Posts

Showing posts from May, 2013

Search in ElasticSearch with where condition -

let's have documents following fields: {field1, field2, costprice, sellingprice} i need run queries of conditions require difference between costprice , sellingprice in standard sql, example be: select * table1 costprice-sellingprice>0 how can achieve in elasticsearch? still scripts need: { "query": { "bool": { "must": [ { "match_all": {} } ], "filter": { "script": { "script": "doc['costprice'].value - doc['sellingprice'].value > 0" } } } } }

get element count with a few parameters angularjs -

i want filter elements using angular's filter check on 2 attributes , number of returned elements this have tried: $scope.countpriorityactive = true; $scope.getcountactive = function(strcat) { return filterfilteractive($scope.tasks, {priority: strcat, active: true}).length; }; but it's not working have started editing example: http://plnkr.co/edit/8ybrtd?p=preview what's mistake? you forgot add "active" attribute in elements of array { id: 1, name: 'iron man', fname: 'tony', lname: 'stark', location: 'stark tower', comic: 'marvel' active: true //this need add each element }, also need call "filterfilter", not "filterfilteractive" unless made new filter yourself

oop - Is there any benefit from explicitly defining all used classes and namespaces at the beggining of PHP class? -

consider these 2 classes: namespace foo\bar; use logicexception; use memcached; class baz extends memcached { public function testbaz() { throw new logicexception('not implemented'); } } the same class written as: namespace foo\bar; class baz2 extends \memcached { public function testbaz() { throw new \logicexception('not implemented'); } } is there diffrence in performance of these 2 classes? if use composer's optimized autoloading? also consider these 2 classes: namespace foo\bar; use acme\demo; class kaz { public function init(demo\unita $unita, demo\unitb $unitb) { // } } the same coded as: namespace foo\bar; use acme\demo\unita; use acme\demo\unitb; class kaz2 { public function init(unita $unita, unitb $unitb) { // } } and again same questions: there performance diffrence between two? if use composers optimized autoloading? to clarify questions: there

javascript - Update DOM reference in jQuery each -

i modifying elements innerhtml property inside $.each() loop. if stack of elements contains childrens of element update innerhtml , dom reference of children lost. example: $(function(){ $stack = $(".myelement, .myelement *"); $stack.each(function(){ var $this = $(this); var element = $(this)[0]; console.log(element.innerhtml = element.innerhtml + " modified"); }); }); fiddle: https://jsfiddle.net/b0ux0v5e/ what happens first modify innerhtml of .myelement . includes children p . therefore dom reference of element lost , "modified" not appended. how can such scenario solved without building function creates unique selector element , re-catches in each loop? note: not asking appending text nodes. example. in real project replacing text in innerhtml . don't modify innerhtml, destroy/recreate elements inside , force re-render. can use insertadjacenthtml or jquery's append add element.

go - Panic during panic -

when running http server in go (go1.2.1 linux/amd64) rare error. unexpected fault address 0xb84004 fatal error: fault [signal 0x7 code=0x2 addr=0xb84004 pc=0x421d62] goroutine 1 [running]: unexpected fault address 0xacb59c panic during panic this happened once, far, after week of running , not reproducible. however, still know means , how happen. unfortunately cannot provide code sample, since don't know might occur , code not open source (yet), i'm looking more general answer. anyone?

asp.net - File is being used by another process in c# -

i trying delete file in c#, receiving message file used process. want check if files exists , close it. using following function in order check if file open: public static bool isfileinuse(string path) { if (string.isnullorempty(path)) throw new argumentexception("'path' cannot null or empty.", "path"); try { using (var stream = new filestream(path, filemode.open, fileaccess.read)) { } } catch (ioexception) { return true; } return false; } and trying when file in use close it: bool checking = isfileinuse(file ); file.create(file ).close(); if (file.exists(file)) { file.delete(file ); } i got issues in file.create line, receiving message: file being used process. edit: trying use lock approach in order delete file. suppose delete file inside lock statement? how can use lock statement? why suppose reading operation fail

symfony - Symfony2: Dynamically generate URL protocol (HTTP/HTTPS) -

i know many ways of forcing route or whole section use either http or https: http://symfony.com/doc/current/cookbook/routing/scheme.html http://symfony.com/doc/current/cookbook/security/force_https.html how let symfony 2 adopt protocol scheme (http vs https) ...my question is: there way decided dynamically? by this, mean, when generate url {{url('route_name'}} generates url using same protocol current page using. http://domain/index links to http://domain/route https://domain/index links to https://domain/route

Can regular JavaScript be converted to asm.js, or is it only to speed up statically-typed low-level languages? -

