Posts

Showing posts from March, 2012

extjs - Ext Form Model load two fields with same data -

i have ext model form. need load single data value password field both password , confirm password field. possible load records in ext? yes possible. when record loaded in form, data obtained calling getdata() on record. therefore, can tweak model provide copy of password in field this: ext.define('user', { extend: 'ext.data.model', fields: [ 'id', 'name', 'password' ], getdata: function() { var data = this.callparent(arguments); data['confirm_password'] = data['password']; return data; } }); full example: https://fiddle.sencha.com/#fiddle/pgr alternative approach if not want change model, password field mirror value confirm password field whenever value set through setvalue : var form = ext.create('ext.form.panel', { defaulttype: 'textfield', items: [ { fieldlabel: 'name', na...

mysql - How to store each record or row in descending order into database in rails? -

i want store record or row in descending order of scores of match database in ruby on rails. can top 3 topper rank of current user. don't know how this. the problem simple: don't need specify order when insert data in database. database engine capable of sorting data according instructions when perform select. simply create rails model store score , reference of subject associated score (e.g. user_id). then, solution selecting records ordering score. assuming model called result result.order("score desc").limit(3) just small note. simple problem, long have necessary basic knowledge of ruby, rails , database interaction. this answer helpful if do. if don't, you'll need start simpler problems learn these topics first.

javascript - How to append json array to value attribute -

