Posts

Showing posts from August, 2015

javascript - Get number of times a number will multiply itself with another until reach a certain limit -

i can number of times number multiply until reach limit: var velocity = -5.706875; var friction = 0.9925; var limit = 0 var times = 0; while (math.floor(math.abs(velocity)*10) > limit) { velocity *= friction; times += 1; } // times = 538 is there way times without loop? tried math.log(5.706875, 0.9925) gives result. sure, there are: times = math.ceil(math.log(-0.1/velocity)/math.log(friction)); edit: actually, taking account limit var, be: times = math.ceil(math.log(-(0.1+limit/10)/velocity)/math.log(friction));

java - Incompatible types: possible lossy conversion from double to int -

help? don't know why getting error. getting @ in line 39: term[1] = differentiate(coeff[1], exponent[1]); how can fix issue? full code listing: public class calcprog { public static void main(string[] args) { scanner input = new scanner(system.in); int numterms = 7; double[] coeff = new double[6]; double[] exponent = new double[6]; string[] term = new string[6]; system.out.println("enter number of terms in polynomial:"); numterms = input.nextint(); while (numterms > 6) { if (numterms > 6) { system.out.println("please limit number of terms six."); system.out.println("enter number of terms in polynomial:"); numterms = input.nextint(); } } (int = 1; < numterms + 1; i++) { system.out.println("please enter coefficient of term #" + + " in decimal form:&q

linux - sed place parentheses at the beginning and close on the 4th line -

im trying place open parenthesis on first line , close end of 4th line. below example of data followed output looking for. tester1 service_ticket_created thu mar 19 23:27:57 utc 2015 192.168.1.3 tester2 service_ticket_created fri mar 20 00:31:59 utc 2015 192.168.1.2 (tester1 service_ticket_created thu mar 19 23:27:57 utc 2015 192.168.1.3) (tester2 service_ticket_created fri mar 20 00:31:59 utc 2015 192.168.1.2) using awk can as awk 'nr%4==1{print "("$0; next} nr%4==0{print $0")"; next}1' test $ awk 'nr%4==1{print "("$0; next} nr%4==0{print $0")"; next}1' input (tester1 service_ticket_created thu mar 19 23:27:57 utc 2015 192.168.1.3) (tester2 service_ticket_created fri mar 20 00:31:59 utc 2015 192.168.1.2) shorter version awk 'nr%4==1{$0="("$0} nr%4==0{$0=$0")"}1'

Android speech recognition for non-dictionary words -