i have read question how test , develop asm.js? , , accepted answer gives link http://kripken.github.com/mloc_emscripten_talk/#/ . the conclusion of slide show " statically-typed languages , c/c++ can compiled javascript ", can " expect speed of compiled c/c++ 2x slower native code, or better, later year ". but non-statically-typed languages, such regular javascript itself? can compiled asm.js? can javascript compiled asm.js? not really, because of dynamic nature. it's same problem when trying compile to c or to native code - need ship vm take care of non-static aspects. @ least, such vm possible: js.js javascript interpreter in javascript. instead of trying create interpreter scratch, spidermonkey compiled llvm , emscripten translates output javascript. but if asmjs code runs faster regular js, makes sense compile js asmjs, no? no. asm.js quite restricted subset of js can translated bytecode. yet first need

How to check all type of file and display the validation message while uploading file using PHP -

i need upload below type of file using php. 1-.png, 2-.jpeg 3-.jpg 4-.pdf, 5-.ppt 6-.docx , excel sheet. i explaining code below. <form name="billdata" id="billdata" enctype="multipart/form-data" method="post" onsubmit="javascript:return checkform();" action="complain.php"> <div style="color:#f00; text-align:center;"> <?php echo $error; ?></div> <div class="input-group bmargindiv1 col-md-12"> <span class="input-group-addon ndrftextwidth text-right" style="width:180px">upload document :</span> <input type="file" class="filestyle form-control" data-size="lg" name="uploadme" id="bannerimage" onchange="javascript:displayimage(event);"> </div> </form> complain.php: $target_dir = "upload/"; $target_file = $target_dir . basename($imagename); $upl

javascript - How group objects in array from ng-repeat with filter? -