Image
there search box in view. when search product on here retrieve(single) product using ajax my ajax code is <script> $(function() { $("#update_prod").click(function(event) { event.preventdefault(); var head = $("#update_product").val(); $.ajax({ datatype: 'json', type: "post", url: "<?php echo base_url(); ?>index.php/admin/update_product", data: { product: head }, success: function(data) { } }); }); }); </script> so in controller public function update_product() { $product = $_post['product']; $query = $this - > db - > query("select * product title '%$product%' , online=1"); $result = $query - > result_array(); echo json_encode($result); } and im reviving data in console [{ "id": "99", "brand_id": "8", "category_id": "1", ...

java - covert text file to multiple pdf files based on a string -

i have big text file, have 20,000 student's transcript data.i need create 1 pdf each student’s transcript (means 20,000 pdf) in text file. how can achieve this. appreciate ideas. thanks. this new requirement, havn't start anything. checking possible ways achieve this. sample input text file have data below. * student-name : test1;student # : 123456 subject : english marks : 100 subject : maths marks : 90 * student-name : test2;student # : 345678 subject : english marks : 100 subject : maths marks : 90 * student-name : test3;student # : 567859 subject : english marks : 100 subject : maths marks : 90 * student-name : test4;student # : 657656 subject : english marks : 100 subject : maths marks : 90 for above text file, requirement create seperate pdf each student transcirpt test1.pdf,test2.pdf,test3.pdf,test4.pdf

ember.js - Sync the states of multiple instances of same Ember Component -

here's situation: i wrote component facility-search searches through fixture data. put multiple instances of {{facility-search}} on same template (tab pages). component has input boxes can write search keywords. want observe change in value of input box , update same instance of component both of them in sync. this i'm doing in components/facility-search.js import ember 'ember'; import em 'ember'; var facilitysearchcomponent = ember.component.extend({ // tag name appears in html tagname: 'div', // randomnumber searchboxid: null, // facilities allfacilities: null, // search values textfacility: "", textcountry: "", textspecies: "", // text input ids needed <label for="id"/> // elements in multuple components should not have same id textfacilityid: 'text-facility', textcountryid: 'text-country', textspeciesid: 'text-species', // initiali...

api - How can I predict which Facebook friends chat with each other based off online status and Facebook's "last time active" feature -

if @ facebook's chat ( http://i.imgur.com/hxhjehc.png ) can see says last time specified user active. so if 2 friends both last active 2 minutes ago , both go online , become inactive again, there high likelihood chatting. i want know if has idea best way go accessing data be. don't think it's available through facebook api unsure. furthermore, perform sort of probabilistic statistical analysis on data see how confident algorithm guess of whether or not 2 friends chatting. i know question broad ideas on either acquiring data or design , analysis of data appreciated. this not available via graph api, don't see chance here implement planning.

networking - How Global Unicast Addresses work for IPv6 on android devices -

i developing android app , need find global unicast addresses android device without make network requests. (that should easy if can make network request since can therefore see outfacing public ipv6 in header). want see how find unicast address before make network request. i have used apis retrieve possible ipv6 interfaces. focus on ips falling 2000::/3 range. however, got 1 ipv6 ( right answer), got two/multiple address in 2000::/3 range. assume scenario might cause network status changes, not sure. for example: api returns me following 2 ipv6s 2600:1010:b022:1349:d25c:f9bf:2881:d30c%3%3 , 2600:1010:8043"3aba:67ca:ac76:4a8f:dbdb%9%9 can tell me how global unicast ipv6 works on android devices? how can ensure getting real ipv6 , not temporary one? with privacy extensions, temporary address rest of world use. periodically changes try prevent associating address you. how privacy extension implemented os dependent, but, generally, temporary address while, ...

symfony - How to check app.request.attributes.get('_route')==blog/slug variables -

for eg if url is http://localhost/project/blog can check current url routes {% if app.request.attributes.get('_route') == 'blog' %} </p>this default page</p> {%endif%} but below url: http://localhost/project/blog/2 not working {% if app.request.attributes.get('_route') == 'blog/2' %} </p>this blog page 2</p> {%endif%} try app.request.requesturi : should return "project/blog/2" {% if 'blog/2' in app.request.uri %} </p>this blog page 2</p> {% endif %}

class - How do I affect all the classes on javascript? -

here sample code html , css body{ font-family: verdana, geneva, sans-serif; } .box{ width: 140px; height: 140px; background-color: red; display: none; position:relative; margin-left: auto; margin-right: auto; } .bold{ font-weight: bold; } .table{ border: 2px solid black; height: 150px; width: 150px; } </style> <p class="bold">your time: <span id="time">0.000</span>s</p> <table id="table"> <tbody> <tr> <td class="table"><div class="box"></div></td> <td class="table"><div class="box"></div></td> <td class="table"><div class="box"></div></td> </tr> <tr> <td class="table"><div class="box"></div></td> <td class="table"><div ...

android - Add a shadow over the bottom of the ImageView in CordinatorLayout -

recently implementing material design existing application. using following library : http://android-developers.blogspot.com/2015/05/android-design-support-library.html achieve following effect : https://plus.google.com/+androiddevelopers/posts/xudgfs9eyxg . my layout code below: <android.support.design.widget.coordinatorlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="true"> <android.support.design.widget.appbarlayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="350dp" android:fitssystemwindows="true" android:theme="@style/themeoverlay.appcompat.dark.actionbar"> <android.support.design.widg...

opengl - QT for OpenglEs on Desktop -

i have existing project uses opengles library (libglesv2.lib) on desktop platform. now want use qt user interface using qglwidget. after calling opengl function in qglwidget::initializegl function access violation executing location 0x00000000 error @ code below, void myglwidget::initializegl() { if (!context()->create()) throw std::exception("no context :)"); context()->makecurrent(); glviewport(0, 0, 640, 480); } if include library opengl32.lib glviewport function works when hit glgenframebuffers same error. could please let me know how can configure project use qt opengles on desktop platform. if include library opengl32.lib glviewport function works when hit glgenframebuffers same error. glviewport opengl function found in every opengl version , profile since version 1. such it's available linking against basic opengl interface library. glgenframebuffers function introduced opengl-...

javascript - How to append json values to html[value] -

i have json this. how append json values html input values. [{"user_id":"180", "firstname":"anandhsp", "lastname":"sp", "email":"xyz@gmail.com", "mobile":"9000000000", "gender":null, "hashcode":"2xxg3dfyuxjo9c4ovaww", "username":"anandhsp21", "password":"64c20f8bb630eb5cb329fdd609c807b7:j6", "emailverify":"true", "company_name":"xxx", "address":"chennai", "city":"chennai", "state":"tamilnadu", "pincode":"637001", "phone":"1234567890", "website":"hello", "nature":"hello", "no_employe":"23", "year":"2015", "type...

android - what is the correct way to concat strings in c++ and execute using system -

the following code used in native c++ library create directory under android shell, jniexport void jnicall java_com_xprea_lib_stb_mkdir(jnienv* env, jobject javathis, jstring jdir) { const char* dir = (env)->getstringutfchars(jdir, 0); string d=dir; string cmd= "su -c 'mkdir -p "+d+"'"; const char* c=cmd.c_str(); loge("s%s",c); system(c); } it's not working because command built concatenated strings. tested without concatenation , it's working what correct way concat strings , send them system() your concatenation "su -c 'mkdir -p "+d+"'" results in string su -c 'mkdir -p bla' (if dir name bla) so command su searches command named mkdir -p bla won't find. better make: "su -c mkdir -p '"+d+"'" concatenation. way search command named mkdir find, , directory name may contain white space (although have escape ' , \ character \ . ...

c# - The Appium desired capabilties code in the constructor of the class gives object null reference error -

i created 2 different projects. in project 1 have class have constructor following code setup appium server desiredcapabilities capabilities = new desiredcapabilities(); capabilities.setcapability("device", "android"); capabilities.setcapability(capabilitytype.platform, "windows"); capabilities.setcapability("devicename", "soti india (sm-p600)"); capabilities.setcapability("platformname", "android"); capabilities.setcapability("platformversion", "4.4"); capabilities.setcapability("apppackage", "net.soti.hub"); // app package capabilities.setcapability("appactivity","net.soti.securecontentlibrary.activities.splashactivity"); driver = new androiddriver(new uri("http://127.0.0.1:4723/wd/hub"), capabilities); driver.context = "native_app"; now class in project calling constructor write testmethods getting "object null referen...

reactjs - React components rendering with variable names -

i have unknown list of react components render. // react component var defaultmodule = require('./defaultmodule.js'); <defaultmodule/> <--- output because name class name inside defaultmodule.js but if // react component var sssss = require('./defaultmodule.js'); <sssss/> <--- not work so there way can take list of component names , render them accordingly? thanks. p.s: react component looks this import react, {proptypes, component} 'react'; class testcomponent extends component { render() { return ( <div> 1123123123123123 hahaha small test </div> ); } } export default testcomponent; i figured out answer discussion thread... yes can react component must start in capital letter. sssss work sssss now. https://github.com/facebook/react/issues/3365 the key use capitalized variable name (component) otherwise react treat built-in dom element.

c++ - SSL verses Encrypted Socket -

i building open source client/server app, not sure use, ssl (e.g. openssl) or encrypted packets on plain sockets. i guess have few questions: is there security implications using encrypted packets on plain sockets? is there 'suggested' setups? know fact openssl has 1/2 million lines of code , had lot of security issues. is there features (open)ssl give me a) beneficial or b) detrimental. hopefully question has structured in such way pass moderators :) is there security implications using encrypted packets on plain sockets? not if done correctly. btw, ssl/tls encrypted packets on plain sockets. is there 'suggested' setups? know fact openssl has 1/2 million lines of code , had lot of security issues. the suggested setup use code , algorithms known good. in no case should invent own, if don't know topic. is there features (open)ssl give me a) beneficial or b) detrimental. the ssl/tls standard gives need. implementations ha...

mysql - Excude value from sql results -

here problem.i have table recursive association this:(#id_boss,#id_manager) references id_employee. i have function $id argument .in function have sql query should return id_boss or id_manager depending on $id. this query: select group_concat (id_guy, id_friend) table id_guy=$id || id_friend=$id; my query works returns $id value (because id_guy $id_friend $id_guy) exclude. example: $id_guy=10, id_friend=11 $id_guy=14, id_friend=10 i have result: 11,14 , not: 10,11,14,10 how that? thanks group_concat() ignores null values, can use case in select : select group_concat((case when id_guy <> $id id_guy end), (case when id_friend <> $id id_friend end) ) table $id in (id_guy, id_friend); edit: the above might require else : select group_concat((case when id_guy <> $id id_guy else '' end), (case when id_friend <> $id id_friend else '' end) ...

c# - Linq performance parsing XML file -

i need parse xml file (1~10 mb); using xdocument purpose. at moment using linq query xml document, need improve performance of application , thought replace linq query old style loops , did not have boost. following piece of code called query: stopwatch stopwatch = new stopwatch(); xdocument xdoc = xdocument.load("filename.xml"); string def = "version"; xelement xelm; stopwatch.start(); (int = 0; < 1000; i++) xelm = xdoc.descendants("def").where(d => d.attribute("name").value == def).single(); stopwatch.stop(); console.writeline(stopwatch.elapsedmilliseconds); stopwatch.restart(); (int = 0; < 1000; i++) { foreach (var elm in xdoc.descendants("def")) { if (elm.attribute("name").value == def) { xelm = elm; break; } } } stopwatch.stop(); console.writeline(stopwatch.elapsedmilliseconds); the elapsed time pretty same both versions, , me ...

c++ - What happens when you define an empty default constructor? -

i have searched previous questions, , have not found satisfying answer question: if define empty default constructor class, example class my_class{ public: myclass(){} private: int a; int* b; std::vector<int> c; } my understanding if define object using default constructor, say my_class my_object; then my_object.a random value, pointer my_object.b random value, vector c well-behaved, empty vector. in other words, default constructor of c called while default constructors of , b not. understanding correctly? reason this? thank you! a , b have non-class types, meaning have no constructors @ all. otherwise, description correct: my_object.a , my_object.b have indeterminate values, while my_object.c constructed. as why... writing user-defined constructor , not mentioning a , b in initializer list (and not using c++11 in-class member initializers) explicitly asked compiler leave these members uninitialized. note if class did not hav...

sql server - Extrememly High Estimated Number of Rows in Execution Plan -

Image
i have stored procedure running 10 times slower in production in staging. took @ @ execution plan , first thing noticed cost on table insert (into table variable @temp) 100% in production , 2% in staging. the estimated number of rows in production showed 200 million row! in staging 33. although production db running on sql server 2008 r2 while staging sql server 2012 don't think difference cause such problem. what cause of such huge difference? updated added execution plan. can see, large number of estimated rows shows in nested loops (inner join) clustered index seek table. updated2 link plan xml included plan.xml and sql sentry plan explorer view (with estimated counts shown) this looks bug me. there estimated 90,991.1 rows going nested loops. the table cardinality of table being seeked on 24,826 . if there no statistics column , equality operator used, means sql can’t know density of column, uses 10 percent fixed value. 90,991.1 * 24,826...

php - Use multiple Database Tables in single model in Lumen Framework -

i have these database tables: country_us country_fr country_en country_nl country_es how can create single model above tables? database structure of these tables same. what can workaround scenario in lumen framework? i don't know reason having such bad database design. ideal have 1 table 'language' column. anyway, 1 dirty way overwrite gettable() method: /** * table associated model. * * @return string */ public function gettable() { if ($conditionus) return 'country_us'; if ($conditionfr) return 'country_fr'; // etc ... } the gettable() method method laravel intenally uses determine table should use model. if override it, take control of table used.

c# - ExpandoObject quirky behavior while adding items dynamically -

so i'm using expandoobject add properties dynamically populated string. going use these bind datagrid later. given below 2 variations of code, doing same thing (to me atleast) 1 fails , 1 doesn't. can me understand why is? failed code dynamic dynamo = new expandoobject() idictionary<string,object>; string words[] = basestring.split('|'); foreach(string word in words) { dynamo[word] = word.toupperinvariant(); } successful code dynamic dynamo = new expandoobject(); var dynamoose = dynamo as idictionary<string,object>; //notice cast string words[] = basestring.split('|'); foreach(string word in words) { dynamoose[word] = word.toupperinvariant(); } ` your code doesn't run directly. couldn't double cast work. , string words[] didn't compile, changed string[] words. from there on failing code gave me valuable info: additional information: cannot apply indexing [] expression of typ...

ggplot2 - Layering density plots in R without using density() -

i've computed , plotted gaussian kernel density estimates using kernsmooth package follows: x <- mydata$mynumericvector h <- dpik(x) est <- bkde(x, bandwidth=h) plot(est, type='l') this method described in kernsmooth's documentation. note dpik() finds optimal bandwidth , bkde() uses bandwidth fit kernel density estimate. it's important use method instead of basic density() function. how layer these plots on top of 1 another? i cannot use basic density() function geom_density() ggplot2 relies upon, bandwidths , kernel density estimates best optimized using kernsmooth package (see deng & wickham, 2011 here: http://vita.had.co.nz/papers/density-estimation.pdf ). since wickham wrote ggplot2 , above review of kernel density estimation packages, make sense there's way use ggplot2 layer densities aren't reliant on basic density() function, i'm not sure. can use ggplot2 if don't wish use basic density() function? l...

Leaflet map with WMS and custom projection -

i have implemented map using leaflet , tiles wms-service. offer list of projections, of 1 usable in standard leaflet epsg:4326. however, map looks bit distorted, , recon 1 of other projections better. supplier of maps uses epsg:32624, cannot seem projection right. this complete list: epsg:32624, epsg:32619, epsg:32620, epsg:32621, epsg:32622, epsg:32623, epsg:32624, epsg:32625, epsg:32626, epsg:32627, epsg:4326, epsg:3413, epsg:3575 i have fiddle here: http://jsfiddle.net/uyrv2j7f/2/ there 2 maps, top 1 using desired projection, not working. bottom 1 using working, distorted projection. i'm quite sure, need edit configuration of crs. what? find info? i have found first part here: http://spatialreference.org/ref/epsg/wgs-84-utm-zone-24n/ - rest have nicked examples using other projections. var crs = new l.proj.crs('epsg:32624', '+proj=utm +zone=24 +ellps=wgs84 +datum=wgs84 +units=m +no_defs', { resolutions: [ 2116.670900008467, ...

Giving Excel worksheet a Form like look with only fixed number of rows and columns enabled -

is there way activate smaller section of excel sheet , deactivate rest of sheet, meaning a4 size visible , rest part grey , nothing happens when click grey part. (eg: sheet consists of 20 rows , 7 colums). i want basically, make sheet appear form, user can edit or use parts , not entire sheet. i have sheen before such type of sheets in presentation, don't know how done. can me this.? you can find answer doesn't use vba @ microsoft's support pages: https://support.microsoft.com/en-us/kb/214081

voip - Two pjsua application at the same time on Android -

i have 2 application, uses pjsua. can not run both @ same time on single android device. after running second application crashes exception: java.lang.exception: title: pjsua_transport_create(type, &tcfg, &tid) 06-26 14:49:56.355 code: 120098 06-26 14:49:56.355 description: address in use 06-26 14:49:56.355 location: ../src/pjsua2/endpoint.cpp:1519 06-26 14:49:56.355 14:49:56.361 pjsua_core.c pjsua state changed: init --> starting 06-26 14:49:56.355 14:49:56.362 sip_endpoint.c .module "mod-unsolicited-mwi" registered 06-26 14:49:56.360 28512-28512/com.lemondo.biz.intelphone i/system.out﹕ 14:49:56.363 pjsua_core.c .pjsua state changed: starting --> running 06-26 14:49:56.365 a/libc﹕ ../src/pjsua-lib/pjsua_acc.c:404: pjsua_acc_add: assertion "pjsua_var.tpdata[0].data.ptr != ((void *)0)" failed do know how can solve problem? set unique local ports (might described bind ports in configur...

c# - Identifying the logged in user from different browser tab in asp.net -

i have website login option in asp.net. if open website in 2 browser tabs , logged in same user account , navigated homescreen in both tabs , logged out 1 tab , again logged in same tab,after clicked on second tab, how can discriminate sending request first tab or second tab code behind? if request second tab need navigate application login screen.how can this? in home page had added logic like if (session["userid"] == null) { response.redirect("login.aspx"); } but problem when logout first tab , login in again there, , after second tab refreshed session["userid"] not null stay there.but need redirect login page .how can achieve this?? may suggest use javascript , ajax post redirection. use myself, , find reliable, satisfying need. still think there may far better ways this. job. below code checks tab focus/focus lost, , calls csharp code on blur , focus. <script type="text/javascript"> //divcl...

python - Linker error with libboost_python-py34 on Ubuntu 15.04 -

i must making simple mistake trying use boost-python on ubuntu linux 15.04 (vivid vervet), libboost-python1.55-dev package installed. i'm trying build simple test file so: $ g++ -o conftest -wall -i/usr/include/python3.4m -i/usr/include/x86_64-linux-gnu/python3.4m -l/usr/lib/x86_64-linux-gnu -lboost_python-py34 -lpython3.4m conftest.cc but gives me linker error: /tmp/ccxkw5xr.o: in function `pyinit_test': conftest.cc:(.text+0x7e): undefined reference `boost::python::detail::init_module(pymoduledef&, void (*)())' collect2: error: ld returned 1 exit status but symbol seem exist: $ nm -d --demangle /usr/lib/x86_64-linux-gnu/libboost_python-py34.so | grep "init_module" 0000000000033ac0 t boost::python::detail::init_module(pymoduledef&, void (*)()) this simple test code i'm building, based on config test used ax_boost_python autoconf macro: #include <boost/python/module.hpp> boost_python_module(test) { throw "boost::python ...

amazon s3 - Can I route my mailgun email to S3 bucket and save data there? -

i have requirement need fetch email data , save somewhere. can route server , save data there. there feature email data can routed s3 bucket , save data there? as can see, need backend app recursively fetch emails using mailgun api formatted json, can save these text files on s3 service can queried later backend application. it requires programming , server infrastructure. regards,

jquery - Div alignment inside a <th> -

hello have problem div alignment inside . i'am made small fiddle show problem. https://jsfiddle.net/jpq7xzoz/ i use jquery tablesort-plugin , display second div buttons in header. e.g. search icon show/hide filter. <th class="header" style="text-align: center"> <div class="header-inner">patchlevel</div> <div class="header-inner-filter"> <button class="filterbutton"></button> </div> </th> but when columns have different size, table use autosize cols , div button wrap new line. head-description should @ same line button , background-image. when take button in same div description @ same line can't set button @ right column. i try use different display-styles , withe-space property no success. what do? thx felix hei! try use negative margin. example: .header-inner {margin-right:50px;} .header-inner-filter {margin-left:-40px;} a...

Launching applications using python -

i wanted launch application canalyzer.exe using python, without using path of application. trying launch application using com interface. got code open excel files win32com.client.dispatch("excel.application") worked doesnt work if mention other application name. please me code. use subprocess.call or os.system .

java - Android Google Play notification does not bring user to game screen -

similar questions have been trivial @ best answers. using faily up-to-date google play game services apk 'com.google.android.gms:play-services:7.0.0' , have oninvitationreceived() , onconnected() implemented. however, oninvitationreceived() doesn't seem called when invitee accepts game invite in-game. , while i'm onconnected() called no matter when player connects via callback after mgoogleclient.connect() , seems invitation dropped or because player not redirected game screen specified if bundle contains invitation (i'm assuming called when app closed either way, status bar notification shown invite). any insight appreciated. here relevant methods: onconnected() class, extends androidgame, , androidgame extends activity (i've tried in both classes, have overridden in child class of androidgame): @override public void onconnected(bundle connectionhint) { // connected google play services! // stuff goes here. games.invitations.regis...

java - JSONObject inside JSONArray -

i'm trying put jsonobject inside jsonarray in java. here 2 objects: jsonarray: [{ "url": null, "flag": "0", "read": "0", "time": 2000, "exp": null, "population": 10 }] jsonobject: { "events": [ { "color": "green", "event": "restart" }, { "color": "black", "event": "shutdown" }, { "color": "white", "event": "read" } ] } expected result: [ { "url": null, "flag": "0", "read": "0", "time": 2000, "exp": null, "population": 10, "events": [ { "color": "green", "event": "restart" ...

javascript - When using bootstrap Radio without preselecting an option, the first option result checked even if nothing is -

i'm trying use bootstrap radio using following markup , js <div class="form-control type"> <div class="radio-header">please select type of gallery item want create</div> <div class="btn-group" data-toggle="buttons"> <label class="btn btn-primary"> <input type="radio" div_class="form-inline" class="visibility_switcher" id="type_image_0" value="image" name="dgt_gallery_item[0][type]" />image</label> <label class="btn btn-primary"> <input type="radio" div_class="form-inline" class="visibility_switcher" id="type_quote_0" value="quote" name="dgt_gallery_item[0][type]" />quote</label> <label class="btn btn-primary"> <input type="radio" div_class=...

How can I generate the same random number in JavaScript and Python? -

in python, if use code: import random random.seed(123) print(random.random()) the first random number 0.052363598850944326 , since i'm giving same seed every time run program. javascript doesn't have built-in way use seeds. i've tried out javascript script called mersenne-twister.js , since that's type of prng python uses. if use same seed, different result in python. var m = new mersennetwister(123); m.genrand_int32(); that code return 0.6964691872708499 first time it's run. how can use given seed same random number in both python , javascript? this library/plugin worked me when compared python output javascript output. https://github.com/davidbau/seedrandom

java - Is it ok to use increment operators with any primitive type? -

we know int++ increase variable value 1, say: int number = 0; int temp = number + 1; number = temp; this allowed other primitive types too: double number = 0d; number++; so, wondering if code above executed as: double number = 0d; double temp = number + 1d; number = temp; or: double number = 0d; int temp = number + 1; number = temp; in second case, should prefer double += 1d instead? the ++ (prefix or postfix) not works on int , if use other primitive types, not mean there intermediate conversion int , back. see java language specification: 15.15.1. prefix increment operator ++ 15.14.2. postfix increment operator ++ as jls says, binary numeric promotion applied variable , value 1 . in case of number++ number double , means 1 treated double . so, number++ works same number += 1d if number double . not necessary number += 1d explicitly. note: if there intermediate conversion int , back, suggest in question, expect that: double num...

sql - Get row for each user where the count of a value in a column is maximum ++ -

this question update this question . my column structure: column0 column1 column2 aaa abc aaa abc aaa abc b aaa abc aaa abc b aaa abc na aaa xyx b aaa na b bbb fgh v bbb fgh na bbb fgh na bbb na m bbb na m bbb na m bbb na na bbb na na ccc na na ccc na na ccc na na what wished earlier foreach distinct 'column0' data 'column1' data count max unless data na in case second highest. if 'column0' data values of 'column1' na value can na. the same rule applies here well. 'column2', wish apply same rule on expected answer of 'column1' so though 'column0' value 'aaa' number of 'column2' values b more, wish answer 'column2' a. because query result in 'column1...

sql - Translate nested join and groupby query to Slick 3.0 -

i'm implementing todo list. user can have multiple lists , list can have multiple users. want able retrieve lists user, each of these lists contain list of users it's shared (including owner). not succeeding implementing query. the table definitions: case class dblist(id: int, uuid: string, name: string) class lists(tag: tag) extends table[dblist](tag, "list") { def id = column[int]("id", o.primarykey, o.autoinc) // primary key column def uuid = column[string]("uuid") def name = column[string]("name") // every table needs * projection same type table's type parameter def * = (id, uuid, name) <> (dblist.tupled, dblist.unapply) } val lists = tablequery[lists] case class dbuser(id: int, uuid: string, email: string, password: string, firstname: string, lastname: string) // shared user projection, data of other users user shared item can see case class dbshareduser(id: int, uuid: string, email: string, firstname: s...

How to get the file URL uploaded in google drive SDK using php -

i using google drive sdk upload files php. want link string can store in database. don't have idea on how it.. code in creating file in google drive using php. $file = new google_drivefile(); $file->settitle( 'new_pdf' ); $file->setmimetype( 'application/pdf' ); $createdfile = $service->files->insert( $file, array( 'data' => $stringcontent, )); you want 1 of properties of $createdfile. the list of properties @ https://developers.google.com/drive/v2/reference/files you want webcontentlink , depends on how intend use url.

javascript - computerChoice is not a function error -

so having problems making rock, paper , scissors game. keep getting error "typeerror: computerchoice not function" can see why happening, don't know how fix it. heres code; var userchoice = prompt("do chose rock, paper or scissors?"); var computerchoice = math.random(); console.log(computerchoice) if (computerchoice < 0.33) { computerchoice("rock"); } else if (computerchoice < 0.66) { computerchoice("paper"); } else (computerchoice < 1) { computerchoice("scissors"); } ive been told since var isn't function problem, how fix it. tried var computerchoice = function (math.random()); still didn't work. thanks whoever can me! :) you have assign value variable. here's code. http://jsfiddle.net/neoares/vespwott/ var userchoice = prompt("do chose rock, paper or scissors?"); var rnd = math.random(); var computerchoice; if (rnd < 0.33) { computerchoice = ...

button - How do I make an activity wait until Facebook login is complete? -

i trying make application android platform. far have 2 activities. both have fragments. first activity @ moment using facebook api users can sign in. want first activity switch second activity once login complete. tried using onclicklistener intent, second activity start before login completed. have sense reverted code point there no onclicklistener or intent. appreciated. did try reading documentation intents , activities, couldn't figure out how wanted. post code bellow. public class mainactivity extends actionbaractivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.menu_main, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { // handle action bar item clicks here. action ba...

javascript - Global variables in Angular, stored with angularLocalStorage -

i want make 1 place can store variables must saved in localstorage/cookie (i using angularlocalstorage plugin). best way that? thanks in advance. you should create service. have few advantages : easily mockable if want unit test it's allways idea create modular components, its's easier maintain , readability. ;)

Specific class with anchor css -

i trying override style on following html: <a class="ui-state-default" href="#">7</a> the issue ui-state-default class used in many other places cannot update it. have tried following no effect. .ui-state-default { width:27px !important; } .ui-state-default: { width:27px !important; } a.ui-state-default { width:27px !important; } how can target 1 anchor tag style change? well not idea put inline css if don't have onther way try inline css this: <div class="ui-state-default" style="width:24px !important;">your stuff</div> the main part style="width:27px !important;" put in html markup. may works .ui-state-default * { width:27px !important;}

php - DataTables columnFilter number-range filtering -

i have database in column "birth_date" there date (for example 2015-06-26 ). use datatables display information users. want make number range search. when using datatables plugin columnfilter , try use number-range type filter doesn't works. as enter value from or to field tells me there no results. if in same column there row date written 20150626 filter shows it. understand problem in symbol - in middle of number. how make filter ignore - sign? number-range filter code: function fncreatecharrangeinput() { th.html(_fnrangelabelpart(0)); var sfromid = stableid + 'range_from_' + i; var = $('<input type="text" class="number_range_filter" id="' + sfromid + '" rel="' + + '"/>'); th.append(from); th.append(_fnrangelabelpart(1)); var stoid = stableid + 'range_to_' + i; var = $('<input type="text" clas...