Posts

Showing posts from August, 2014

android - PHP GCM Undefined Index -

on execution of function, error appears: [23-apr-2015 01:08:39 europe/berlin] php notice: undefined index: syncnewdata in c:\xampp\index.php on line 972 for line: $pushmessagetag = isset($_post["syncnewdata"]) ? $_post["syncnewdata"] : $_post["syncnewdata"]; in function: function updatedatagcm($db) { // gcm regids new, "unseen" data: $sqlallregids = 'select distinct gcm_registration_id users id in ( select distinct myid usersid group_messages `read` = 1 union select distinct touid usersid messages `read` = 1 union select distinct invited_id usersid event_invites `status` = 1 union select distinct receiver_id usersid group_invites `status` = 1 union select distinct requestid usersid friends `status

html - Element does not return to its position CSS Float -

Image
what happens nav-search-ul element not return correct position after changing screen resolution, it's media not work. only happens in chrome, since in firefox y ie ok so can check in click <nav> <ul> <li class="m">aaaaa</li> <li class="nav-search-ul">bbbbb</li> </ul> </nav> li { color: red; display: block; } ul { clear: both; background: rgb(27, 34, 36); text-align: center; } @media (min-width: 600px) { li { display: inline-block; } .nav-search-ul { float: right; } } ok solution http://codepen.io/anon/pen/jpogzn just add following css: .nav-search-ul { display:inline }

c# - WPF DataBinding with other Namespace/Class -

i´m having problems databinding using wpf. have webservice(wcf) windows service app , wpf app control service. in wpf app, builded textbox want receive logs webservice. at moment can send new data same namespace (wpf app) when send (wcf app) using instance of data class, dont reflect new data in textbox. here code: mainwindow.xaml ... <grid name="grid" margin="0,0,346.6,4"> <textbox name="log" text="{binding path=logtext}" scrollviewer.cancontentscroll="true" isreadonly="true" borderthickness="0" background="transparent" horizontalalignment="left" textwrapping="wrap" verticalalignment="top" grid.column="2" margin="30.8,35,-325.8,0" height="303" grid.rowspan="2" width="295"/> </grid> ... mainwindow.xaml.cs public mainwindow() { initializecomponent();

node.js - How do I get the nodejs version inside a nodejs program? -

in debugger nodejs , there command show v8 version , debugger package version. how can nodejs version? i imagine can run command node --version or nodejs --version , i'm hoping there way without running external shell command – not slower but, depending on paths, might give different answer. use process.version version of node running: console.log('node version is: ' + process.version);

c++ - How to copy text from one file to another and then turning the first letters of the text string into uppercase -

i trying build program copies text 1 .txt file , takes first letter of each word in text , switches uppercase letter. far, have managed copy text no luck or idea on uppercase part. tips or appreciated. have far: int main() { std::ifstream fin("source.txt"); std::ofstream fout("target.txt"); fout<<fin.rdbuf(); //sends text string file "target.txt" system("pause"); return 0; } instead of copying entire file @ once, you'll need read part or of local "buffer" variable - perhaps using while (getline(in, my_string)) , can iterate along string capitalising letters either in position 0 or preceeded non-letter (you can use std::isalpha , std::toupper ), stream string out . if have go @ , stuck, append new code question , someone's sure out....

java - How can I get an enum from an interface to a class that implements that interface? -

i trying enum interface: public interface pizzainterface { public enum toppings { pepperoni, sausage, mushrooms, onions, greenpeppers; } } to class: public class pizza implements pizzainterface{ private string[] toppings = new string[5]; } and able store in array. (edit): want put in arraylist if changes anything. the first thing need understand enum static inside interface. , call values() method on enum return array of enums instances. if can work enum array rather string, should using values() call way pbabcdefp mentioned above. : pizzainterface.toppings[] toppings = pizzainterface.toppings.values(); but if need string contents, suggest use arraylist. there more benefits using arraylist arrays. in case , if you, add 1 static method inside enum class return list of strings, have used in pizza class. sample code : public interface pizzainterface { public enum toppings { pepperoni, sausage, mushrooms, onions, greenpeppers; publ

php - join two tables and fetch result in two array -

i have 2 tables , make join groupid : $userinfo= db::query("select g.* groupper ,u.* userinfo , (select count(m.id) ".database_tp_prefix."comments m m.userid =u.userid ) totalcomments ".database_tp_prefix."user u left join ".database_tp_prefix."userprofile p on u.userid=p.parentid left join ".database_tp_prefix."groups g on g.id=u.groupid u.userid=".$userid.""); i need fetch results 2 array (the above result 1 array) forexample : $this->info = db::fetch_array($userinfo,'assoc'); // user info $this->permission = db::fetch_array($userinfo,'assoc'); // user permission like this array ( array[0] ( username => manour, email => eimaidwra@zzzz.com ) array[1] ( group_tite => administer, permissonaccess => 1 ) )

php - Getting extra values in json while fetching from MySQL -

i trying fetch data ajax call via json , access data after successful ajax call. purpose, wrote following code : <?php error_reporting(e_all); ini_set('display_errors', 1); require_once('../include/functions.php'); // session_start(); if( isset($_post['bike_id'])) { $rows = array(); // echo " in isset"; $bike_id = $_post['bike_id']; // $modal_name = $_post['modal_name']; // $json['insertmodal'] = false; // json_decode($modal_name); json_decode($bike_id); $result = selectbike_modal($bike_id); while ( $row = mysqli_fetch_array($result)) { $rows[] = $row; } echo json_encode($rows); } else { echo "bike_id not set"; } ?> now want access via javascript : $('#choose_bike').on('blur', function (e) { e.preventdefault();

mysql - how to prevent one sql table to be affected when updating another table -

string update_sql = "update employees set first_name=?, last_name=?, email=?, phone_number=?, hire_date=?, job_id=?, manager_id=?, department_id=? employee_id=?"; preparedstatement ps_one = connection.preparestatement(update_sql); ps_one.setstring(1, firstname); ps_one.setstring(2, lastname); ps_one.setstring(3, email_final); ps_one.setstring(4, phonenumber); ps_one.setdate(5,sqldate); ps_one.setstring(6, job); ps_one.setint(7, manager_final); ps_one.setint(8, department_final); ps_one.setint(9, id_final); ps_one.executeupdate(); here code. try update 1 table , table affected. ora-02290: check constraint (gas.jhist_date_interval) violated ora-06512: @ "gas.add_job_history", line 10 ora-06512: @

javascript - how do I labels to the axis in this d3 example -

i figured out how enter data d3 chart can't seem figure out how put labels on both x , y axis. looking put strings values in x-axis. appreciated. thank <!doctype html> <meta charset="utf-8"> <style> body { font-family: "helvetica neue", helvetica, arial, sans-serif; margin: auto; position: relative; width: 960px; } text { font: 10px sans-serif; } .axis path, .axis line { fill: none; stroke: #000; shape-rendering: crispedges; } form { position: absolute; right: 10px; top: 10px; } </style> <form> <label><input type="radio" name="mode" value="grouped"> grouped</label> <label><input type="radio" name="mode" value="stacked" checked> stacked</label> </form> <script src="http://d3js.org/d3.v3.min.js"></script> <script> var n = 3, // number of layers m = 3, // number of s

xslt - Lines of Strings to XML tree structure -

this question exact duplicate of: strings xml format [closed] lets in notepad: have following text : first line: a\b\c second line: a\b\c\d how can make xml tree structure of 2 lines without duplicating , b, , c - new character not have duplicates-which in case letter "d", shall added child last character has same value is, in case letter "c" – this seems pretty straightforward. each line, check see whether there top level node first symbol , create 1 if there not. each subsequent symbol, again check existence , create child node if needed. repeat on each line. whole thing reminds me of -p option mkdir command.

tdd - Testing Chef roles and environments -

i'm new chef , have been using test kitchen test validity of cookbooks, works great. i'm trying ensure environment-specific attributes correct on production nodes prior running chef initially. these defined in role. for example, may have recipes converge using vagrant box dev settings, validates cookbook. want able test production node's role. think want these tests source of truth describing environment. looking @ test kitchen's documentation, seems beyond scope. is assumption correct? there better approach test cookbook before first time chef run on production node ensure has correct settings? i pleasantly discovered chef_zero uses "test/integration" directory it's chef repository. just create roles under test/integration/roles example standard chef cookbook layout. ├── attributes │   └── default.rb ├── berksfile ├── berksfile.lock ├── chefignore ├── .kitchen.yml ├── metadata.rb ├── readme.md ├── recipes │   └── defaul

c - Scanf two numbers at a time from stdout -

i have program outputs huge array of integers stdout, each integer in line. ex: 103 104 105 107 i need write program reads in array , fill spaces number isn't increment of 1 of previous number. different between numbers going 2 (105,107), makes easier. this code logic: printf("d",num1); if ((num2-num1) != 1) numbetween = num1 + 1; printf("%d", numbetween); printf("%d", num2); else( printf("%d",num2); ) so output of program be: 103 104 105 106 107 my issue reading numbers. know can while (scanf("%hd", &num) != eof) read lines 1 @ time. logic want, i'm going need read 2 lines @ time , computation them, , don't know how. you read first , last numbers file, , print in between. int main( void ) { // first value in file int start; if ( scanf( "%d", &start ) != 1 ) exit( 1 ); // last value in file int end = start; while ( scanf( "

java - (Android)Trying to understand why my method will not compute/display the correct value in the textview -

my method called (calculate bmi) inside of activity supposed compute , display bmi (based on formula inside code), , display value inside of textview. application runs correctly, value displayed zero. struggling figure out if problem lies in formula (unlikely) or if way passing value incorrect. appreciated. code below .java file import android.content.intent; import android.support.v7.app.actionbaractivity; import android.os.bundle; import android.view.menu; import android.view.menuitem; import android.widget.edittext; import android.widget.textview; import android.view.view; import android.widget.toast; public class health extends actionbaractivity { edittext bloodpressure; edittext cholesterol; int weight; int height; edittext heightstring; edittext age; textview bmitext; edittext weightstring; mydbhandler dbhandler; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate);

c++ - uniform_int_distribution using a list instead of a range of values -

i've looked documentation , examples after trying run code unable find method feed list uniform_int_distribution . not possible then? does have suggestions on best way randomly pick item given list without using srand() or rand() ? you can generate random number in correct range using uniform_int_distribution , pick element of list using std::next , like: #include <algorithm> #include <iostream> #include <list> #include <random> int main() { std::random_device rd; std::mt19937 rng(rd()); std::list<char> lst{'a', 'b', 'c', 'd'}; std::uniform_int_distribution<std::size_t> uid(0, lst.size() - 1); // range [0, size-1] std::size_t pos = uid(rng); // random index in list auto elem = *std::next(lst.begin(), pos); // pick element std::cout << elem << std::endl; // display }

javascript - Possible to modify cookie values in a jQuery ajax request? -

i working on chrome extension allow users record http requests site, modify pieces of request , resend it. i'm hoping use jquery's ajax method construct , send modified request. have been able construct other parts of request, far can tell there no way include cookie values in request. just clear - i'm not trying create cookie on browser, i'm trying modify cookie value sent along part of http request using jquery's ajax method. can done jquery's ajax? if not, there anyway in javascript? since you're talking chrome extension, can employ webrequest api intercept , modify requests. chrome.webrequest.onbeforesendheaders.addlistener( function(details) { /* identify somehow it's request initiated */ (var = 0; < details.requestheaders.length; i++) { if (details.requestheaders[i].name === 'cookie') { /* */ break; } } /* add cookie header if not found */ return {requesthead

css - How to create a multi email client html template such that background image with text on top is displayed in all clients? -

i trying add background image table element tr email html template . there text displayed @ top of image . the text dynamic coming from field can not make image in table elements. the code have follows <tr> <td background="http://bit.ly/1hxqys9" bgcolor="#c0393f" style="background-image: url('http://bit.ly/1hxqys9');width:600px;height:240px" width="600" height="240" valign="top" > <!--[if gte mso 9]> <v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width:600px;height:240px;"> <v:fill type="tile" src="hhttp://bit.ly/1hxqys9" color="#c0393f" /> <v:textbox inset="0,0,0,0"> <![endif]--> <p style="color:#c9be8a;font-weight:

ruby on rails - -su: bundle: command not found when starting unicorn -

i'm following tutorial @ digitalocean (fyi, tutorials, link1 , link2 ), install production ready rails app using unicorn, , nginx, , when part on installing unicorn. when try typing console: sudo service unicorn_appname start i error: starting appname -su: bundle: command not found all users can bundle. message makes no sense me. ideas? i followed same guide , had same issue. the startup script in init.d/unicorn_appname evaluated to: su - deploy -c cd /home/deploy/appname && bundle exec unicorn -c config/unicorn.rb -e production -d root user on startup first su - rails user (in case 'deploy') excutes bundle start unicorn. rbenv single user, 'deploy' has bundle installed. path bundle stored in .bashrc file if followed guide. .bashrc file not invoked login in through su - , caused bundle not installed error. the solution include paths related rbenv in .profile. way when root su - 'deploy' paths loaded.

javascript - Change numberic value in td with jquery -

how can increase numeric values in <td> element using jquery? tried following no luck. have button id="#increasenum", , trying change td cell value click. html: <table> <tr> <td id="num">1</td> <td id="num">5</td> <td id="num">10</td> </tr> </table> js: $(document).ready(function() { $("#increasenum").click(function() { $("#num").html(number(("#num").innertext) + 1); }); }); this makes first <td> value disappear. suggestions? try :remove duplicate ids , use class instead. iterate each num increment value shown below html: <table> <tr> <td class="num">1</td> <td class="num">5</td> <td class="num">10</td> </tr> </table> jquery : $(document).ready(function () { $("#increasenum"

java ee - gradle test failing due to interceptor class not found -

i'm working through exercises in beginning java ee 7 except i'm trying adapt them use gradle instead of maven. chapter 2 interceptor exercise, wrote build.gradle: apply plugin: 'java' repositories { mavencentral() } dependencies { compile 'org.slf4j:slf4j-api:1.7.5', 'org.jboss.weld.se:weld-se-core:2.2.10.final' testcompile "junit:junit:4.11" } jar { { configurations.compile.collect { it.isdirectory() ? : ziptree(it) } } manifest { attributes 'main-class': 'org.agoncal.book.javaee7.chapter02.main' } } i'm using src dir directly author's github . ./gradlew -x test build succeeds , java -jar build/libs/gradletest.jar gives expected output (although spits out lot of unexpected warnings). ./gradlew test fails error: org.jboss.weld.exceptions.deploymentexception: weld-001417: enabled interceptor class <class>org.agoncal.book.javaee7.chapter02

validation - Unique Validator - add error (warning) and return true -

what best way create validator checks if model value unique or not, not return false - shows message "the value exists" (i can still save model)? validators don't return boolean values, add errors given model attribute(s). one of ways (with minimal completions) using built-in uniquevalidator , saving without running validation. at first call $model->validate() fill model errors. you can use $model->validate('fieldname') validate needed field. then call $model->save(false) or $model->save('fieldname') (for 1 field). this prevent validation before saving , model values saved "as is". another way saving 1 attribute without triggering events, etc. using updateattributes after calling validate() : $model->updateattributes(['fieldname' => 'fieldvalue']);

html - CSS: style is reset after `<pre>` element -

Image
there web-site nodeclipse foss project http://www.nodeclipse.org/ i not quick @ web development , styles, , there problem don't know how approach: on main page http://www.nodeclipse.org/index.html there <pre> element ( source line ) , after style different @ pragraph start. i guess there's in applied http://www.nodeclipse.org/pipe.css " ( source ), for? (as not pre element happens after it) foss project needs web. as can see, <pre> tag usage inside <p> tag breaks dom structure so text after pre tag not enclosed inside <p> tag. it not advised use pre tag display content doesn't lose it's meaning if not pre-formatted. so use <a> tag or other suitable tags span (if don't want clickable link) display url , style accordingly.

ios - Override UIViewController's view property -

i want override myviewcontroller : uiviewcontroller 's setview: method, such that, not allow 1 set view 's property nil . -(void)setview:(uiview*)view { if (view == nil) //ignore - make no change else //default performance } how can this? calling super class when want default behavior should work: -(void)setview:(uiview*)view { if (view == nil) { //ignore - make no change } else { //default performance [super setview:view]; } }

javascript - Full Size AmCharts -

i using amcharts website, make full size. example, have code: <style> #chartdiv { width : 50%; height : 500px; float : left; } </style> <script> var chart = amcharts.makechart( "chartdiv", { "type": "pie", "theme": "light", "automargins": false, "margintop": 2, "marginbottom": 2, "marginleft": 2, "marginright": 2, "fontsize": 14, "dataprovider": [ { "type": "open issues", "number": op }, { "type": "closed issues", "number": cl }, { "type": "deferred issues", "number": df }, { "type": "vendor issues", "number": ve }, { "type": "faq issues", "number": fq } ], "valuefield": "number", "titlefield": "type", "export": { "enabled": true, "l

ruby on rails - Reset the database , remove the seeds.rb data from database -

how remove seeds.rb data database , added data in seeds.rb though changed ,it not working !!!, how remove data present in database , entered through seeds.rb file ? if have data seed.rb file in database, should type rake db:seed again after updating seed.rb file. add line: modelname.delete_all before creating new records of model. however, if have other data in database, choose 1 of solutions below: manualy remove data using sql query before line of creating records, add lines removes them. example: mymodel.where(name: "foo").destroy_all mymodel.create(name: "foo") use env variable in seed.rb file switch mode: if env['seedmode'] == 'removedata' #add removing code here else #here should normal seed code then run seedmode='removedata' rake db:seed

javascript - Testing REST routes with curl -X PUT, returns 404 -

i'm learning mean stack , following mean tutorial on @ thinkster.io https://thinkster.io/mean-stack-tutorial/ i'm on "opening rest routes" section. i'm trying put upvote using curl command: curl -x put http://localhost:3000/posts/55387047f2334d2 c227e8079/upvote i following error messages: c:\users\michael\desktop>curl -x put http://localhost:3000/posts/55387047f2334d2 c227e8079/upvote <h1>not found</h1> <h2>404</h2> <pre>error: not found @ app.use.res.render.message (c:\users\michael\desktop\flapper-news\app.js: 39:13) @ layer.handle [as handle_request] (c:\users\michael\desktop\flapper-news\n ode_modules\express\lib\router\layer.js:82:5) @ trim_prefix (c:\users\michael\desktop\flapper-news\node_modules\express\l ib\router\index.js:302:13) @ c:\users\michael\desktop\flapper-news\node_modules\express\lib\router\ind ex.js:270:7 @ function.proto.process_params (c:\users\michael\desktop\flapper-news\nod

javascript - converting canvas to blob using cropper js -

i have created application using cropper.js cropping images. application working , image cropping, after trying send cropped image blob server side storing, as per cropper.js documentation can use canvas.todataurl data url, or use canvas.toblob blob , upload server formdata. when tried canvas.todataurl() getting base64 string, need send file blob tried canvas.toblob() getting uncaught typeerror: canvas.toblob not function in chrome , typeerror: not enough arguments htmlcanvaselement.toblob. in firefox can please tell me solution this my code this var canvas = $image.cropper("getcroppedcanvas", undefined); var formdata = new formdata(); formdata.append('mainimage', $("#inputimage")[0].files[0]); formdata.append('croppedimage', canvas.toblob()); the method toblob asynchronous , require 2 arguments, callback function , image type (there optional third parameter quality): void canvas.toblob(callback, type, encoderoptions

python - Pandas DataFrame to List of Dictionaries -

i have following dataframe: customer item1 item2 item3 1 apple milk tomato 2 water orange potato 3 juice mango chips which want translate list of dictionaries per row rows = [{'customer': 1, 'item1': 'apple', 'item2': 'milk', 'item3': 'tomato'}, {'customer': 2, 'item1': 'water', 'item2': 'orange', 'item3': 'potato'}, {'customer': 3, 'item1': 'juice', 'item2': 'mango', 'item3': 'chips'}] use df.t.to_dict().values() , below: in [1]: df out[1]: customer item1 item2 item3 0 1 apple milk tomato 1 2 water orange potato 2 3 juice mango chips in [2]: df.t.to_dict().values() out[2]: [{'customer': 1.0, 'item1': 'apple', 'item2': 'milk', 'item3':

restful architecture - PUT on REST collection. Do I provide addresses? -

when put on rest collection should provide addresses of members in collection? put on dogs address specified [{"name":"sparky", "id":1}, {"name":"rusty", "id":2}] or... put on dogs without address specified [{"name":"sparky"}, {"name":"rusty"}] and let server return locations of new members in collection. in case row ids in table. if sending put replace every resource in entire collection, should send full new / updated entities. if id part of entity, should send within entity, client has nothing uri (a.k.a "address") of element, clients have knowledge how uri build server. if id not part of entity client, should not send within entity. but both cases possible , server accept both, important the put on collection behaves in http/1.1 specs described: the put method requests enclosed entity stored under supplied request-uri. so if put

android - How to get unread SMS when just receive it? -

i'm building unread sms relay application. there phone , b, when receives sms , no 1 read it, application relay b. find when receives sms, there system notification display. contentobserver 's onchange() method called until disappear notification. should unread sms when receive it? contentobserver: public newincomingcontentobserver(handler handler, application application) { super(handler); this.mapplication = application; } @override public void onchange(boolean selfchange) { system.out.println(selfchange); super.onchange(selfchange); uri uri = uri.parse(sms_uri_inbox); mmessagelistener.onreceived(this.getsmsinfo(uri, mapplication)); } /** * newest sms */ private smsinfo getsmsinfo(uri uri, application application) { ... } public interface messagelistener { public void onreceived(smsinfo smsinfo); } public void setonreceivedmessagelistener( messagelistener messagelistener) { this.mmessageli

javascript - meteor get google accesstoken after redirect -

i'm implementing invite people in app, want use googgle contacts, if use accounts-google package authenticating user, complex process, beause don't want store user information, i want 1 time auth, i'm searching client side solutions, var url='https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/contacts.readonly&client_id=5558545-3n8vg6u4nu2hm1gmuj1dbjib28p33qss.apps.googleusercontent.com&redirect_uri=http://localhost:3000/_oauth/google&response_type=token' var newwindow = window.open(url, 'name', 'height=600,width=450'); on click of invite button i'm calling working well, how read accesstoken returned window. i can't find how this? i tried using http method http.get(url, {}, function(e,r){ console.log(e,r); }); but throwing error, not working. how read accesstoekn popup? or there alternatives that? window.location.hash contains fragment part of url.

java - Find the sum of all the primes below two million.My program doesn't work for very big numbers -

this code finding sum of primes.it works low numbers if it's 2000000 (2 million) never ends.anybody can me? import java.math.biginteger; public class problem010{ public static void main(string[] args) { biginteger sum = new biginteger("2"); //for (int i=3; i<2000000; i++) { for(int i=3; i<10; i++){ (int j=2; j<i; j++){ if (i % j == 0) break; else if (i == j+1){ sum = sum.add(biginteger.valueof(i)); } } } system.out.println("sum = "+sum); } } your answer 142913828922 how? i changed algorithm little bit: public static void main(string[] args) { biginteger sum = new biginteger("2"); boolean isprime = true; (int i=3; i<2000000; i++) { double aa = math.sqrt((double)i); (int j=2; j<=aa; j++){ if (i % j == 0){

mongodb - How to update a field value in array in mongo database? -

how can update value 'enabled' field in configuration @ index 1 in configurations array in mongo database ? below json data. { "configurations" : [ { "configuration" : { "host" : "", "port" : "1521", "enabled" : "true" } }, { "configuration" : { "host" : "", "port" : "", "enabled" : "true" } } ], "descripti

garbage collection - use JMX(jconsole) to monitor JVM GC.how to get young GC info and full GC info? -

i can " ps scavenge ,ps marksweep" attributes: collectioncount,collectiontime through jmx .but questiong :" 1 young gc info ?which 1 full gc info ? " how can more details on gc. jstat jstat gc info .the twos different. the following bean: import java.io.serializable; public class performancebean implements serializable { /** * */ private static final long serialversionuid = -6021047939070147624l; /* * survivor space 0 utilization percentage of space's current * capacity. */ public final long jstats0; /* * survivor space 1 utilization percentage of space's current * capacity. */ public final long jstats1; /* * eden space utilization percentage of space's current capacity. */ public final long jstate; /* * old space utilization percentage of space's current capacity. */ public final long jstato; /* * permanent space ut

javascript - React.js: Difference between passing in the subcomponents with React.render() and with React.createClass()'s render? -

i'm working on project using react.js, , confused composition of react. http://facebook.github.io/react/docs/multiple-components.html the link above gives example. uses react.creatclass() create 3 components. parent component , 2 child components. parent component includes others within it's jsx in render method. this example's clear, not 'reusable'. if wanna pass in child in situation? react.js seems lacking 'extend' method backbone's view. later, found can pass children components in react.render(), , use this.props.children composite. var tom = react.createclass({ render: function(){ return( <a>this tom.</a> ) } }); var john = react.createclass({ render: function(){ return( <a>this john.</a> ) } }); var outter = react.createclass({ componentdidmount:function(){ console.log(this.props.children); }, render: function(){ return( <div classname=&qu

url routing - Django URLConf include from sub-app not working -

i trying include django sub-app's urls main urls.py. app/urls.py: urlpatterns = patterns( '', ... include('transfers.urls'), ) app/transfers/urls.py: urlpatterns = patterns( '', url(r'^transfers/$', 'some.view'), ... ) but route not found error. last element of route urlconf module sub-app. has not been delisted parent url list. using urlconf defined in app.urls, django tried these url patterns, in order: 1. 2. ... 30. <module 'transfers.urls' '/path/to/app/transfers/urls.pyc'> current url, transfers/, didn't match of these. when copy first url pattern transfers.urls main urls.py, works. seems including sub-app urls.py, not sure if in right way. how can work properly? you can try this: url(r'^transfers/', include('transfers.urls', namespace="transfers")), then can use host:port/transfers/transfers/ . these 2 transfers different. f

jquery - Bootstrap Progress bar with custom validation -

i'm trying activate tabs of progress bar after slight validations. however, css % property of progress bar fails change. here javascript relevant code , working code on fiddle : $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { console.log("here"); //update progress var step = $(e.target).data('step'); var percent = (parseint(step) / 4) * 100; $('.progress-bar').css({width: percent + '%'}); $('.progress-bar').text(percent + '%'); //e.relatedtarget // previous tab }) $('#page-wrapper').on('click', '#to-tab-2', function(e) { e.preventdefault(); $('ul.nav-pills li a[data-step="2"]').attr({ "href": "#step2", "data-toggle": "tab" }); $('a[href="#step2"]').parent().removeclass('disabled') $('a[hr

c - Returning array address from function did not work -

i have c program in user enters sets of grades. works correctly. gpa calculated correctly, etc. however, when numbers printed out, both pointers in student structs point same address reason, leading both students display grades of second when information printed out. rest of information correct, it's grades identical. the thing can think of second initialization of grades array overwrites first. don't understand why happens or how fix it. the following sample io of program: enter number of students:> 2 enter number of grades track:> 3 there 2 students. there 3 grades. enter information student: enter sid:> 101 enter last name:> enright enter first name:> reed enter grades (separated space):> 70.1 60 92 enter information student: enter sid:> 123 enter last name:> claire enter first name:> heidi enter grades (separated space):> 82.5 96.1 89.0 student id #101: name:

html - Responsive Website Generator - Is It Possible? -

so, there million tools out there on making responsive html5 websites. do think it's possible, or know of out there, have upload old school website , have software spit out html5 mobile/responsive website? try self. of them generate tools mean, no needed developers , supports. work have make manually. , no tool available in web market. try http://www.responsivehtmlfactory.com/ . payable , manual work , have time.

c# - AngularJS the AJax data not submitting back to HTML -

i have 2 pages index.html , default.aspx. index.html, ajax hit submitted default.aspx process database request , return json string html page. sample code given below. i'm using angular 1.2.26 . <div ng-app="myapp" ng-controller="customerscontroller"> <ul> <li ng-repeat="x in names"> {{ x.id + ', ' + x.name}} </li> </ul> </div> <script type="text/javascript"> var app = angular.module('myapp', []); function customerscontroller($scope, $http) { $scope.response = $http.get("http://localhost/default.aspx") .success(function(response) { $scope.names = response.records; }); } </script> default.aspx public static string getemployees() { // ... stuff grab data goes here ... // datarow dr; foreach (datarow dr in dt.rows) { row = new d

python - Many-to-Many relation fields with WTForms-Alchemy? -

on documentation page , there examples of how use wtforms-alchemy one-to-one , one-to-many relations. have tables use many-to-many , can't seem figure out how render form fields. code below reference. from flask.ext.wtf import form wtforms import form form2 wtforms_alchemy import model_form_factory, modelform, modelfieldlist wtforms.fields import formfield app.models.bookmodel import book app.models.submodels import booktypeform basemodelform = model_form_factory(form) basesubmodelform = model_form_factory(form2) class modelform(basemodelform): @classmethod def get_session(self): return db.session class submodelform(basesubmodelform): @classmethod def get_session(self): return db.session class booktypeform(submodelform): class meta: model = booktype = ['name'] class bookform(modelform): class meta: model = book book_type = modelfieldlist(formfield(booktypeform)) this the book_type field , mode

datetime - Is UNIX time universal -

i did research on internet still confused. unix time universal time gmt/utc or vary place place local time? i know unix time counted 1st jan, 1970 00:00:00 gmt. when use gettime() function in java (more date d= new date(); long currenttime d.gettime()) getting unix time in milliseconds. if person , person b use same function sitting in 2 different time zones, same result? now if person , person b use same function sitting in 2 different time zones, same result? yes, - assuming clocks both "correct" of course. the java.util.date class wrapper around "the time since unix epoch, in milliseconds". given unix epoch instant in time (not "midnight on january 1st 1970", number of elapsed milliseconds same wherever are. (ignoring relativity , discussion of leap seconds...) (side-note: @ unix epoch, wasn't midnight in greenwich. 1am, because uk observing bst @ time. that's british standard time, not british summer time - uk @ utc

ruby - Moving a node as the first child of another node -

i have document: <html> <head> <style>some styles<style> </head> <body> <h1>header</h1> <table>table content</table> <div>some text</div> </body> </a> the below code moves <style> tag below <div> in <body> : style = @doc.at_css "style" body = @doc.at_css "body" style.parent = body is there way move <style> above <h1> ? finding first child of body , adding style tag previous sibling first child solves problem. style = @doc.at_css "style" body = @doc.at_css "body" style.parent = body first_child = body.first_element_child first_child.add_previous_sibling(style)

multithreading - In Java, is there a deadlock if `insert()` and `size()` executed in concurrency? -

the codes looks ( link ): /*** * excerpted "seven concurrency models in 7 weeks", ***/ import java.util.concurrent.locks.reentrantlock; class concurrentsortedlist { private class node { int value; node prev; node next; reentrantlock lock = new reentrantlock(); node() {} node(int value, node prev, node next) { this.value = value; this.prev = prev; this.next = next; } } private final node head; private final node tail; public concurrentsortedlist() { head = new node(); tail = new node(); head.next = tail; tail.prev = head; } public void insert(int value) { node current = head; current.lock.lock(); node next = current.next; try { while (true) { next.lock.lock(); try { if (next == tail || next.value < value) { node node = new node(value, current, next); next.prev = node; current.next = node; return;