Posts

Showing posts from April, 2012

c++ - In general How to find out whether client has assigned static Ip or it is dhcp client -

i have retrieved ip, subnet , broadcast using ioctl() system call. can me find out whether client static or dhcp?? asking in general , using system call. client instead of interface. the interface has nothing dhcp. can configured have particular ip address, gateway, etc. that's all. configuration, however, can done smart little program called dhcp client :) need find out (i mean, program) has configured interface. update: for example, under majority of linux distributions may a ps aux | grep 'dhcpcd .* eth0' if gives result /sbin/dhcpcd --netconfig -l -e -hhh -c /etc/sysconfig/network/scripts/dhcpcd-hook -t 0 -h somehostname eth0 you can eth0 configured dhcp

VideoView not playing video from URL in Android -

i tried many links links show same error.but it's giving error "can't play video". my code following public class videodemo extends activity { private videoview video; private static final string path ="http://www.ustream.tv/embed/6540154?v=3&wmode=direct"; @override public void oncreate(bundle icicle) { setcontentview(r.layout.activity_main); videoview = (videoview) findviewbyid(r.id.videoview); try { // start mediacontroller mediacontroller mediacontroller = new mediacontroller( videodemo.this); mediacontroller.setanchorview(videoview); // url string videourl uri video = uri.parse(videourl); videoview.setmediacontroller(mediacontroller); videoview.setvideouri(video); videoview.start(); } catch (exception e) { log

java - why getting socket closed error after running script by jmeter? -

i getting "non http response code: java.net.socketexception response message: non http response message: connection reset" type of error after running jmeter script i bet you're experiencing problem described in connection reset since jmeter 2.10 ? wiki page so recommend take next steps: switch "implementation" of http request samplers "httpclient4". best way using http request defaults have change value in 1 place. as per wiki page add next 2 lines user.properties file (lives under /bin folder of jmeter installation) httpclient4.retrycount=1 hc.parameters.file=hc.parameters add next line hc.parameters file (same location, /lib folder) http.connection.stalecheck$boolean=true remember restart jmeter after making these changes, properties change not dynamic, they're being picked upon jmeter startup. hope helps.

angularjs - IE only anglure http request cache / MVC issue -