i developing android application of speech recognition non-dictionary words. want remove dictionary , word. example if pronounce word "pini", current application "beanie". want word recognize pronounced. my code: public void onclick(view v) { // todo auto-generated method stub switch (v.getid()) { case r.id.btnspeak: promptspeechinput(); break;} } @override // act on result of tts data check protected void onactivityresult(int requestcode, int resultcode, intent data) { if (requestcode == my_data_check_code) { if (resultcode == texttospeech.engine.check_voice_data_pass) { mytts = new texttospeech(this, this); } else { intent installttsintent = new intent(); installttsintent .setaction(texttospeech.engine.action_install_tts_data); startactivity(installttsintent); } } // receiving speech input super.onactivityresult(request

apache spark - Are multiple reduceByKey on the same RDD compiled into a single scan? -

suppose have rdd (50m records/dayredu) want summarize in several different ways. rdd records 4-tuples: (keep, foo, bar, baz) . keep - boolean foo , bar , baz - 0/1 int i want count how many of each of foo &c kept , dropped, i.e., have following foo (and same bar , baz ): rdd.filter(lambda keep, foo, bar, baz: foo == 1) .map(lambda keep, foo, bar, baz: keep, 1) .reducebykey(operator.add) which return (after collect ) list [(true,40000000),(false,10000000)] . the question is: there easy way avoid scanning rdd 3 times (once each of foo , bar , baz )? what mean not way rewrite above code handle 3 fields, telling spark process 3 pipelines in single pass. it's possible execute 3 pipelines in parallel submitting job different threads, pass through rdd 3 times , require 3x more resources on cluster. it's possible job done in 1 pass rewriting job handle counts @ once - answer regarding aggregate option. splitting data in pairs (keep, foo

c - undefined reference to avltree_init -

in code provided instructor there is: typedef int (*avltree_cmp_fn_t)(const struct avltree_node *, const struct avltree_node *); int avltree_init(struct avltree *tree, avltree_cmp_fn_t cmp, unsigned long flags); after define my_cmp function... int my_cmp(const struct avltree_node *a, const struct avltree_node *b) { struct my_struct *p = avltree_container_of(a, my_struct, node); struct my_struct *q = avltree_container_of(b, my_struct, node); return p->key - q->key; } and pass parameter avltree_init... avltree_init(&tree, my_cmp, 0); i get: undefined reference `avltree_init(avltree*, int (*)(avltree_node const*, avltree_node const*), unsigned long)' could explain, please, why happens , did make mistake? thanks! it seems error message you're not linking file contains avltree_init function. need link files, including file containing function, final application. error comes linking phase, not compiling phase. further

c++ - Write a function to copy 0-15 bits into 16-31 -

how write function copy 0-15 bits 16-31? unsigned int n = 10; // 1010 copyfromto(n); assert(n == 655370); n = 5; copyfromto(n); assert(n == 327685); n = 134; copyfromto(n); assert(n == 8781958); you want copy bits in 0-15 16-31. should understand multiplying 2 equivalent shifting bits of number once left (moving higher bits). if number n , n << 16 shifting number 16 bits left. equivalent multiplying n 16th power of 2, happens 65536. to copy bits, , keep original bits in 0-15, command n = n + (n << 16); should work. however, issue (as pointed out in comments), upper 16-31 bits still set in n + term. need clear these bits. note 65535 corresponds 2^16 - 1, , have first 0-15 bits 1, , others 0. correct command n = (n && 65535) + (n << 16);

Alfresco Rest API to get the current node version -

i'm making call get service/api/version?noderef={noderef} , want limit query recent version. found stackoverflow post suggests use of &filter={filterquery?} filter results, looks applies people query method. there version method? before answering specific query, general point. alfresco community open source, , of alfresco enterprise too, many queries around best bet go , check source code yourself! rest apis held in projects/remote-api looking in there, can see versions webscript returns versions given node. it's fast that, calling , getting recent 1 isn't end of world otherwise, slingshot node details api @ http://localhost:8080/alfresco/service/slingshot/doclib2/node/{store_type}/{store_id}/{id} (add parts of noderef url) return lots of information on node quickly, including latest version. in json returned that, inside item key like "version": "1.7", which gives latest version node some of listing , search apis include

mysql - How to obtain a value from previous day in a query -

given data table below, how can show score these date range: 3/10 3/12? the formula score today's score=(today's avg5daysprice *2.15)/ yesterday's score. example 3/10 score = (126.11*2.15)/10.36 the data lives in both sql server , mysql. symbol tdate price avg5daysprice score ----------------------------------------------- aapl 3/9/2015 127.14 126.6, 10.36 aapl 3/10/2015 125.32 126.11 null aapl 3/11/2015 128.15 127.25 null aapl 3/12/2015 124.48 125.66 null cte solution in sql server, below code with value_cte (symbol, tdate,avg5day, scoreant) ( select symbol, tdate,avg5day, score scoretable score not null ynion select b.symbol, b.tdate, b.avg5day, cast(((b.avg5day*2.15)/a.scoreant) decimal(8,2)) score value_cte inner join scoretable b on dateadd(day,-1,b.tdate) = a.tdate ) -- define outer query referencing cte name. select symbol, tdate, avg5day, scoreant value_cte result symbol

graphics - Java custom Path2D -

i have created custom path2d class draw h-shaped "calliper" on screen, project doing. want drag , resize calliper on screen. have managed path2d set can draw calliper, , code looks this: declaration , constructor: public class calliper extends path2d.double { // x , y coordinates of 6 points on calliper double cx1, cx2, cx3, cx4, cx5, cx6; double cy1, cy2, cy3, cy4, cy5, cy6; // width , height double cwidth; double cheight; public calliper(double x, double y, double w, double h) { cwidth = w; cheight = h; cx1 = x; cy1 = y; cx2 = x; cy2 = y + (h/2); cx3 = x; cy3 = y + h; cx4 = x + w; cy4 = y; cx5 = cx4; cy5 = cy4 + (h /2); cx6 = cx4; cy6 = cy4 + h; build(); } build() method (used draw path) , setcalliper() method, used redefine coordinates, or width, height: private void build() { // draw path calliper moveto(cx1, cy1); lineto(cx2, cy2); lineto(cx3, cy3);

c# - FB.Init fails trying to convert Int32 to Char -

the facebook api works when it's in unity editor not on facebook canvas. receive error in development console: >overflowexception: value greater char.maxvalue or less char.minvalue >>system.convert.tochar(int32 value) >>facebook.minijson.json+parser.get_peekchar() >>facebook.minijson.json+parser.eatwhitespace() >>facebook.minijson.json+parser.get_nexttoken() >>facebook.minijson.json+parser.parsevalue() >>facebook.minijson.json+parser.parse(system.string jsonstring) >>facebook.minijson.json.deserialize(system.string json) >>facebook.nativedialog.commonvariablescallback(.fbresult result) >>facebook.asyncrequestdialogpost.callbackwitherrorhandling(.fbresult result) >>facebook.asyncrequeststring+<start>.c_iterator0.movenext() i understand converting int32 char, contains 1byte, not possible i've not included such conversions in code related to facebook api. i've found out successive deletions occurs

android - onMessageReceived() never called, although connected to handheld -

i want send messages handheld device smartwatch (moto360) when message comes up. i made sure both modules have same package name, debug.key , version number. the listener gets added in onconnected() , function called. here handheld gradle.build: apply plugin: 'com.android.application' android { compilesdkversion 19 buildtoolsversion "22.0.0" defaultconfig { applicationid "de.bachelorthesis.important" minsdkversion 9 targetsdkversion 19 versioncode 1 versionname "1.0" } signingconfigs { debug { storefile file("../debug.keystore") } } buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.txt' } } } dependencies { compile 'com.android.support:support-v4:19.1.0' compile 'com.google.android.gms:play-services:7.0.0' compile files('libs/commons-io-2.4.jar') compi

c# - Should I create a new array or use array.clear? -

i have array of data gets zeroed out time time. that, should instantiate new array, or use array.clear method? for instance, int workingset = new int[5000]; // other code here workingset = new int[5000]; // or array.clear(workingset, 0, 5000); when make new array instead of old one, c# will: make old array eligible garbage collection, , deallocate it allocate new array fill new array zeros. when keep old array, c# will fill old array zeros. everything else being equal, second approach more efficient.

Android device mirrored PC -

i know if there possibility mirror android device in real time using android studio? or else may used usb or hdmi cable no required registration? tried couple of little software apps far there delay consinsting in more 10 seconds until action mirrored on pc. thank in advance. you can try allcast. http://www.omgchrome.com/cast-android-mirror-chrome-desktop-pc/ or may be, can first record screen , play later using adb shell screenrecord /sdcard/demo.mp4 , pull file using adb pull /sdcard/demo.mp4

javascript - How to prevent and guard against closure memory leaks -

var utils = (function() { var playlistutils = (function() { // playlist utils return { saveplaylisobj: function(playlist) { if (playlist) { localstorage.setitem('playlistobj', json.stringify(playlist)); } }, getplaylistobj: function() { var plobj = localstorage.getitem('playlistobj'); if (plobj) { return json.parse(plobj) || {}; } } }; })(); return { playlistutils: playlistutils }; })(); could closure possibly causing memory leak ? i'm running issue chrome mobile android crashes intermittently when running web application. reference: what stack trace mean? app specifics : server : jboss frameworks : angular heavy, javascript , jquery i don't see leak here. and, regardless leak material has either hold large amount of memory or created , leaked thousands of times or combination of two. doesn't declared more once , not hold large amo

ember.js - How do I turn my form into an ember component? -

i have form: <form {{action 'resetpassword' on="submit"}}> {{input type="password" value=newpassword placeholder="reset password"}}<br> {{#if newpassword}} {{input type="password" value=confirmpassword placeholder="confirm password"}} {{#if passwordok}} <button>reset</button> {{/if}} {{/if}} </form> it relies on resetpassword action being available , passwordok function tests password has been entered , confirmation matches. this smashing think need use form multiple times in app. assume should make component. how can turn form reusable component? i'm interested in how take chunk of functionality , make available throughout app. how package , re-use it? possibly late party may else. a 5 minute guide creating ember form component ember cli generate new project - "ember new quick-form" navigate directory type - "ember g componen

php - Load a modal popup if a session exists? -

hi title suggests load modal popup if session exists on page load. i use sort of flash message. example if form submitted php script creates success session success message in it. then redirects previous page. on page if statement checking if success session exists echos out if , destroys session show again if page reloaded. so instead of showing success message modal window open. i have thought have been quite simple cant seem to it. although sure duplicate , have been found google... yes possibly. you like: <?php if (isset($_session['success'])) { ?> <div class="modal hide fade" id="mymodal"> <div class="modal-header"> <a class="close" data-dismiss="modal">×</a> <h3>success</h3> </div> <div class="modal-body"> <p><?php echo $_session['success']; ?></p> </div> <

Returning a particular index of a list based on another index of the same list R -

i have list below(this 1 element of list there 50 more every state) $ak hospital.name state heartattack heartfailure pneumonia 99 providence alaska medical center ak 13.4 12.4 7.9 103 alaska regional hospital ak 14.5 13.4 8.9 102 fairbanks memorial hospital ak 15.5 15.6 9.8 106 alaska native medical center ak 15.7 11.6 11.6 100 mat-su regional medical center ak 17.7 11.4 9.0 104 yukon kuskokwim delta reg hospital ak not available 11.2 6.9 110 sitka community hospital ak not available not available 7.8 114 peacehealth ketchikan medical center ak not available 11.4 8.0 101

node.js - Webdriver (wd) tests work locally but time out on Travis CI? -

i have tests written gulp-mocha-selenium uses wd under hood. may important note 'wd' driver not vanilla webdriver. tests here: https://github.com/uwfosterit/react-starter/blob/master/test/acceptance/hello-spec.js my travis.yml is: language: node_js node_js: - "0.10.37" before_install: - "export display=:99.0" - "sh -e /etc/init.d/xvfb start" - "npm install -g eslint gulp eslint-plugin-react webpack" before_script: - "sleep 30" script: - "gulp check" - "gulp test:server" - "gulp test:acceptance" addons: firefox: "31" the tests work fine locally, time out on travisci.org. i'm not sure start looking. travis results: https://travis-ci.org/uwfosterit/react-starter/builds/55222925 it turns out need download , start selenium on travisci before_script: - "wget http://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.0

javascript - Counting continusly with scroll, speed varies -

my boss asked me mimic site: http://mailchimp.com/2013/#by-the-numbers i've been able figure out every piece except white numbers. cool (but tricky) effect speed of count accelerates/decelerates depending on data-count attribute, though distance between sections same. it looks used waypoints.js differentiate between sections. searched plug-in adjust speed depending on data inputs, find ones countto.js trigger count, rather continuously count , down user scrolls. any appreciated! this intrigued me, gave shot. as far know, waypoints.js fires when element hits edge of viewport. don't think use kind of thing, because need continually update counter. wrote without jquery plugin. disclaimer: code may or may not work you, either way, please regard nothing more sketch of solution, still needs improved in several places used production site. var current = $('.step').first(); $('.step').each(function() { var start = $(this).data('c

javascript - HTML5 Canvas y-height not correct -

so i'm trying make simple animated hmtl canvas animated block moves around canvas using wasd. noticed painting rectangle on canvas of size 5,5 made looked rectangle of size 5,10. when testing redrawing function , printing console x , y location of element in canvas, noticed rectangle can go 1-300 in x direction, 1-150 in y direction. happens though canvas styled 300,300. can figure out if i've done silly? <!doctype html> <html> <head> <link rel="stylesheet" type="text/css" href="style.css"> <script type="text/javascript" src="script.js" defer></script> </head> <body> <div class="text-holder holder" id="instruction-holder"> <p class="text" id="instruction">use wasd navigate around viewer</p> </div> <div class="holder" id="canvas-holder"> <canvas

Convert pure javascript to jquery -

i want convert pure javascript jquery, code lines containing specified search text removed. here code: my code on jsfiddle: http://jsfiddle.net/v306rzhg/4 <body> search lines for: <input type="text" id="addfield0" value="sometimes|relevance|understand" style="width:100%; margin-top:10px;" /> <input type="button" style="margin-top:10px;" value="remove lines containing..." onclick="if(document.getelementbyid('addfield0').value!='') {removelines('containing');}" /> <input type="button" value="not containing..." onclick="if(document.getelementbyid('addfield0').value!='') {removelines('notcontaining');}" /> <textarea id="input_output" style="width:100%; margin-top:10px; height:150px; resize:none;" wrap="off">sometimes understand word's meaning n

python - adding a color theme in spyder in preferences -

i using spyder python coding. @ moment trying add color theme editor. there way can if have source code theme (i.e. pygment file)? thank you! if want change theme, edit spyder.ini, found in ~/.spyder2/.spyder.ini or c:\users\[yourusername]\.spyder2\.spyder.ini [color_schemes] section as described here :

ios - NSFetchedResultsController - deleting rows - How to get access to managed object before row deletion? -

i'm using nsfetchedresultscontroller display core data , have user generated images in ubiquitous documents container, each managed object fetchedresultscontroller displays. i've implemented swipe left delete functions on tableview, i'm having trouble accessing managed object before fetchedresultscontroller deletes object. need access delete user generated images in icloud container. here's function i'm using: func controller(controller: nsfetchedresultscontroller!, didchangeobject anobject: anyobject!, atindexpath indexpath: nsindexpath!, forchangetype type: nsfetchedresultschangetype, newindexpath: nsindexpath!) { switch type { case .insert: tableview.insertrowsatindexpaths([newindexpath], withrowanimation: .automatic) case .delete: tableview.deleterowsatindexpaths([indexpath], withrowanimation: .automatic) default:

java - How do I shift the contents of an array a la Super 2048? -

more specifically, how shift contents of array this: [2 0 2 8] into this: [0 0 4 8] edit: shifting, mean game of super 2048 . think of array 1 row in 4x4 game. when enter command 'shift right', left number number equal it, element 0 being equal element 2. number in element 0 become 0 , 1 in element 2 add 4. if number fails find equal number, stops left of different number. i tried manipulating array's elements directly code below, had no success. for(int col = dimension-2; col >= 0; col--) { for(int tgtcol = col+1; tgtcol < dimension; tgtcol++) { if(initialstate[tgtcol] == initialstate[col]) { initialstate[tgtcol] += initialstate[col]; initialstate[col] = 0; } /*if(initialstate[tgtcol] == 0 && initialstate[col] != 0) { initialstate[tgtcol] = initialstate[col]; initialstate[col] = 0;

java - Passing context from class extends thread -

before, using kelas1 extends service , , code worked read inbox. don't know how work if class using kelas1 extends thread . sms.inbox(kelas1.this,localdataoutputstream); and code: kelas1.java public class kelas1 extends thread { public void run() { //code while (true) { charsread = in.read(buffer); if (charsread != 1) { string message = new string(buffer).substring(0, charsread).replace(system.getproperty("line.separator"),""); log.d("wew", message); // problem sms.inbox(kelas1.this,localdataoutputstream); } } readsms.java public class readsms { public void inbox(context context, dataoutputstream outstr) throws ioexception{ uri urismsuri = uri.parse("content://sms/inbox"); cursor cur = context.getcontentresolver().query(urismsuri, null, null, null,null); string sms = ""; int body = cur.getc

javascript - socket.on not working for things I write? Help? It only works for disconnect. -

client: var socket = io.connect(); socket.on('some stuff', function(){ console.log("please please work."); }); server: var io = require('socket.io').listen(app); io.sockets.on('connection', function(socket){ console.log("yay, tab opened!"); socket.on('disconnect', function(){ console.log("aww, tab closed. "); }); socket.on('some stuff', function(){ console.log("did work? idk."); }); }); app server irrelevant. when run it, part works tab open tab closed part. when open localhost , go on there, says "yay tab opened" in windows console. (and when open more tabs, says message every tab open). when close tabs, says aww tab closed message every tab close. but when trying add own function, doesn't care log in. realize i'm not doing function yet, need later on. want know why it's not logging it. disconnect works, "some stuff" doesn't work. why n

php - Unregistering sidebar in child theme with no id -

i have child theme changes parent theme's footer (widget area). copied footer.php , changed include new footer registered/ativated in child's functions.php i use unregister_sidebar( ' ' ); code remove other sidebars parent. problem: footer widget area parent defines has no 'id' can't target unregister code. parent side-bar codes follows function web2feel_widgets_init() { register_sidebar( array( 'name' => __( 'sidebar', 'web2feel' ), 'id' => 'sidebar-1', 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h1 class="widget-title">', 'after_title' => '</h1>', )); register_sidebar(array( 'name' => 'footer', 'before_widget' => '

Rolling back a migration in Ruby on Rails -

i working on first ruby on rails project, , have created "users" table app using "rails generate scaffold users" command. now trying undo statement wish try rewrite classes involved class , table in database. i saw scaffold statement created "def change" class in migration, , when try rollback migration there no function within migration. added "def down" method "drop_table :users" defined within it. def down drop_table :users end however, when run "rake db:rollback", there no response in command prompt , table unchanged. i not quite sure how undo migration rewrite table schema. can offer assistance please? the whole migration looks following: class createusers < activerecord::migration def change create_table :users |t| t.string :name t.string :password_digest t.string :email t.timestamps end end def down drop_tabl

javascript - Firebase: How do I retrieve records from my data for which a specific key exists? -

i have data in firebase looks this: "application": { "companies": { "firebase": { "creation": { "name": "firebase inc", "location": "usa" }, "google": { "creattion": { "name": "google inc", "location": "usa" } } "facebook": { }, "apple": { } } } } there tens of thousands of records under companies key. how efficiently execute following queries? how query records key creation present under name? how query records not have key creation present under name? i want call .on('child_added') on returned result set can process specific records later on. possible? edit: simpler way without using parameter queries here queries without having use parameter: find companies without creat

ios - Custom ViewController Transitions: Get ToViewController's Subview's Frame -

Image
here's illustration of question: i have starimageview s in viewcontrollers & b displays same image have different frames each other in viewcontroller. when starimageview in viewcontroller tapped, app pushes new view controller navigation controller stack , @ same time, animates final frame in viewcontroller b. this behaviour transition in iphone photos app. how i'm doing now i initialise temp uiimageview in animator object initial starimageview's frame , image in viewcontroller a, , animate final frame hard-coding rect cgrectmake(0, 60+44, containerview.bounds.size.width, containerview.bounds.size.width) (frame of starimageview in viewcontroller b), , removing temp uiimageview superview in animation completion block. how wish instead the project created in storyboard autolayout enabled. wish frame of starimageview in viewcontroller b during transition rather hard-coding above. due viewcontorller lifecycle, unable reference subviews in viewco

Multi form validation through parsley.js -

i facing in asp.net while implementing parsley.js. having master page in there form tag pass data-parsley-validate. in slave page there 3 forms in 2 optional user fill . when applied validation , user clicks on submit button . parsley validation occurs on 3 forms . want occur on single form. asp.net support 1 form tag form . how can apply validation on 3 blocks individually.

bash - Torque PBS passing environment variables that contain quotes -

i have python script. run this: ./make_graph data_directory "wonderful graph title" i have run script through scheduler. using -v pass arguments python script through qsub. qsub make_graph.pbs -v args="data_directory \"wonderful graph title\"" i have tried many combinations of ', ", \" escaping , can't right. quoting around 'wonderful graph title' either lost or mangled. here excerpt pbs script if [ -z "${args+xxx}" ]; echo "no args specified!" exit 1 fi cmd="/path/make_graph $args" echo "cmd: $cmd" echo "job started on `hostname` @ `date`" ${cmd} what proper way pass string parameter contains spaces through qsub environment variable? there better way this? maybe more general bash problem. update: answer based on sge qsub rather torque qsub , cli different. in particular, torque qub doesn't seem support direct argument passing

PHP - get project directory path on MacOsX apache -

Image
i'm getting different results while retrieving root directory path of project folder under different environments: phpstorm8 browser debugger , mac osx apache2 php version: 5.6.6 apache: server version: apache/2.2.26 (unix) my mac osx apache directory /library/webserver/documents/projectfolder i'm using phpstorm8 , workspace directory /users/myname/documents/workspace/php/projectfolder my folder structure this: -projectfolder/ -config/ config.php - subfolder index.php index.php below snippet on how getting root directory of project echo "document_root:" . $_server['document_root']; under phpstorm8 debugging environment, i'm getting: document_root:/users/myname/documents/workspace/php/projectfolder in mac osx apache, i'm getting: document_root:/library/webserver/documents why in mac osx apache, i'm not able root directory of project folder? in mac osx apache: in phpstorm8 in built apach

input - Image not displayed after camera click on some of the android devices -

i using camera in website, in mobile phone browser having problems, in of phone browser after clicking camera, image not displayed, show blank image icon. can u plz find out problem in code? (function () { var takepicture = document.queryselector("#take-picture"), showpicture = document.queryselector("#show-picture"); if (takepicture && showpicture) { // set events takepicture.onchange = function (event) { // reference taken picture or chosen file var files = event.target.files, file; if (files && files.length > 0) { file = files[0]; try { // window.url object var url = window.url || window.webkiturl; // create objecturl var imgurl = url.createobjecturl(file); // set img src objecturl

Using a type of a parameterized data type in a Haskell function -

let's have algebraic data type in haskell: data foo = ... i'd have function "extract" type a , it, assuming satisfies conditions. specifically, need like: fun :: bounded => foo -> with intended usage follows: fun foo = maxbound :: of course notation incorrect in haskell, think intentions clear. possible this? you don't need anything, works. fun :: bounded => foo -> fun _ = maxbound the compiler knows result of fun a , therefore call correct maxbound .

qt - QUrl and QNetworkReply errors -

using qt 5.4 32-bit on windows 8.1 (64-bit) mingw. i experiencing weird problem. consider this: //qstring m_surl = "cloud.mysystem.info/"; //qstring m_sfilename = "results.html"; //qnetworkaccessmanager m_manager; qurl url(m_surl + m_sfilename); url.setscheme("ftp"); url.setusername(m_slogin); url.setpassword(m_spassword); qfile *file = new qfile(m_sfilename); if(file->open(qiodevice::readonly)) { qnetworkreply *reply = m_manager.put(qnetworkrequest(url), file); connect(reply, static_cast<void (qnetworkreply::*)(qnetworkreply::networkerror)>(&qnetworkreply::error), this, &ocmresults::error); connect(reply, &qnetworkreply::finished, reply, &qobject::deletelater); connect(reply, &qnetworkreply::finished, file, &qobject::deletelater); } else file->deletelater(); at first code worked fine stopped working (possibly due change, not sure it) , workaround when write url explicitely: qnetworkre

java - Intellij error with "add non-palette componente" -

when try add non-palette component in intellij 14.0.3 error: forms added palette must have binding top-level component the component try add tab of scrollpane, class extends jpanel. i can not understand why error. other classes not give me problems. the error remains if select 2 options. you may add form pallet , place component on form. to open in designer form want custom component. click right on group (e.g. swing) , select "add component palette". after can open form , place newly added component on it.

How to connect MySQL to PHP? -

so i'm brand spanking new mysql , php. i'm set mysql workbench , i'm practicing building site using notepad++ , run through chrome. want create sign page, i'm assuming use .php page on site, username , password. that's it. can't seem find tutorials on how connect mysql .php page, or how create sign in page. appreciated! welcome php! typically connection established on php page along lines of this: $conn = mysqli_connect("localhost","[username]","[password]","[databasename]") or die("error " . mysqli_error($conn)); the "or die" produce error if there's problem establishing connection. also, uses newer "mysqli_" method connection; make sure when call connection in future use mysqli_ methods (there still traditional "mysql_" methods available, depreciated). hope helps! m

How to link scss file with style sheet link tag in Ruby on Rails -

<%= stylesheet_link_tag 'main', media: 'all', 'data-turbolinks-track' =>true %> ruby on rails seems assume it's main.css , throw error. how link correctly main.scss ? only application.css.scss precompiled default. files required through file compiled. normally, request other files within file using either *= require_tree , *= require_self or @import . if still want explicitly include main.css.scss using stylesheet_link_tag in question, need add list of precompiled assets in config/initializers/assets/ so: rails.application.config.assets.precompile += %w( main.css )

JavaScript function that alternates YouTube embed sources? (No iframe) -

the intention upon clicking button youtube video embed code (without iframe) generate youtube video embed code - here html: <p><button onclick="philscode()">click here!</button></p> + <div id="video0"><embed src="https://www.youtube.com/v/dp_zpemrjxy" wmode="transparent" type="application/x-shockwave-flash" width="200px" height="140px" allowfullscreen="true"></div> i need embedded youtube video (above) replaced youtube video. don't want have use jquery either. here javascript have currently: <script> var embedcodes = ["https://www.youtube.com/watch?v=0vxq6k6ylm0"]; function philscode() {document.getelementbyid("video0").innerhtml = embedcodes [0]; </script> here demo http://embed.plnkr.co/phmnaqd2jqa4rh8itk0i <script> var embedcodes = ["http://www.youtube.com/v/xgsy3_czz8

javascript - onmouse out not working as needed -

what i've been trying have box, contains text , want whenever hovered, remove current content , add 1 , when hovered out, old one. , attempts realise not going well, know what's exacy problem. in advance. var i1,span1,a1,p1; function changecontent1() { var item = document.getelementbyid('item1'); var = document.getelementbyid('icon1'); var span = document.getelementbyid('itemspan1'); i1 = i; span1 = span; item.removechild(i); item.removechild(span); var p = document.createelement("p"); var t = document.createtextnode("the point of using lorem ipsum has more-or-less normal distribution of letters, opposed using 'content here, content here', making readable english. many desktop publishing packages , web page editors use lorem"); var = document.createelement("a"); a.href = "#"; p1 = p; a1 = a; var @ = document.createtextnode(&quo

java - How to check that @Async call completed in Spring? -

im using @async annotation method execute rsync command. there ten threads calling method @ time. requirement after ten threads complete rsync command execution remaining code should execute not getting how check whether ten threads has executed @async method or not? please tell me way check it if going return value, should wrap return value standard java se future or spring's asyncresult , implements future also. something this: @component class asynctask { @async public future<string> call() throws interruptedexception { return new asyncresult<string>("return value"); } } if have in place, in caller like: public void kickoffasynctask() throws interruptedexception { future<string> futureresult = asynctask.call(); //do stuff in parallel string result = futureresult.get(); system.out.println(result); } call futureresult.get() block caller thread , wait until async thread finishes. optionally can use futur

Multiple Boxplots in R specifying columns? -

i have had cursory search here answer seems knowledge of r limited , hoping me. i have dataframe have extracted larger data set (shown @ end of post) , create boxplot each row, specifying columns use (q1, min, max, median) etc. does know of way this? the dataframe looks this: delivered.median delivered.max delivered.min delivered.q1 delivered.q3 delivered_int.median delivered_int.max delivered_int.min delivered_int.q1 delivered_int.q3 delivered_empt.median delivered_empt.max delivered_empt.min 1 138 39752 47 74 289 138 39577 47 73 289.00 138 39752 47 2 157 13398 53 89 333 158 13334 54 89 335.00 157 13398 53 3 150 12301

python - From file to list -

hello guys trying read file digits put example(below) list[1,2,3,4] : 1 2 3 4 5 im doing in class. tried without class this: def velocity(): items = [] open('smhi.txt') input: line in input: items.extend(line.strip().split()) return items when print items ["1,","2","3","4"] you need convert numbers int ,and can use list comprehension following but,note define list inside function in local name space couldn't access outside of function!so need return list : def velocity(): open('smhi.txt') input: my_list=[int(line) line in input if line.strip()] return my_list result : [1, 2, 3, 4, 5]

angularjs - ng-class strange behaviour after after $compile -

i have made following directive: (function () { 'use strict'; angular .module('app.widgets') .directive('zzforminput', forminput); function forminput($compile) { // usage: // <div zz-forminput></div> function setupdom(element) { var input = element.queryselector("input, textarea, select"); var type = input.getattribute("type"); var name = input.getattribute("name"); if (type !== "checkbox" && type !== "radio") { input.classlist.add("form-control"); } var label = element.queryselector("label"); label.classlist.add("control-label"); element.classlist.add("form-group"); return name; } function addngclass(form, element, name, $compile, scope) {

JPA EntityManager Nullpointer exception (which shouldn't be!?) -

my ejb code: @stateless public class employeebean { @persistencecontext(unitname="eclipselink_jpa") private entitymanager entitymanager; public void createemployee(){ employee employee = new employee( ); employee.seteid( 1201 ); employee.setename( "gopal" ); employee.setsalary( 40000 ); employee.setdeg( "technical manager" ); entitymanager.persist( employee ); entitymanager.gettransaction( ).commit( ); entitymanager.close( ); } } basically, nullpointer exception happens @ line entitymanager.persist called, should not happen right? my persistence.xml file <?xml version="1.0" encoding="utf-8"?> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/