how group objects in array ng-repeat filter ? i have array objects, , group objects countries. sample : have result : free : australia, india, united states pay : australia not pay : australia, india from : $scope.lists = [{ "id": 1 "field": [ { country: "australia", type: "free" }, { country: "australia", type: "pay" }, { country: "australia", type: "not pay" }, { country: "india", type: "free" }, { country: "india", type: "not pay" }, { country: "united states", type: "free" }, }, { "id": 2 "field": [ { country: "australia"

c# - add item and fill DropDownlist from db -

add ---select--- item , fill dropdownlist db if (cboassignto != null) { getusers(); cboassignto.datasource = getactiveusers(dstauthusrlist).tables[0]; listitem lstitm = new listitem("new", ""); cboassignto.items.insert(0, lstitm); } i set proterty appenddatabounditems true , add 1 empty value .aspx <asp:dropdownlist id="cboassignto" runat="server" appenddatabounditems="true" > <asp:listitem value="" text=""></asp:listitem> </asp:dropdownlist> then can bind data .cs cboassignto.datasource = getactiveusers(dstauthusrlist).tables[0]; cboassignto.databind();

What is the best way to update files on nodes using chef? -

i have file in chef recipe , on node configure chef. want if file modify automatically changes in configured node using chef. my approach is, make recipe , put file in template folder , put recipe in runlist of nodes. cron scheduled chef-client on nodes. when files updated , recipe uploaded on server, files on nodes update. other approach more efficiently. is possible without cron. eg. chef server if file modify in recipe. it depends - always. you can use remote_file resource download files remote locations (e.g. via http). way, chef can automatically deploy updated files, if replace on source server. you can use use git or deploy resources deploy files git repository. way, update git repo , chef update node new content. but either way, chef-client changes during chef run. can trigger through cron or run chef service. triggering chef-client run automatically, either kick-off chef-client via ssh (e.g. automated jenkins server) or might give chef's push j

inversing the keys and values in a dictionary python -

this question asked wondering if there way solve problem without using .iteritems() or .items() ?? https://stackoverflow.com/a/8305541/3975231 i've tried myself know can't iter on values in dictionary dictionary = {} key in d: = key dictionary[key] in d: b = dictionary[key] dictionary[b] = return dictionary and this: dictionary = {} key in d: = key d[a] = return dictionary would appreciate in second example you're not adding dictionary . should be: dictionary = {} key in d: dictionary[d[key]] = key # no need save key in new variable return dictionary

ruby on rails - "We're sorry, but something went wrong." - right after deploying in production -

i've released rails 4.2.5 app in production, working fine during development, once put secret key secret.yml and restarted passenger, got typical error 500 message, can't tell comes because development.log , production.log doesn't show @ all. this first time release raill app i'm sadly newbie in domain though went relatively fine until now, don't have clue @ solve problem.. my server on debian 8, apache2 , passenger (if can help) thank in advance edit i think found problem, help app 25227 stderr: started "/" 92.90.21.174 @ 2016-01-28 11:53:17 +0100 app 25227 stderr: app 25227 stderr: mysql2::error (access denied user 'siteweb'@'localhost' (using password: no)): just sure, mean didn't set password database while give 1 when i'm attempting connect ? thank again in advance

ip - Is iptunnel possible in amazon web services? -

is there way use iptunnel in elastic ip of instance in aws. or other method? want client view resources using private , secure tunnel. yes, did using service amazon direct connect

sql - PostgreSQL : Optimizing function with virtuals tables without "UNION SELECT" -

i'm wondering if possible optimize function without creating table , indexes. this function : create or replace function decode_trame_v3(in tid integer) returns table(id integer, card numeric, kilo double precision) $body$ declare v_weights character varying; v_waste_no integer = 0; v_number_waste integer; begin select weights data data.id = tid v_weights; select coalesce(length(v_weights)/7, 0) v_number_waste; loop exit when v_number_waste = v_waste_no; return query convert_table (letter, value) ( select '-' letter, 63 value union select ':', 62 union select 'z', 61 union select 'y', 60 union select 'x', 59 union select 'w', 58 union select 'v', 57 union select 'u', 56 union select 't', 55 union select 's', 54 union select 'r', 53 union select 'q', 52 union select 'p', 51 union select 'o', 50 union select 'n', 49 union select 'm', 4

object - Use of prototype in below example Javascript -

while going through concepts of prototype. saw below example stackoverflow - add new element existing object var myobj = function(){ this.property = 'foo'; this.bar = function(){ } } myobj.prototype.objprop = true; var newobj = new myobj(); my question use of " myobj.prototype.objprop = true; " above code snippet. i beginner. referred other post similar this. couldn't make out. any on appreciated. thanks. prototype used having common values in similar objects. property objprop available objects not belong anyone. when myobj.objprop , objprop searched inside myobj . if not found, property searched in __proto__ . also note if define property of same name inside object, myobj.objprop , add property in object , not override proto one var myobj = function(){ this.property = 'foo'; this.bar = function(){ } } myobj.prototype.objprop = true; var newobj = new myobj(); console.log(newobj); cons

powershell - Exclude directories when using hg purge -

i trying perform hg purge in repository need exclude directories (e.g. node_modules , , else) purge. basically, want keep (not-delete) these directories, in order avoid downloading them again everytime. this build process, runs hg purge before starting new build process , consequently removes ignored (listed in .hgignore ). don't want happen directories node_modules , other else. is there way tell mercurial not make purge on directories? use -x / --exclude command line switch (can specified more once): hg purge -x 'glob:node_modules/**.js' the above pattern ignores javascript files in node_modules directory, including in subdirectories. use /** match under directory: hg purge -x 'glob:node_modules/**' see file names , pattern matching chapter in mercurial guide; patterns described there can used here. when testing patterns, make sure use --print command-line option hg purge , it'll print files removed. helps when iterating

Vagrant define path to website dir -

first, sorry stupid question, because i'm pretty new in vagrant , linux. i'm trying separate vagrantfile , website project directory. so have next directories structure: d:\vagrant machines\domain.com vagrantfile install.sh domains\domain.com app\code.php web\index.php i want run vagrant dir d:\vagrant\machines\domain.com , virtual machine d:\vagrant\domains\domain.com home , d:\vagrant\domains\domain.com\web publick_html dir. how can that? help! you can add sync folder can add in vagrantfile config.vm.synced_folder "d:\\vagrant\\domains\\domain.com\\web", "<path deploy files in vm>" note : not using windows not sure how path should set in file try \\ or forward slash d:/vagrant/....

doctrine2 - Syntax error with execute a query with one to one -

i have 2 entities: user entity 2 fields are: id (@id), username profile entity 2 fields are: user (@onetoone,targetentity="user"), fullname but when make query try things read jpa book: select p profile p p.user.username = 'john' it alerts me message: [syntax error] line 0, col 55: error: expected =, <, <=, <>, >, >=, !=, got '.' as of current ebnf , syntax used invalid in doctrine 2 orm. have join related entity following: select p profile p join p.user u u.username = :username

python - how to write unittest in Django for method with ListField variable? -

i have never written unit test before. i'm trying write unit test class: class user(models.model): facebook_id = models.charfield(max_length=200) friends = listfield() status = models.charfield(max_length=200) status_time = models.datetimefield('date published') @staticmethod def login(cls, userid, facebook_friends): myuser = none try: myuser = user.objects.get(facebook_id=userid) except user.doesnotexist: myuser = user() myuser.status_time = datetime.datetime.now() - datetime.timedelta(minutes=16) myuser.facebook_id = userid myuser.save() # user exists myuser.friends = facebook_friends myuser.save() return {"data":myuser.get_friend_statuses()} but i'm not sure how write unit test facebook_friend since it's in list field class: class listfield(models.textfield): __metaclass__ = models.subfieldbase d

javascript - How to display GetResponse form in Fancybox popup -

i try display getresponse form created , code there, fancybox popup on wordpress site. i have problem displaying it. content popups empty. the code getresponse looks this: <script type="text/javascript" src="there code here"></script> here html: <a href="#open_newsletter_popup" class="click_to_open_np">click</a> <div class="newsletter_signup" id="open_newsletter_popup"> <script type="text/javascript" src="the code here"></script> </div> and jquery display fancybox popup window: jquery(window).load(function() { settimeout(function() { jquery("#open_newsletter_popup").fancybox().trigger('click'); }, 5000); }); i hope have answer on this. thanks in advance guys.

multithreading - Creating multiple threads in C -

i beginner in programming using c.for college project want create multi-threaded server application multiple clients can connect , transfer there data can saved in database. after going through many tutorials got confused how create multiple threads using pthread_create. somewhere done like: pthread_t thr; pthread_create( &thr, null , connection_handler , (void*)&conn_desc); and somewhere like pthread_t thr[10]; pthread_create( thr[i++], null , connection_handler , (void*)&conn_desc); i tried implementing both in application , seems working fine. approach of above 2 correct should follow. sorry bad english , description. both equivalent. there's no "right" or "wrong" approach here. typically, see later when creating multiple threads, array of thread identifiers ( pthread_t ) used. in code snippets, both create single thread. if want create 1 thread, don't need array. declaring variable(s) didn't use. it'

hadoop - HDFS: Actual space of all disks on cluster vs usable HDFS size -

how can calculate available size of hdfs cluster based on total size of disks in cluster? e.g. if cluster 10 machines, each 1tb of storage, hadoop fs -df report? more specifically, need store 5 tb of data in hdfs cluster. how total disk space cluster need? that depends on how set hdfs replication factor. default (and recommended) 3. you can set hdfs keep non-dfs space so, substract if need be. a rough calculation file size * 3 = total storage needed .

python - Wrong media location using Django management command -

i'm downloading image , saving models image field, on separate media app. working fine while code in view moved code management command can't image save separate media location. before correctly saving /home/me/webapps/myapp_production_media/images files being saved incorrectly /home/me/webapps/myapp_production_django/src/media/images command: download_image('temp', model_instance.image, new_image) def download_image(name, image, url): input_file = stringio(urllib2.urlopen(url).read()) output_file = stringio() img = image.open(input_file) if img.mode != "rgb": img = img.convert("rgb") img.save(output_file, "jpeg") image.save(name+".jpg", contentfile(output_file.getvalue()), save=false) model: class mymodel(models.model): image = models.imagefield(upload_to='images', null=true, blank=true) i've added myapp_production_media/images path name+".jpg" doesn'

graph - Best path algorithm while avoiding moving enemies? -

i have general graph/path-finding question had interview. suppose trying specific node on 2d graph, , there enemy units transversing graph's nodes, searching you: best way maximize chances of reaching goal without encountering enemy unit? i curious of best algorithm or general approach handle this. p.s: know enemy units located assuming want human in dangerous maze do: go ahead , run away whenever see enemy, here simple idea: run breadth first search once starting goal on whole graph store distance goal in every node. in step, ignore enemies. of course assuming have distance measure in graph. otherwise counting number of nodes during bfs applications. keep distance of last node goal, let call quantity maxdist . run "small" breadth first search every enemy towards directions. small, because stop after distance of k , k number of graph nodes want keep away enemies or other suitable metric (this represents " seeing "). similar thing in bfs:

background - Why, dows 'neo4j console' work, and 'neo4j start' doesn't? -

i want use neo4j. installed neo4j-community 2.3.2-1 archlinux aur , when ise neo4j console everything works fine. when want start server in background neo4j start the server won't start error message: warning: max 1024 open files allowed, minimum of 40 000 recommended. see neo4j manual. starting neo4j server...process [20559]... waiting server ready... failed start within 120 seconds. neo4j server may have failed start, please check logs. the server did not try start or 120 seconds, more 2 seconds. in addition callot find log-files anywhere. google told me tryout neo4j start-no-wait when command: warning: max 1024 open files allowed, minimum of 40 000 recommended. see neo4j manual. starting neo4j server...process [21088]...started server in background, returning... but nothing started , webclient doesn't work when use neo4j console . so basic question is: why neo4j console work , neo4j start does not? , how can start neo4j in background , stop again without kill

php - Check if request to server was made by ionic app -

right have ionic project finished comes php backend. make backend little bit more secure against influences outsite make backend accessible within ionic project (native app). tried restrict domain since native app doesn't have domain that's not gonna work. i can't show code because i'm absolutely clueless on how approach this. thanks in advance we make backend accessible within ionic project (native app). given existence of reverse engineering , futility of drm, what you're asking is, strictly speaking, not possible in absolute terms. can take app, analyze code/behavior (usually freely available tools), , write own app communicates server. to make backend little bit more secure against influences outsite given above impossible, threat model? attacks trying protect against? should assume clients malicious , validate input on server side. if that, don't need worry whether or not used native app communicate server. consider workflo

apache spark - Native library missing warning while running SVD on 10Kx10K dense matrix -

i doing svd on dense matrix of size 10000x10000 using computesvd method on indexedrowmatrix on apche spark. run log shows warning follows warn blas: failed load implementation from: com.github.fommil.netlib.nativesystemblas warn blas: failed load implementation from: com.github.fommil.netlib.nativerefblas warn lapack: failed load implementation from: com.github.fommil.netlib.nativesystemlapack warn lapack: failed load implementation from: com.github.fommil.netlib.nativereflapack kindly let me know if affects running time of spark job , if yes how install them on centos. thanks in advance...

mvvm - How to insert button into Grid from ViewModel C# class in windows 8.1 store app -

i can insert button grid control code behind file var felem = new button(); felem.content = "button text"; bggrid.children.add(felem); // bggrid defined in xaml how can add same button grid view model class? in code-behind of xaml page (xaml.cs) need publicly expose grid public grid mygrid => bggrid; then can access viewmodel so: frame rootframe = window.current.content frame; var page = rootframe.content yourpageclassname; var felem = new button(); felem.content = "button text"; page.mygrid.children.add(felem); however, not mvvm @ all.

Confusing use of gradient in Pattern recognition and machine learning -

Image
i'm reading prml , gradient notation seems confusing. in chapter 2, page 116, a column vector: and on appendix e page 707, column vector: however, in chapter 3, during derivation of least-square, page 141, row vector: can clarify these confusing details me? have read posts on web, of them says gradient strictly column vector, says depends on calculation being carried out, says depends on author, , couldn't come conclusive answer the answer stated in question - gradient vector of partial derivatives, treating column/row vector not matter. people use orientation best particular use/derivation, same applies putting data points in data matrix row/column wise, defining linear projections column/row vectors etc. thus, answer it depends on particular use , have check kind of notation author uses. why that? because not matter, , calculations - row notation reduces amount of transpose operations needed, , - column notation helps. that's all.

ruby on rails - How to change password without current password in devise? -

i using devise authentication , have role each user , allow user admin role create new user , want admin user edit password rest of user if forgot password. cannot able change password without current password in edit. how can allow admin user change password editing users password , save rest of values. since update_without_password still required current_password update password, have have update this: def update # required settings form submit when password left blank if params[:user][:password].blank? params[:user].delete("password") params[:user].delete("password_confirmation") end @user = user.find(current_user.id) if @user.update_attributes(params[:user]) set_flash_message :notice, :updated # sign in user bypassing validation in case password changed sign_in @user, :bypass => true redirect_to after_update_path_for(@user) else render "edit" end end

javascript - Meteor callback on some template render -

in meteor project, have code this: baz = function() { // jquery add/remove class here... }; template.foo.onrendered(function() { baz(); }); template.bar.onrendered(function() { baz(); }); template.qux.onrendered(function() { // no baz() call }); is there better way accomplish task without repeat baz(); on template render? meteor 1.2.1 allows run global onrendered() function via following code: template.onrendered(function() { var = this; //pass baz() if need deps.afterflush(function() { console.log('baz'); baz(); }); }); if doesn't fit needs, , want on every page, use onrendered() within common template menu or page header, not guarantee html attempting alter jquery rendered.

css - Filter using Checkboxes -

i have website: http://ba.nowcommu.myhostpoint.ch/table.html as can see, have 2 tables. need, if possible, hide , display tables in same position using checkboxes "table 1" , "table 2". i think have put 2 tables in same <div> , what? how can this? you few ways here pops mind: give each table individual id (id="table1" , id="table2"). then create 2 checkboxes , give them unique id's. $('#checkbox1').on('click', function(event) { $('#table1').toggle($('#checkbox1').is(":checked")); }); $('#checkbox2').on('click', function(event) { $('#table2').toggle($('#checkbox2').is(":checked")); }); you more dynamic javascript if understand question correctly should work.

PHP MYSQL Combine two queries on one line -

i have database books onto course assigned '70' in status column, cancels in given '10'. i want report on booked on course eliminating have cancelled. the problem retains number, query below shows everyone. remove has 10 regardless of fact they've got 70 also. where statuscode <>'10' , statuscode <>'20' , statuscode <>'30' , statuscode <>'40' , statuscode <>'50' , statuscode <>'60' , statuscode ='70' , statuscode <>'80' , statuscode <>'90' , statuscode <>'100' where statuscode ='70' , mod(cast(statuscode unsigned),10)=0 update: the subselect returns ids of users cancelled (status code=10) remove ids. delete the_table t id in (select id the_table t statuscode='10')

linq - Dictionary to XML C# -

i have dictionary<tkey, tvalue> , want convert xml, using linq. <root> <key>tkey1</key> <value>tvalue1</value> <key>tkey2</key> <value>tvalue2</value> <key>tkey3</key> <value>tvalue3</value> </root> right using var xdoc = new xdocument(new xelement("root", values.select(entry => new xelement(entry.key, entry.value)))); and getting <root> <tkey1>tvalue1</tkey1> <tkey2>tvalue2</tkey2> <tkey3>tvalue3</tkey3> </root> as @alex mentioned, structure of desired xml not good, if need legacy system.. xdocument xdoc = new xdocument( new xelement("root", dictionary.selectmany(kvp => new [] { new xelement("key", kvp.key), new xelement("value", kvp.value) }))); for sample dictionary var dic = new dictionary<int,

angularjs - How to make Jenkins fail the build of zero tests were run (due to configuration error) -

Image
i have jenkins job runs javascript unit tests (jasmine + karma). result of step junit-compatible xml file. i have configured post-build action using `` publish xunit test result report` plugin, can handle variety of test result formats, including junit. it works fine, if there failed tests, step fails build. ...but doesn't fail build in case of catastrophic failure: if there error bad in web app no tests run @ all, xml result file happily <testsuite/> ... meaning there 0 tests, meaning there 0 failed tests, meaning peachy! that's false positive if ever saw one. how can configure jenkins / xunit reports plugin / ... take failure case account? fwiw: use bower manage js modules use, , config file had error, no 3rd party deps downloaded our angular app, including angular package. i did using 'text finder' plugin, , searching exact file contents if there no tests. it's totally counter-intuitive, in order fail build, need not check

javascript - get highcharts data from table angularjs -

i'm trying highcharts data html table using angularjs here html: <table class="table-count" id="table-count"> <thead> <tr> <th> priority </th> <th> total </th> <th> active </th> </tr> </thead> <tbody> <tr> <td> <span class="color-p0"></span> p0 </td> <td ng-model="countpriority"> {{getcount("p0")}} </td> <td ng-model="countpriorityactive"> {{getcountactive("p0")}} </td> </tr> <tr> <td> <span class="color-p1"></span>p1 </td> <td ng-model="countpriority"> {{getcount("p1")}} </td> <td ng-model="countpriorityacti

R raw text file missing lines after read -

i looking text mining , attempting read in flat file raw texts, when read file in, missing more half rows after read. file looks similar this; ddjkfj; raw line of text ? fjpflij jfioej33 line of text jdkfjd etc. i trying read in, using method, data <- read.table('text.txt',sep='\n',fill=t) how can read in without skipping or joining lines? you can try using readlines instead: lines <- readlines('filetoread.txt') lines [1] "ddjkfj; raw line of text ? fjpflij " [2] "jfioej33 line of text jdkfjd"

javascript - Is tail recursion merely a special case of CPS? -

i've implemented map in tail recursive , continuation passing style. both versions quite similar: var inc = x => ++x; var xs = [1,2,3,4,5]; var mapr = f => xs => { var rec = acc => { acc[acc.length] = f(xs[acc.length]); return acc.length < xs.length ? rec(acc) : acc; } return rec([]); } mapr(inc)(xs); // [2,3,4,5,6] var mapc = f => xs => cc => { var rec = acc => cc => { acc[acc.length] = f(xs[acc.length]); return acc.length < xs.length ? cc(acc)(rec) : acc; } return cc(rec([])(rec)); } mapc(inc)(xs)(console.log.bind(console)); // [2,3,4,5,6] instead of cc(acc)(rec) have wrote rec(acc) . conclusion correct, tail recursion merely special case of cps , mapc written var rec = acc => {...} proper cps function? i'd write thing in pure cps following: const inc = x => cont => cont(x+1); const map = f => xss => cont => { if (!xss.length) cont([]);

javascript - How to use ng-init to select a default value in a select box when the ng-model and the ng-options are referencing different objects -

i have select box iterates on listofthings , , model has currentthing property. select box binds currentthing correctly. however, can't ng-init set default value in listofthings currentthing . following isn't setting default value. <select ng-options = "something something.name in controller.listofthings" ng-model = "controller.currentthing" ng-init = "something = controller.currentthing" ng-change = "controller.changething(controller.currentthing)"/> i output values of something , currentthing , they're same. any ideas? thanks! instead of using in dom should assign default value in controller like: $scopr.controller.currentthing = $scopr.controller.listofthings[0];// first element or need and no need ng-init = "something = controller.currentthing"

ember.js - Ember 2 set select value in component -

i have little problem. there component, must render form editing model's record. , need render on listing page below each model's record. there gist: https://gist.github.com/mxgoncharov/9f1b4cd52cac9173fd46 problem: when open it, fields without select-tags filled. if render e.g. groupid or select-tag's value label shows right (e.g. '6'). select-tag doesn't show selected value, , select-tags shows prompt. how can redraw or refill select-tags? maybe did smth wrong?

Need to ZIP an entire directory using Node.js -

i need zip entire directory using node.js. i'm using node-zip , each time process runs generates invalid zip file (as can see this github issue ). is there another, better, node.js option allow me zip directory? edit: ended using archiver writezip = function(dir,name) { var zip = new jszip(), code = zip.folder(dir), output = zip.generate(), filename = ['jsd-',name,'.zip'].join(''); fs.writefilesync(basedir + filename, output); console.log('creating ' + filename); }; sample value parameters: dir = /tmp/jsd-<randomstring>/ name = <randomstring> update: asking implementation used, here's link downloader : i ended using archiver lib. works great. example var file_system = require('fs'); var archiver = require('archiver'); var output = file_system.createwritestream('target.zip'); var archive = archiver('zip'); output.on('close', function () { console.

can't deduce the numeral representation (church encoding) of a lambda expression λx.λy.x(xy) -

i have lambda expression: λx.λy.x(xy) , , i'm supposed infer integer representation of it. i've read lot church encodings , church numerals can't find number is. can explain me in way 3 year old can understand or refer me resource better wikipedia? church encoding of integers following: "0" ≡ (λf.(λx.x)) : think of (λf.(λx.x)) meaning: given function f , element x , result x : it's applying function f 0 times x . "1" ≡ (λf.(λx.(fx))) : think of (λf.(λx.(fx))) meaning: given function f , element x , result (fx) : should thought of apply f x or, in more standard mathematical notation, f(x) . "2" ≡ (λf.(λx.(f(fx)))) : think of (λf.(λx.(f(fx)))) meaning: given function f , element x , result (f(fx)) : should thought of apply f x twice or, in more standard mathematical notation, f(f(x)) . "3" ≡ (λf.(λx.(f(f(fx))))) : think of (λf.(λx.(f(f(fx))))) meaning: given function f , element x , result (f(f(fx

sql - Mysql - PHP show data from one column over 3 columns -

i have moodle install building standalone report. the fieldid has integers relate personnel info. fieldid information 1 job title 2 payrol 3 dept i 3 separate columns info. works fine within moodle using alias's reference alias column info. can't work in php. from moodle join prefix_user_info_data uid on uid.userid = u.id join prefix_user_info_data uid2 on uid2.userid = u.id join prefix_user_info_data uid3 on uid3.userid = u.id join prefix_user_info_data uid4 on uid4.userid = u.id uid.fieldid = '13' , uid2.fieldid = '1' , uid3.fieldid = '3' , uid4.fieldid = '8' sharing php , full code isn't going much, showed relavant bits. i've included part of php using info. ['data'] columns 1 information is. when include , uid2.fieldid = '1' shows department. 2 columns job title , payroll number. $course = $_post["course"]; $date= $_post["date"]; $sql = "sele

Python - Android logcat output of stdout to textview then save to .txt file error -

i have following python code, uses android logcat via stdout pull logs off phone wxpython text field. login app, username jack , password jack@123$ logcat output stops error, seems not @ or $ symbols: return codecs.charmap_decode(input,errors,decoding_table) unicodedecodeerror: 'charmap' codec can't decode byte 0x9d in position 76: character maps <undefined> or when try getvalue() of text control save .txt file open writing: unicodeencodeerror: 'ascii' codec can't encode characters in position 204447-204449: ordinal not in range(128) the code logcat function follows def logcat(self): params = [toolsdir + "\\adb.exe", "logcat"] p = popen(params, stdout=subprocess.pipe, bufsize=1) line in p.stdout: #line = line.decode('latin-1') self.progressbox.appendtext(line) def savelog(self,e): f = open(outdir + '\\' + pkgname + '\\' + pkgname + '_logcat.txt', 'w'

amazon web services - Does CloudFront support versioned origins? -

i have versioned s3 bucket origin. correct format accessing specific version of object cloudfront? http://example.cloudfront.net/files/file.pdf?verisonid=[id] it ignoring versionid , serving head object. my s3 bucket policy allows following actions cloudfront: s3:getobjectversion s3:getobject i've searched , searched can't seem find documentation on this. how specify versionid in cloudfront url? i figured out. in cloudfront go distributions > behaviors. set "forward query strings" yes. allow cloudfront pass versionid s3 , cache correct version. note need s3:getobject bucket policy action make work.

JavaScript set input value in while loop -

the code below: v1 = document.getelementbyid('double').value; while (v1 < 10) { v1++; = new date().gettime(); while(new date().gettime() < + 1000){} document.getelementbyid('inputarea').value = v1; } inputarea text box has 1 number, want increase number 1 ever second until reaches 10. problem inputarea shows last value 10, supposed ....7, 8, 9 10. you can use setinterval var timerid = setinterval(function(){ v1 = parseint(document.getelementbyid('double').value,10); if(v1 == 10){ clearinterval(timerid) } else{ document.getelementbyid('double').value = (v1+1) } },1000); <input id="double" value="1" />

android - Multiple TextViews in a LinearLayout, Last TextView should start with a new line when text goes beyond screen width -

i have 3 textviews in linearlayout. want last textview appear in new line (from left side) when text goes out of bound of screen width. below xml code <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/topcontainer" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginbottom="@dimen/general_padding" android:gravity="center_vertical"> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centervertical="true"> <textview android:id="@+id/objectnametv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="will smith " android:singleline="true" android:ellipsize="none" android:textappea

git - Bluemix spark jazzhub addjar -

Image
i trying add jar in spark scala notebook on bluemix. examples speak using public github url. have code in jazzhub git repository. problem run jazzhub don't have public url without user , password access jar file. i tried several url's userid:password etc did not succeed load jar file. is there example jar file jazzhub loaded spark scala notebook? first, ensure project publicly available reviewing settings in jazzhub. please go project's settings , go options. next, uncheck private if checked. lastly, click save apply changes. second, since project jazzhub git repo, there git repo link provided. find link, go project's settings , go general. next, note url next git url. third, construct complete download url. the complete url have following format: [git url]/contents/[git_branch]/[jar_location] for example, download psclnt.jar within master branch of sample project, following url used: https://hub.jazz.net/git/hobert/libtest/contents/mas

xml - Flex Stacked ColumnChart not showing up -

i have following xml structure: <root> <day name="sun" values="21,22,25,26"/> <day name="mon" values="27,20,22,25"/> </root> i want represented in column chart stacked bars. first column comprise of columns stacked on each other values 21,22,25 , 26 corresponding sunday. length of values might change each time dataprovider updated. wrote code like: var columnchart:columnchart = new columnchart(); columnchart.type="stacked"; var yaxisdata:string = "@values"; var xaxisdata:string = "@name"; var dp:xmllistcollection = new xmllistcollection(xmlfile.day); columnchart.dataprovider = dp; var valuelength:int = dp[0][yaxisdata].tostring().split(",").length; for(var count:int = 0;count<valuelength;count++){ var bseries:columnseries = new columnseries(); bseries.dataprovider = dataprovider; bseries.xfield = xaxisdata; bseries.yfield = yaxisdata+"["+count+"]&q

internet explorer 10 - IE 10 elements with relative position disappearing after scrolling in parent element -

elements position: relative , located inside table cells in big table disappear in internet explorer 10 on windows 7 in particular case: scroll down page scroll div#scroller right scroll top all browsers work expected, ie10 shows blank table cells at point, resizing ie10 window trigger correct display of cell contents. big table, cells identical: <td><div>foo bar</div></td> css: td div { position:relative; } here's extremely simplified demo: http://jsfiddle.net/86bau/ this known , reported bug in ie10. however, ms seems unwilling it: https://connect.microsoft.com/ie/feedback/details/817099/ie-10-elements-with-relative-position-disappearing-when-scrolling-in-parent-element-on-windows-7 a hack seems force ie use hardware acceleration (or otherwise forcing redraw toggling display:none ). worked me: -ms-transform: scale(1); transform: scale(1); hope work you!