i have code loads list mvc controller. i load data with $scope.loaddata = function () { $scope.promise = myhttp = $http.get("forms"); myhttp.success(function (response) { $scope.rows = response; this works fine, data loads , can see data on html page. but, if reload code, eg run $scope.loaddata again, fails in ie. works in chrome, ff fails in ie , spartan (tested on non windows 10 same issue) the headers like cache-control: private, s-maxage=0 the mvc controller has authorise attribute hence s-maxage=0, prevents proxy caching. i have tried $scope.promise = myhttp = $http.get("forms"); when fiddle, dont see request going server code fired. if nav new page , nav reload fresh data expect. when reload done $http thanks edit post works, eg $scope.promise = myhttp = $http.post("forms");

delphi - Convert extended value to Time -

i want convert extended value time. before decimalseparator hours after decimalseparator minutes digital 8,62944444444444 --> 8:37 1,41666666666667 --> 1:25 i've made funtion 1,41666666666667 --> 1:24 must 25 minutes function myconvertion(avalue: extended): tdatetime; var hour, min, sec, msec: word; begin hour:= trunc(avalue); min:= trunc(frac(avalue)*60); result:= encodetime(hour, min, 0, 0); end; when use exact 1,41666666666667 i'm 1:25 value must convert comes out soap enterface double (opostcalculationday.directassignedworktime). the value in debug mode = 1,41666666666667 myconvertion(1,41666666666667) --> 1:25 myconvertion(opostcalculationday.directassignedworktime) --> 1:24 myconvertion(roundto(opostcalculationday.directassignedworktime, -15)) --> 1:25 myconvertion(roundto(opostcalculationday.directassignedworktime, -16)) --> 1:24 myconvertion(strtofloat(floattostr(opostcalculationday.directassignedworktime)))--> 1:25

Changing locale of user in home page of Grails application -

i've been trying change user locale after logging in (i use spring security). i have tried changing locale in success event handler of spring security (oninteractiveauthenticationsuccessevent) , creating own localeresolver , registering on resources.groovy. it seems work fine pages except home page. this mylocaleresolver class mylocaleresolver implements localeresolver { def springsecurityservice private locale defaultlocale = null; @override locale resolvelocale(httpservletrequest httpservletrequest) { user user = user.findbyemail(springsecurityservice.authentication.principal.username) if (user && !defaultlocale) { if (user.lang) { this.defaultlocale = new locale(user.lang) } else { this.defaultlocale = locale.english } } println "defaultlocale = $defaultlocale" return this.defaultlocale } @override void setlocal

javascript - Mocha test factorization and backtrace -

i run many mocha tests : it('should fail blabla', function () { return <functionthatreturnsapromise>() .then(function () { assert(false); }, function (err) { assert.strictequal(err.message, 'foobar undefined'); assert.strictequal(err.code, 'eundefinedfoobar'); }); }); the things vary among tests function , code , message . i wanted factorize code this: function shouldberejected(promise, code, message) { return promise .then(function () { assert(false); }, function (err) { assert.strictequal(err.code, code); assert.strictequal(err.message, message); }); } (...) it('should fail blabla', function () { return shouldberejected(<functionthatreturnsapromise>(), 'eundefinedfoobar', 'foobar undefined'); }); it works when tests failed, backtraces reference shouldbe

android - Dual sided DrawerLayout, Left side works - Right doesn't -

i using drawerlayout. have 2 listview both side. left side working clicking left-top corner button on actionbar. right side working too.but right side working sliding left right swipe. want put button right-top corner of actionbar open right side (just left-top button on actionbar). how can that? here actionbardrawertoggle codes using; public class mainactivity extends actionbaractivity { private actionbardrawertoggle mdrawertoggle; //.... protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); //.... getsupportactionbar().setdisplayhomeasupenabled(true); mdrawertoggle = new actionbardrawertoggle(this, mdrawerlayout, r.drawable.sidebar, r.string.drawer_open, r.string.drawer_close) { public void ondrawerclosed(view view) { invalidateoptionsmenu(); toast.maketext(getapplicationcontext(),&

how to create a regex for non-english letters with vba's regex 5.5 -

i'm working vba, , started using regex library, finding numerals and/or english text had no problem far, need use on text fields contain mix of numbers , hebrew letters (addresses has several possible formats). i have managed use in "dumb" way, can find literals , short patterns (such as, finding combination means postal box - 2 letter combined non-letter non number between them), can't use \w english - , make life whole lot better. is there anyway create "custom" regular expressions , save them variables? example make (a regex single hebrew word): regex.pattern = "(א|ב|ג|ד|ה|ו|ז|ח|ט|י|כ|ל|מ|נ|ס|ע|פ|צ|ק|ר|ש|ת|ם|ן|ף|ץ)+" and save \מ instance or \hw (short hebrew word), need make several types of patterns , several possible formats recognize, , save me lot of frustration (as ide don't have best interactions hebrew letters). you can create own character class, , use in code: dim hw string hw = "[אבגדהוזחטיכלמנסעפצקרש

node.js - Test form data using Mocha for NodeJS -

i trying write mocha test nodejs sends form data , checks if response ok (200), , res.body has properties, the test fails , dont know reason. increasing timout didnt help, when use advancedrestclient chrome extension form data in payload section works perfectly! .type('form') supposed superagent syntax var should = require('should'), assert = require('assert'), request = require('supertest'), superagent = require('superagent'); describe('data', function () { it('should return status ok (200)', function(done) { this.timeout(20000); request.post('http://xxx:3000/xxx/xxx') .type('form') .send({startdate:"2015-03-08",enddate:"2015-03-24",timelapse:"day"}) .end(function(err, res) { if (err) { throw err;

paypal - What is the payza equivalent php code for this snippet? -

below code use process payment in site. cart has 1 item. code paypal. want sell same item on payza. //process order paypal // prepare data $query = array(); $query['notify_url'] = 'http://mywebsite.com/ipn.php'; $query['cmd'] = '_cart'; $query['upload'] = '1'; $query['business'] = 'payment@mywebsite.com'; //main item $query['item_name_1'] = $item_name; $query['item_number_1'] = '1'; $query['amount_1'] = $item_price; $query['currency_code'] = "usd"; // prepare query string $query_string = http_build_query($query); header('location: https://paypal.com/cgi-bin/webscr?' . $query_string); <form method="post" action="https://secure.payza.com/checkou

Convert JSON object to simple variables in Java -

i have heavy json lots of parameters want convert java object containing few of them. direct conversion such this dataobject obj = gson.fromjson(br, dataobject.class); is not option. how can access individual fields within objects (just value under date , type under attributes under completion_date )? json example: {"results":[ {"date":{ "attributes":{ "type":null}, "value":"december 13, 2010"}, "is_structured":"no", "completion_date":{ "attributes":{ "type":"anticipated"}, "value":"march 2016"}, .... if don't want directly convert input expected object create jsonobject input like jsonobject root = new jsonobject(input); and navigate there attribute need e.g.: root.getjsonarray("results").getjsonobject(0).getstring("is_structur

How to get the email of current logged in user from twitter in android -

i'm integrating twitter application using twitter 4j library. i'm trying extract email of logged in user. there way can take email address of user without having prompt them? i've checked here , doesn't quite explain how achieve i'm after. you can't email user easily, if check documentation need whitelisted twitter . if aren't, can't email, twitter4j doesn't provide method achieve that. and, possible duplicate: get user's email address twitter (android) email of twitter user in twitter4j

python - Django: migration to NullBooleanField fails with IntegrityError "contains null values" -

i'm working in django 1.7 , trying migrate database field called is_dispensing existing booleanfield nullbooleanfield . my migration file: # -*- coding: utf-8 -*- __future__ import unicode_literals django.db import models, migrations class migration(migrations.migration): dependencies = [ ('frontend', '0007_practice_is_dispensing'), ] operations = [ migrations.alterfield( model_name='practice', name='is_dispensing', field=models.nullbooleanfield(), preserve_default=true, ), ] running manage.py migrate fails error: django.db.utils.integrityerror: column "is_dispensing" contains null values the field in models file: is_dispensing = models.nullbooleanfield(blank=true) previously was: is_dispensing = models.booleanfield(null=true, blank=true) and when added it, asked provide default value, set none. i find message confusing -

android - How to keep ListView Item Selected when we navigate and again come on the same fragment? -

i have 1 list view in fragment. clicking item keeping selected because used following code in listselected.xml <item android:state_pressed="true"> <shape android:shape="rectangle"> <solid android:color="#646973" /> </shape> </item> <item android:state_selected="true"> <shape android:shape="rectangle"> <solid android:color="#646973" /> </shape></item> <item android:state_activated="true"> <shape android:shape="rectangle"> <solid android:color="#646973" /> </shape></item> <item android:state_accelerated="false"> <shape android:shape="rectangle"> <solid android:color="#646973" /> </shape> </item> but when go 1 fragment , when again visit same fragment removed want that

How to covert date variable to java.sql.date -

i facing difficulties while trying insert date variable database table. variable called: date date4; the date4 variable value read textbox has calendar picker. inserting in date column, setting field type date: preparedstmt.setdate(4,date4); however, got below message after submitting form: javax.faces.component.updatemodelexception: java.lang.illegalargumentexception: cannot convert 4/1/15 12:00 of type class java.util.date class java.sql.date also, there way insert field in format of date ("dd-mon-yyyy")? convert util date sql date java.sql.date sqldate = new java.sql.date(date4.gettime());

remote desktop - RDWeb asking for credentials on only one of two servers -

i customizing rdweb application remote desktop service windows server 2012. i have configured 2 separate servers rdweb, , rdweb application generated both servers. access remote app of second server using rdweb application of first server through single ui. remote apps both servers coming single ui. suppose have 2 calculator applications both servers, let's call them cal1 , cal2 . when click on cal1 , calculator application runs first server without asking credentials. when click on cal2 ask credentials, , if provide credentials calculator application second server runs. when click on cal2 , should not ask credentials. rdweb application auto-generated , uses form authentication. this, need share cookies between both servers. have use same machine key in web config of both applications, not working.

javascript - What is the difference between client-side and server-side programming? -

i have code: <script type="text/javascript"> var foo = 'bar'; <?php file_put_contents('foo.txt', ' + foo + '); ?> var baz = <?php echo 42; ?>; alert(baz); </script> why not write "bar" text file, alerts "42"? nb: earlier revisions of question explicitly php on server , javascript on client. essential nature of problem , solutions same any pair of languages when 1 running on client , other on server. please take in account when see answers talking specific languages. your code split 2 entirely separate parts, server side , client side . | ----------> http request | +--------------+ | +--------------+ | | | | | | browser | | | web server | | (javascript) | | | (php etc.) | | | | | | +--------------

memory management - emulating a variable size struct in C; allignment, performance issues -

it possible put arrays custom length anywhere in struct in c, in case additional malloc calls required. compilers allow having vlas anywhere in struct, not standard compliant. decided emulate vlas within struct standard c. i in situation have maximum performance. code in c automatically generated, readability or style not important in case. there structs many custom size array members in between static size members. below simple form of such structs. struct old_a { int n_refs; void **refs; int count; }; struct old_a *old_a_new(int n_refs, int count) { struct old_a *p_a = malloc(sizeof(struct old_a)); p_a->n_refs = n_refs; p_a->refs = malloc(n_refs * sizeof(void *)); p_a->count = count; return p_a; } #define old_a_delete(p_a) {\ free(p_a->refs);\ free(p_a);\ } while (0) the additional malloc call refs can avoided follows. #define a_get_n_refs(p_a) *(int *)p_a #define a_set_n_refs(p_a, rval) *(int *)p_a = rval #define

xforms - Use read-only xf:input as xf:output in Orbeon? -

Image
can use read-only xf:input act xf:output in orbeon? how set value of readonly input field? simpler code sample: <xf:input ref="//some/elements/totalcredit" value="round(($quantity) * ($creditperunit))"> </xf:input > <xf:output ref="//some/elements/totalcredit" value="round(($quantity) * ($creditperunit))"/> in above code xf:input shows initial value model! doesn't update! xf:output value updated expected! so, how can set xf:input 's value xf:output ? i don't want use calculation in bind. in example, have xf:input both ref , value ; not sure expect do, or if makes sense, sure won't work: with xf:output , can have both ref , value , node pointed ref can influence whether xf:output shown , value gives value. if want same xf:input , can put result of calculation in ref (in case round(($quantity) * ($creditperunit)) ). if expression returns atomic value, inp

javascript - jQuery: get clicked button values -

i need values of jquery button when form submitted. form , jquery i'm using below, it's not working. i need value of data-url . jquery code $("#addagency").submit(function(event) { var val = $("button[type=submit][clicked=true]").attr('data-url'); alert(val); }); html code <form id="addagency"> <button type="submit" data-url="test.php"> </form> thanks in advance. try $("#addagency").submit(function(event) { var val = $(this).find("button[type=submit]").data('url'); alert(val); });

php - Optimalization task -

i have problem optimalization function generate document tax free. i add order positions : name, price, weight , numbers (count). like: product = array(); product[0] = array('name'=>'product_a','price'=>32.00,'weight'=>5.23,'numbers'=>100); product[1] = array('name'=>'product_b','price'=>22.00,'weight'=>2.23,'numbers'=>140); product[2] = array('name'=>'product_c','price'=>12.10,'weight'=>3.03,'numbers'=>150); product[3] = array('name'=>'product_d','price'=>5.12,'weight'=>4.03,'numbers'=>10); product[4] = array('name'=>'product_e','price'=>52.22,'weight'=>5.13,'numbers'=>22); no positions have generate smallest document tax free. in 1 document can have sum weight max 50 , sum price 2000 (price 1 element. if have numbers

javascript - how to remove element from session storage array when there are lot of -

i trying remove elements localstorage array. find localstorage.removeitem(key); i couldn't understand how works because have 2 sessionstorage. okay? i have far var thecart = json.parse(sessionstorage.getitem("productname")); // retrieving var quantity = json.parse(sessionstorage.getitem("quantityofprod")); var prodprice = json.parse(sessionstorage.getitem("sum")); productname, quantityofprod , sum arrays. don't how form localstorage.removeitem select array , select element inside array. have tried sessionstorage.removeitem("productname", json.stringify(namee)); namee variable contains element want delete inside specific sessionstorage array. doing deleting everything. you have way: read entry decode json remove element encode json update entry tmp = json.parse(sessionstorage.getitem("productname")); delete tmp["key remove"]; sessionstorage.setitem("productname", json.stringif

javascript - Sorting issue with plain text and html in the same column using Handsontable -

i'm having problem sorting column contains plain text html anchor tag. sorting seems occurring on value stored in data source array rather displayed value. cells containing anchor tag sorted above plain text cells. below jsfiddle example. third column sort alphabetically names regardless of whether cell contains anchor tag or plain text. example: http://jsfiddle.net/5sl2jkqt/ { data: 2, renderer: "html" } i tried applying custom cell renderer on third column did not help. suggestions on how around appreciated! what did around add following function handsontable.full.js // strip out tags not in allowed parameter function striptags(input, allowed) { if (!input) { return ""; } else if (!isnan(input)) { return input; } // making sure allowed arg string containing tags in lowercase (<a><c>) allowed = (((allowed || "") + "").tolowercase().match(/<[a-z

Install R packages on remote linux server via RSclient on a windows machine -

we using r ubuntu server in cloud hosted aws run our models on. can connect server r studio on desktop rsclient: library(rsclient) c <- rsconnect(host="*confidential*", port = *confidential*) rseval(c, "require(rodbc)") [1] true but when try install additional packages in same way, fails , takes 5 minutes before msg: rseval(c, "install.packages('surv')") error in rseval(c, "install.packages('surv')") : remote evaluation failed since server set third party , not ask them time need additional package, install myself. have no experience linux hoping possible r on own machine. any appreciated! best regards, tim

vim - how to delete all lines that match a pattern asking permission in vi -

hello i'm new vi , have problem making vi ask me permission delete line pattern. file looks this: seqres 1 46 gly ser glu ala arg glu cys val asn cys gly ala thr seqres 2 46 ala thr pro leu trp arg arg asp arg thr gly tyr seqres 3 46 leu cys asn ala cys gly leu tyr lys met asn gly seqres 4 46 gln asn arg pro leu ile arg i want delete lines contain string 'gly' this came to: :g/gly/cd but it's wrong only :substitute command has c onfirm flag. however, if use regular expression matches entire line (including trailing newline), can use delete entire lines, confirmation: :%s/.*gly.*\n//c alternatively, build own confirmation :global ; here's simple 1 have answer either enter or esc : :g/gly/if confirm('delete: ' . getline('.')) | delete _ | endif

android - How to get values from the selected item in a list view? -

this code far. working shows first value have in listview , not selecting item user. please halp me this. important. unitlistview.setchoicemode(abslistview.choice_mode_single); unitlistview.setonitemclicklistener(new adapterview.onitemclicklistener() { public void onitemclick(adapterview<?> parent, view view, int position, long id) { // selected item textview t1 = (textview) findviewbyid(r.id.lbllunitname); string name=t1.gettext().tostring(); // string a= (string) unitlistview.getitematposition(position); // touchpressed=position; toast.maketext(getapplicationcontext(), "selected item :" +name, toast.length_short).show(); } }); update code follows , try ; unitlistview.setchoicemode(abslistview.choice_mode_single); unitlistview.setonitemclicklistener(ne

cocoa - How to force redrawing a group row in a NSOutlineView after it’s been expanded/collapsed -

i tried calling setneedsdysplay: , setneedsdisplayinrect: drawbackgroundinrect: , drawseparatorinrect: not called group row else this piece of code have: - (void)outlineview:(nsoutlineview *)outlineview didaddrowview:(nstablerowview *)rowview forrow:(nsinteger)row { id previtem = [outlineview itematrow:row - 1]; if ([self outlineview:outlineview isgroupitem:previtem]) { id view = [self outlineview:outlineview rowviewforitem:previtem]; if (view) { [view setneedsdisplay:yes]; } } } edit this came with: - (void)outlineview:(nsoutlineview *)outlineview didremoverowview:(nstablerowview *)rowview forrow:(nsinteger)row { // todo: find a better way repaint node after it's been collapsed (nsview *view in outlineview.subviews) { nsinteger testrow = [outlineview rowforview:view]; if (testrow == row - 1) { id item = [outlineview itematrow:testrow]; if ([(id)outlineview outlineview:

xcode - equal spacing between uiimageview using size class -

Image
i'm trying add 4 or (more in future) uiimageview in ipad application landscape mode. want equal spacing between each uiimageview. used wregular hregular format build application , used few constraints, when try run application in simulator i'm getting different result different ipad devices. how can achieve having equal spaces between uiimageview irrespective size of screen ? below screen shots. ipad2: ipad air : ipad retina : resizable ipad : auto layout system lets lay out app’s user interface creating mathematical description of relationships between elements. define these relationships in terms of constraints either on individual elements, or between sets of elements. using auto layout, can create dynamic , versatile interface responds appropriately changes in screen size, device orientation, , localization. try link learn size classes , auto layout. http://www.appcoda.com/introduction-auto-layout/

ruby - How do I make sure that gems get installed in the correct location? -

setup fresh ubuntu 14.04.2 lts install (in hyperv snapshot first reboot) sudo apt-get update official rvm install both single , multi-user rvm install [ruby] 2.1 , 2.2 separately (on fresh installs) gem_home: /home/me/.rvm/gems/ruby-2.2.1 (for 2.2 install) pre gem update gem location example: /home/me/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/bundler-1.8.4 post gem update gem location example: /home/me/.rvm/gems/ruby-2.2.1/gems/bundler-1.9.2 after first gem update --system , gem update attempt gem clean always ends errors updated gems' previous versions not installed in gem_home. everything else i've tested rvm/ruby setup functioning (single or multiuser installs).

javascript - VBScript set value at onload -

i have hta vbscript has element set variable, sn2: <script language="vbscript">document.getelementbyid("computername").value = sn2</script> set print out html textbox: <html><input class="inputs" type=text id="computername" name=computername /></html> and works well! however, wanted set value display in textbox on onload to this, set vbscript function <body onload="myfunction()"> . , works well, except there function need set body onload so wondering if there way set document.getelementbyid("computername").value = sn2 onload in different way. i know way in javascript, can set document.getelementbyid("computername").onload , doesn't seem working in vbscript. can done in vbscript, , if so, how? can't use javascript case. i'm referring this method (although don't need of iframe stuff have in example). reason js way doesn't translate in vbscript.

java - Appfuse spring security hasRole() not working -

i'm trying appfuse , have added custom menus in menu.jsp (no doing in menu-config.xml because add glyphicon, , struts menu can't it) so hide/show menus wanted use spring security authorized tag <security:authorize access="hasrole('role_admin')"> <li> <a href="test.jsp"><i class="fa fa-edit fa-fw"></i> forms</a> </li> </security:authorize> but tag causes yike! error(error 500), nothing showed in console. have <logger name="org.springframework.security" level="all"/> <logger name="org.springframework" level="all"/> in log4j2.xml. if switch <security:authorize ifanygranted="role_admin" > works expected. far know, ifanygranted deprecated. i'm curious why see no error in output console? i'm using appfuse 3.5 springmvc, run

python - Unexpected Indent Error at End of File -

Image
for reason @ end of of python file in idle i'm getting indentation error, though block of code has right amount of spacing. when try run , told error, highlights whole line after code, instead of highlighting character before line of wrongly indented code, does. here's screenshot demonstrating highlights: for reference, how looks when highlighting real indent problem: the code has problems form: if yes.lower() == 'y': linkfiles(folders) raw_input(iprint('= script finished, press enter quit.',true)) and form: if yes.lower() == 'y': linkfiles(folders) raw_input(iprint('= script finished, press enter quit.',true)) also yes, have confirmed i'm not mixing tabs , spaces. using spaces on these lines. i checked whitespace @ end of file, error occurs same when there's no characters whatsoever after closing bracket. , attempting run script add newline character, nothing else. as per suggestion, did try run through commandl

oracle - Database backup using PGP -

i using oracle 11 , postgre in local machine. want write program in pgp dump of data table .csv file. example, if have table name table1 . after running program csv file(after zip) generated timestamp. mytable.yyyymmddhhmiss.csv.gz i new pgp, there link or example can @ please?

Needing conformation box before delete in google sheets -

i needing conformation box appear before cells deleted. thank great help. in advance. here script function clearrange() { //replace 'sheet1' actual sheet name var sheet = spreadsheetapp.getactive().getsheetbyname('load assignment'); sheet.getrange('b7:g7').clearcontent(); } thanks script! here's documentation on how that: https://developers.google.com/apps-script/reference/base/button-set

javascript - Change order of data with jQuery two-way data binding -

i'm trying use 2 way data binding have score changes on fixtures move league position of team depending on result. i've given try not sure why it's not working. have no idea i'm doing. i've used tinysort try , order them when points attribute changes don't know how dynamically add points attribute , change order of league changing fixture result. can help? getremainingfixtures = function(){ $.ajax({ type: 'get', url: '/fixtures/later_fixtures', datatype: 'json' }).done(function(data){ data = _.groupby(data,'matchday'); $.each(data, function(index, day){ var matchdatediv = $('<div id="days">').css({ 'margin-left': '20px', 'max-width': '80%', 'display': 'block', 'text-overflow': 'ellipsis', 'white-space': 'nowrap', 'float': 'left&#

javascript - Does JQuery have a "move" function? Or is there a more compact way of doing this? -

when using jquery in conjunction content management system, find myself writing snippets of code such $(document).ready(function() { var thishtml = $('#some-element')[0].outerhtml; $('#some-element').remove(); $('#hmpg-btm-box-holder').prepend(thishtml); }); does jquery have functionality accomplish in more compact fashion? this should suffice: $(document).ready(function() { $('#hmpg-btm-box-holder').prepend($('#some-element')); }); i'd avoid using outerhtml whenever possible (and preferably innerhtml also, unless e.g. receive html trusted server via ajax , want include in document). converting element element string (html) representation , element can cause unwanted effects removing event handlers attached it.

r - Fastest way to map a new data frame column based on two other columns -

i have data frame looks this: id|value 01| 100 01| 101 01| 300 #edited case left out 02| 300 03| 100 03| 101 04| 100 and add new column looks @ both id , values assigned each id. for example: if id has both value 100 , 101 add category a. if id has value of 300 add category b. if id has 1 value (either 100 or 101, not both) assign category c. result: id|value|category 01| 100 | 01| 101 | 01| 300 | b #edited case left out 02| 300 | b 03| 100 | 03| 101 | 04| 100 | c i understand can loop through , assign category, question whether there faster vectorized way? a couple of options data.table we number of elements per 'id' '100', '101' , add them together. output 0, 1, or 2 corresponding none, single element, or both present. can converted factor , change labels 'a' '2', 'b' '0' , 'c' '1'. library(data.table) setdt(df2)[, indx:=sum(unique(value)==100)+sum(unique(value)==101),

c - Count number of processes created using fork in a for loop -

i trying find way count number of processes created in loop of length 10 fork() call. easy see result 2^n n calls, need way compute in program. i have found identical question in here . however, when tested second solution given here, works ok number of forks less 10. 10, yelds 256. why that? , there solution problem? (apart using pipes). here actual code: for(i=1; i<=10; i++) { fork(); printf("the process pid=%d\n", getpid()); } there 1 byte exit status of process. therefore, cannot count higher 255 via process exit codes. furthermore, quirk of specific algorithm tried happens produce maximum possible exit status (to parent process adds 1 256 ). exit() function uses least significant 8 bits of argument (and returning x main() has same effect calling exit(x) ). to count higher, need different approach. establish counter in shared memory, , have each child process increment (with appropriate synchronization). runs cleanly, shared memory n

scala - Gatling - convert json response to List of case classes -

gatling 2.0. i'receiving server following json of events: [ { "a":"a","b":"b","c":"c","d":"d"}, { "a":"a1","b":"b1","c":"c1","d":"d2" }, { "a":"a2","b":"b2","c":"c2","d":"d3" } ] now store in session list of event classes case class event(a:string:b:string,d:string) i'm trying following jsonpath("$.chats.chat[0].events.event").oftype[seq[any]].transform(_.map{ l => some(event(l(0).asinstanceof[string], l(1).asinstanceof[string],l(3).asinstanceof[string])).saveas("events") but line not compile: please help. after fetch list session, can by: val events = session("events").as[seq[events]] thanks. you're using transform , takes extract result , tr

php - Codeigniter decode not working -

i making little login system using php inside of codeigniter framework. using encryption class encode password, store in database. on login, finds encrypted password using username, matches against password entered. passwords getting encoded during registration. , in below code, have been able print out encoded password database, fails out whenever run through decode. no error message, nothing. public function check_pw(){ //post username , password database $data['username'] = $this->input->post('username'); $data['password'] = $this->input->post('password'); $this->load->model('lindsdata'); //encoded password returned database - working $return_data = $this->lindsdata->password($data); //$return_data = $this->encrypt->decode($return_data); //print_r shows $return_data hold encrypted password //but when uncomment line decode in it, $return_data print_rs nothing. print_

sql - Pivoting on dates to get roll ups of sums of nodes in a hierarchy -

imagine have table emps, containing parent-child relationship: manager employee ------- ---------- null johnson johnson ketler ketler braun ketler cooper and table contracts, containing history of employees bargains: date_of_contract employee amount_of_contract ---------------- ---------- ------------------ 25.03.2015 ketler 4 25.03.2015 braun 3 25.03.2015 cooper 2 25.03.2015 johnson 9 26.03.2015 ketler 1 26.03.2015 braun 4 26.03.2015 cooper 3 26.03.2015 johnson 6 27.03.2015 ketler 6 27.03.2015 braun 2 27.03.2015 cooper 5 27.03.2015 johnson 7 we proceed query see hierarchical sum of contracts

java - Randomly generating an array of unique chars. Know of better ways to do it now, but wondering why my original method doesn't work -

i supposed generating randomly ordered alphabet. know of shuffle methods , things fisher-yates shuffle algorithm, tried never work. had "reference" array of alphabet in regular order. have loop each 26 spaces. generate random int between 0 , 25(for index in reference array). then, check if array has char in it(it must unique) if unique, add array. still has duplicates though. here's code: public static final char[] alphabet = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', ' '}; public static char[] ciphergenerator(){ char[] cipheralpha = new char[26]; for(int index = 0; index < 26; index++){

Chrome store shareable developer site (like Google's Play) -

when paying developer in google play, public shareable site, like: https://play.google.com/store/apps/developer?id=.... but when paying developer in chromestore, does happend? can't find shareable link... something see here: https://chrome.google.com/webstore/developer/dashboard ...but, shareable (that's not) after while i've found if developer username kind of unique (in case: "germanger"), can share link: https://chrome.google.com/webstore/search/germanger?_category=extensions which search. if there similar username, like: germanger123, wouldn't work (it show both user developed extensions)

node.js - Karma Unit Testing -

i'm having trouble trying figure out reason error when trying start karma: bash-3.2$ node_env=test karma start info [karma]: karma v0.12.31 server started @ http://localhost:9876/ info [launcher]: starting browser phantomjs info [phantomjs 1.9.8 (mac os x)]: connected on socket fontq1onxixrecrxygns id 73511945 phantomjs 1.9.8 (mac os x) error referenceerror: can't find variable: require @ /public/components/angular-cookies/index.js:1 the index.js file contains: require('./angular-cookies'); module.exports = 'ngcookies'; please help!! one way fix npm install karma-browserify --save-dev . should work , have if actual file need uses require . index.js not actual file need. angular-cookies.js is. i find using browserify makes debugging test errors more difficult because stack trace karma refer line numbers temporary .browserify bundles got deleted time test done. a simple solution point files in karma.conf.js directly angular-cookies.j

cursor - Android detect sms belongs to sender or receiver -

i want detect sms list, of messages mine , witch of them belongs other contacts. for example: me: "body": hi john john "body: hi there... uri urismsuri = uri.parse("content://sms/"); cursor cur = getactivity().getcontentresolver().query(urismsuri, null, null, null, null); while (cur.movetonext()) { //detect here } you can use telephony.textbasedsmscolumns.creator field creator. compare address (mobile number) distinguish other people. can number following: (telephonymanager)getsystemservice(telephony_service).getline1number();

c# - Accessing and Updating Cached Dictionary -

i have dictionary (concurrent) used map 1 object id another. getting value id based on input key rather expensive, want persist dictionary in server cache. i have first-blush attempt @ method this, "feels" there better way it: private string getitem(string cachekey, string itemkey) { string sfaccountid = null; concurrentdictionary<string, string> sfaccountmap = context.cache[cachekey] concurrentdictionary<string, string>; if(sfaccountmap == null) { lock(cachelock) { sfaccountmap = context.cache[cachekey] concurrentdictionary<string, string>; if(sfaccountmap == null) { sfaccountmap = new concurrentdictionary<string, string>(); sfaccountid = expensivemethodreturnsstring(); if(!string.isnullorempty(sfaccountid)) { sfaccountmap.tryadd(itemkey, sfaccountid); }

How to access and modify the contents of one object created by one script from another script in python? -

i have 3 scripts written in python. an initialization script a script contains custom data structure class a monitoring script. the initialization script starts first. creates object of custom data structure , starts monitoring script. monitoring script @ points send values fill object created in initialization script. so, there global data object created initialization script. monitoring script add data object. data object buffer contains tasks executed later. how accomplish task of adding data data object monitor script? example scripts: initialization script: import monitorscript import customdatastructure # creates object customdatastructure # starts monitor script custom data structure: class mydata(object): def __init__(self, arg1 = none, arg2 = none): self.arg1 = arg1 self.arg2 = arg2 class mydata2(mydata): def __init__(self): self.queue = [] self.length = 0 def addtask(self, data): # adds task exe

active directory - Use Python script to manage remote LDAP server -

background: working on api centralize user creation , management multiple resources(e.g. google apps, dropbox, etc...). on linux vm, developed api , web interface allows me(and co-admins) authenticate , manage user accounts these services. next thing need integrate our active directory hosted on remote windows server 2008. i have been trying use python-ldap connect , retrieve/modify information have had issues dir_error operations errors(when trying query users) , naming_violation errors(when trying add users). *code based on http://www.grotan.com/ldap/python-ldap-samples.html , stackoverflow questions, , python-ldap documentation binding code believe works: import ldap try: l = ldap.open("serverip") l.protocol_version = ldap.version3 username = "myusername@adtest.local" password = "secret" result = l.simple_bind(username, password) print result except ldap.ldaperror, e: print e which prints: (97, [], 1, [])