Posts

Showing posts from September, 2015

javascript - Js, document.getElementById("ID").innerHTML, error -

hello i'm new javascript, , i'm try write out code test site , i'm having problems, dow below code , keep getting error , can't figure out why. typeerror: null not object (evaluating 'document.getelementbyid("h3").innerhtml = "<h3>you date!</h3>"') this second method tried using. i'm trying have have version list first 1 had pull .js file , build table, didn't work thought try this, guess happened? not working my code i'm using below. if can amazing. thanks, dakmessier var current = "1.0"; function get_latest(){ document.getelementbyid("bob").innerhtml = current; } if (local != current){ document.getelementbyid("get").innerhtml = "<button><a href=\"bla\">get latest update!</a></button>"; } else if (local == current){ document.getelementbyid("h3").innerhtml = "<h3>you date!</h3>"; } else { document.g

jquery - jqGrid update specific column data with out refreshing the entire column? -

i using jqgrid in project . want update/refresh specific column data out refreshing entire grid. please give me idea that. here possible solution. can use 'setcell' in jqgrid set value specific cell in column. see fiddle here: https://jsfiddle.net/99x50s2s/4/ i hope above fiddle give idea complete task. <table id="sg1"></table> <div id="psg1"></div> <br> <button type="button" id="setcolumnbtn">update 'amount' column</button> jquery("#sg1").jqgrid({ datatype: "local", gridview: true, loadonce: true, shrinktofit: false, autoencode: true, height: 'auto', viewrecords: true, sortorder: "desc", scrollrows: true, loadui: 'disable', colnames:['inv no','date', 'client', 'amount','tax','total','notes'], colmodel:[ {name:'

javascript - Create a java script function in c# -

i'm developing winform application , want use google api v3 calculate barycenter of polygon. , have lng , lat in database. want call java script function in c# i'm new found using htmlelement can me here code tried doesn't give result. webbrowser webbrowser1 = new webbrowser(); string url = ("c:\\users/guenafai/desktop/topapplication/topapplication/baryscripts.htm"); console.writeline("je suis laaaaaaaaaaaa"); webbrowser1.navigate(url); htmlelement head = webbrowser1.document.createelement("head"); htmlelement scriptel = webbrowser1.document.createelement("script"); scriptel.setattribute("src","https://maps.googleapis.com/maps/api/js?key=aizasyaxby6ydvnzou0tk2rkrdmbnebn3gn1svk"); ihtmlscriptelement element = (ihtmlscriptelement)scriptel.domelement; string script = @" function baryc(){ var boundss = new google.maps.latlng

objective c - Is there a way in OCMockito to make stubs fail when an unknown method is called? -

when creating stub in ocmockito, use calls stub out method calls , return values: [given([stubobject mymethod]) willreturn:somevalue]; the problem have if don't define method method gets called during test, default seems to return nil . can lead sneaky bugs since real methods asserted never return nil , therefore return value not tested in code calling method. is there way change default behavior or maybe test if called on object apart few methods i'm stubbing? no, ocmockito stubs "nice". if want "strict" stubs, ocmock may suit better.

sql - Error using the DATEDIFF syntax -

i'm trying find age of employees sample database using code: select empno, firstnme, lastname, job, birthdate, datediff(hour,birthdate,getdate())/8766 age employee job '%r'; but keep getting error : "hour" not valid in context used.. sqlcode=-206, sqlstate=42703 this using ibm data studio 4.1. assuming you're using db2 , doesn't support datediff or getdate() . instead, subtract dates , use current date : select empno, firstnme, lastname, job, birthdate, (current date - birthdate)/365.25 age employee job '%r'

Pointers and recursive functions in C -

i have created list numbers. example: -3 4 -2 -1 4 5 the products of 2 continuous nodes -14 -8 2 -4 21 . want check if product of 2 nodes bigger product of following ones. used recursive function , in example treaty unsuccessful because 2>-4 . i want print message showing first node causes problem. in case -1 4th node. how return pointer showing wrong node? see questionmarks :) struct node* findnode(struct node *junc) { //success if(junc->link->link==null){ printf("success"); return null; } //failure if (((junc->content)*(junc->link->content))>=((junc->link->content)*(junc->link->link->content))) { printf("fail."); printf("\nfail because of numbers:%d %d.",junc->link->content,junc->link->link->content); return junc; } return(findnode(junc->link)); } i want check if product o

c++ - Why does the slash key "/" not have an ASCII value of 47? -

i have reassigned hotkey in our game use slash key "/", according ascii table should have value of 47. it's not firing. fires other standard keys. when step through code see keyeventrecord shows key value 191 or 111 if use slash on numeric keyboard. why so? need convert somehow? just clarification, store key value int. keyboards not know ascii. know scan codes , vendor-specific ids actual keys. when processed, scan codes normalized in vendor-independent virtual key codes . 191 vk_oem_2 (used /? key in keyboards) , 111 vk_divide . when dispatched ui windows, virtual key codes converted character codes in wm_char , wm_unichar messages. these human-readable characters, such ascii characters (though wm_char presents characters in ansi/utf-16 encoding, , wm_unichar in utf-32 encoding). so, processing keyboard events, such wm_keydown/up or readconsoleinput() , reporting virtual key codes when expecting character codes instead. for many ascii

android - How to transfer string data from main activity to another Activity -

this question has answer here: pass string 1 activity activity in android 5 answers i need make fragment (dialog box, whatever) content changes depending on user selects. means need transfer string data main activity activity responsible fragment. how do this? you can add extras intent use when starting activity inside of another. so, example, wherever handle users selection in first activity (let's call activity a) can send string activity b this: intent intent = new intent(activitya.this, activityb.class); intent.putextra("stringkey", "stringvalue"); startactivity(intent); the first parameter key used reference need, , value whatever string want passed next activity. then, somewhere in activity b can read string so: if(getintent().getextras().containskey("stringkey"){ string passedstr = getintent().getstringe

Batch File execution on remote windows server via batch file on another windows server -

i trying call batch file placed on remote windows server windows server. have freesshd installed on remote server. tried using putty/plink of no result. syntax of command using is: putty: start e:\putty.exe -ssh user12@serverip -pw "abcd12" call sample.bat plink: start e:\plink.exe -ssh user12@serverip -pw "abcd12" cmd.exe -m e://sample.txt i tried variants of above 2 commands "-m file.txt" etc. able execute batch file via login putty console not via calling batch file placed on windows server. this how start remote programs in windows. wmic /node:servername process call create "cmd.exe c:\\somefolder\\batch.bat" files executed way invisible on remote computer. for help wmic /? wmic process /? wmic process /? wmic process set /? wmic process call /? wmic process call create /? wmic process /node /? wmic process /user /? wmic process /password /?

c# - regex gets stuck with this call -

i'm working on movie scraper / auto-downloader iterates on current movie collection, finds new recommendations, , downloads new goods. there part scrape imdb metadata , seems stuck in 1 spot , can't seem figure out why.... has run same code different imdb pages fine (this 29th iteration of new page) i using c#! the code: private string match(string regex, string html, int = 1) { return new regex(regex, regexoptions.multiline).match(html).groups[i].value.trim(); } regex parameter string contents: <title>.*?\\(.*?(\\d{4}).*?\\).*?</title> html parameter string contents: big paste here, literally html string representation of http://www.imdb.com/title/tt4422748/combined if in chrome, can view with: view-source:http://www.imdb.com/title/tt4422748/combined i have paused execution in visual studio , stepped forward, continues run hangs (it doesn't let me step, runs). if hit pause again return same spot same parameter values

html - Auto resizing div with max width -

Image
i'm trying create div text resizes width depending on how text in div, has maximum width, splitting text multiple lines if exceeds max-width. text resize 1 line of text , split when there's much, when there's more 1 line large space appears inside div between right edge of text , border. html: <div class="balloon"> sample text. second sentence. </div> css: .balloon { background: #fff; border: solid 2px; display: inline-block; max-width: 225px; } here's demo demonstrate mean: http://jsfiddle.net/oft3n5wg/ any ideas how fix this? your updated fiddle this because first word on 2nd line large fit in space have highlighted in red. replace word "second" "seco" , you'll see fits you can add text-align: center space doesn't bad if want, or letter-spacing: 1px there's more space between letters , fill white spaces bit more

MySQL Find and Replace for Tablepress Plugin for WordPress -

i'm using tablepress plugin wordpress. i'm trying find/replace of 'http://' replace 'https://'. i've used search , replace plugin, not touch tablepress content. i know can write sql command search find/replace in phpmyadmin, not sql expert not sure how structure command. can help? thanks in advance!! update your_table set your_column = replace( your_column , 'http://', 'https://')

javascript - How to capture a click event on a shape or group in two.js? -

i have drawn shape using two.js , want write code handle click events on shape. not canvas, on shape itself. front_left.domelement = $('#two-' + front_left.id) .css('cursor', 'pointer') .click(function(e){ alert("hello world!"); }); this code taken answer seems should work: circle.domelement = $('#two-' + circle.id) .css('cursor', 'pointer') .click(function(e) { circle.fill = getnonmainrandomcolor(getrandomcolor()); }); but doesn't work me using latest jquery , latest two.js, , doesn't seem work in the example , since code reads if clicking on circles supposed make colour changes nothing happens on browser or computer i've tried. so, how can capture , respond click events of shapes/groups drawn two.js? thanks message. reason answer doesn't work anymore because two.js has changed since then. i've added example here . gist of that: use svg renderer when

media player - How to play Video on background with Android MediaPlayer? -

i creating program play video. first, created activity play video url using android mediaplayer . my issue when android's home button pressed, want play audio continuous (audio only), , when program, video must play continuous. have solution resolve issue?

git - Create a developer fork of non-Github repository -

i'd create developer fork (not checkout) of non -github repository. setup: main repository on machine x in /export/git/foo.git main repository has many branches. new bare repository created in /home/me/fork.git on machine x. want bring not branches main repository new repository. bring on branch histories new repository. want able bring new commits main new repository. bonus points spelling out how push commits new repository main without using patches. i searched site , internet did not see use case solved. git commands needed above? machine x linux box. here steps: clone new local repo of remote repo wish fork: git clone [source url] source_repo change created directory (source_repo). for every branch wish fork, do: git branch --track [branch name] add new remote repository: git remote add [dest repo name] [dest repo url] now push branches forked repository: git push --all [dest repo name] answer derived this .

csv - Google Chart data export -

when using google charts there's toolbar concept, seems work google drive spreadsheets (through 'datasource' parameter). there similar functionality allow export data when it's retrieved database in general? i've looked @ this , this , inconclusive.

Dynamically allocated string arrays in C -

i'm trying understand how dynamically allocated arrays work in c 99. anyways, have following code: int main() { char** members=malloc(4*sizeof(*members)); *members=malloc(5); *members="john"; *(members+1)="shouldn't work"; printf("%s \n",*members); printf("%s",*(members+1)); return 0; } i thought run time error because didn't allocate (members+1), did print both "john" , "shouldn't work", also, apperas the *members=malloc(5) line wasn't necessary. why? your assignments aren't doing think they're doing. when assign *members or *(members+1) , you're assigning char* each string literal, not copying allocated (or not allocated) heap memory. if instead replaced assignments strcpy , i.e.: strcpy(*members, "john"); strcpy(*(members+1), "shouldn't work"); then access violation on second assignment not first. likewise, reason

PHP, Shorthand, If..Else using Ternary Operators -

is there oneliner this? nice ternary op? $f_name = $_session['usr']['f_name']; if(isset($_post['f_name'])) {$f_name = $_post['f_name'];} basically "if post sent, show that, if post empty, otherwise grab value session, if post not set or empty" really splitting hairs here... looking this: $f_name = ? ($f_name ? isset($_post['f_name']) : $_session['usr']['f_name']); its supposed be: (conditions) ? true : false satisfies <--^ ^----> did not satisfy so equates into: $f_name = isset($_post['f_name']) ? $_post['f_name'] : $_session['usr']['f_name'];

java - Adapters not output image(android) -

sorry english. using adapter, , may wrong somthing using it. trying show image , textview output. textview coming in output, image not. please me, try many many times fix it. load image in downloadimagetask . in downloadimagetask have class imageloader , have used this tutorial . don't have error, have nothing( arraylist<news> arraylistnews; int resourse; context context; layoutinflater vi; public newsadapter(context context, int resource, arraylist<news> objects) { super(context, resource, objects); arraylistnews = objects; resourse = resource; this.context = context; vi = (layoutinflater) context.getsystemservice(context.layout_inflater_service); } @override public view getview(int position, view convertview, viewgroup parent) { viewholder holder; if(convertview == null) { convertview = vi.inflate(resourse, null); holder = new viewholder(); holder.imageview = (imageview) convertview.findviewbyid(r.id.ima

javascript - node.js C++ addon runing differently in Linux and Windows -

i started learning node.js , particularly c++ addon. modified hello world example little bit see how works. found out runs differently in linux , windows. basically, added internal function used cout output console. in linux, output is worldtest yes but in windows, is yes worldtest basically orders of outputs different. seems windows output expected be. ideas i'm missing here? thanks! hello.cc: #include <node.h> #include <v8.h> #include <string> #include <iostream> using namespace v8; using namespace std; string changestring(string tmp); void method(const v8::functioncallbackinfo<value>& args) { isolate* isolate = isolate::getcurrent(); handlescope scope(isolate); string tmp=changestring("world"); const char * c=tmp.c_str(); args.getreturnvalue().set(string::newfromutf8(isolate, c)); } void init(handle<object> exports) { isolate* isolate = isolate::getcurrent(); exports->set(string::newfrom

How would one locate following object [ul, li] in selenium webdriver? -

could me in figuring out how proceed locating "new" using selenium webdriver in java. code snippet: <ul class="ms-crm-commandbar-menu"> <li tabindex="-1" class="ms-crm-commandbaritem ms-crm-commandbar-menu ms-crm-commandbar-button" title="new create new account record." id="account|norelationship|homepagegrid|mscrm.homepagegrid.account.newrecord" command="account|norelationship|homepagegrid|mscrm.newrecordfromgrid" style="white-space: pre-line; display: inline-block;"><span tabindex="-1" class="ms-crm-commandbar-button ms-crm-menu-label" style="max-width:200px"><a tabindex="0" class="ms-crm-menu-label" onclick="return false"><img tabindex="-1" class="ms-crm-imagestrip-new_16 ms-crm-commandbar-image16by16" src="/_imgs/imagestrips/transparent_spacer.gif" style="vertical-align:top

Error on php mysqli_fetch_array() -

this question has answer here: mysqli_fetch_array()/mysqli_fetch_assoc()/mysqli_fetch_row() expects parameter 1 resource or mysqli_result, boolean given 33 answers <?php $connection = mysqli_connect( "localhost", "gari" , "gari" , "onlinemarket" ); $call = "select * products id ='". 4 ."'"; $result = mysqli_query( $connection , $call ); while ( $row = mysqli_fetch_array( $result ) ) { $call = "update products set stock = '". 666 ."' id ='". 4 ."'"; $result = mysqli_query( $connection , $call ); } mysqli_close( $connection ); ?> the real problem in $row = mysqli_fetch_array( $result ) , receive this: mysqli_fetch_array() expects parameter 1 mysqli_result, boolean given in c:\xampp\htdocs\tiendaonl

php - Font or Unicode issue on Scraping -

this question has answer here: php domdocument failing handle utf-8 characters (☆) 3 answers am trying scrape info site. the site have this 127 east zhongshan no 2 rd; 中山东二路127号 but when try scrap & echo show 127 east zhongshan no 2 rd; 中山ä¸äºè·¯127å· i try utf-8 there php code now please me solve problem. function grabpage($site){ $ch = curl_init(); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_useragent, $_server['http_user_agent']); curl_setopt($ch, curlopt_timeout, 40); curl_setopt($ch, curlopt_cookiefile, "cookie.txt"); curl_setopt($ch, curlopt_url, $site); ob_start(); return curl_exec ($ch); ob_end_clean(); curl_close ($ch); } $grabdata = grabpage($site); $dom = new domdocument(); @$dom->loadhtml($grabdata); $xpath = new domxpath($dom); $ma

Cygwin can't compile c with gcc -

i trying compile c program cygwin , gcc. using windows 8.1 i following error ... /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../lib/libcygwin.a(libcmain.o): in function `main': /usr/src/debug/cygwin-1.7.35-1/winsup/cygwin/lib/libcmain.c:39: undefined reference `winmain' /usr/src/debug/cygwin-1.7.35-1/winsup/cygwin/lib/libcmain.c:39:(.text.startup+0x7e): relocation truncated fit: r_x86_64_pc32 against undefined symbol `winmain' collect2: error: ld returned 1 exit status does know going on here? my code looks ... (taken link removed... page full of ads ) edit: link : http://c.learncodethehardway.org/book/ex14.html #include <stdio.h> #include <ctype.h> // forward declarations int can_print_it(char ch); void print_letters(char arg[]); void print_arguments(int argc, char *argv[]) { int = 0; for(i = 0; < argc; i++) { print_letters(argv[i]); } } void print_letters(char arg[]) { int = 0; for(i = 0; arg[i] != '\0

reporting services - How to show external images in the same folder as the SSRS report in Design Mode? -

hi using sql server data tools 2012 create ssrs (.rdl) reports. inserted image external rather embedded , actual image file put right next .rdl file within same local harddrive folder. the issue in design mode, image not show. in preview mode, image not show either until copy bin\debug folder. the above annoying report , image showing fine when both deployed onto report server under same path. any way make image shows in design mode , tell ssdt act smart copy image file debug folder? thank you is image uploaded on report server well? if yes, work in both preview mode , when deployed using following expression =iif(globals!reportserverurl = nothing, "http://yourserver/reportserver", globals!reportserverurl) + "?%2fimage%2fyourlogo.png" this example assumes have image name "yourlogo.png", located in "image" folder in report server. in visual studio, globals!reportserverurl null expression uses actual report server url l

javascript - Parsing retrieved localStorage item brings undesired result in console -

i making note web app using localstorage, when user submits note, values input , textarea saved in object. each note created object containing key/value pairs id: 0 title: value input content: value textarea after localstorage contains least 1 item string on in when new note created, get/retrieve localstorage string contain past entered notes in string format. parse localstorage string , save variable/array have prior notes add on to. push new input values saved input object each time, array before setting localstorage item array(stringifying of course). below function that's responsible saving note localstorage // user clicks save note post_note_button.onclick = function() { // values input , textarea var note_title = document.getelementbyid("note-title").value; var note_textarea = document.getelementbyid("note-textarea").value; // each time note created, new values input saved var input = { id: note_id_count

android - How to make progress bar of activity visible in fragment -

i defined fragement , loaded in activity, there progress bar in activity layout, how can make progress bar visible when in fragment how make progress bar of activity visible in fragment use getactivity().findviewbyid in fragment accessing views parent activity of fragments: progressbar progressbar = (progressbar) getactivity().findviewbyid(r.id.progress_bar_id); now use progressbar show , hide progressbar . note: make sure adding fragments in fragmentmanager after calling setcontentview in activity

sql - Fill automatic data in second table when insert data in one table -

i have 2 table table1 , table2 , structure of table as table1 primary key | name table2 primary key | table1_id_pk | status - true/false value when insert data table2 want automatically transfer data in table1 table2 have status false. you can create after insert trigger : create trigger datamigration on table2 after insert begin insert table1 select * table2 status = 'false' end go

c# - when will be the Item Saved(Rules) event fire in sitecore -

i working sitecore rules , created rule predefined conditions in item saved.i don't know how rule work , when item saved event fire.please can explain how rule work in item saved event you can extend onitemsaved handler actions on save event of item, such validate values, run rule or populate other fields. you need define rule in custom class perform logic, sounds have done. the final step add handler @ end of <event name="item:saved"> in <events> of web.config file. example below; <event name="item:saved"> ... <!-- add namespace name , dll --> <handler type="mynamespace, myassemblyname" method="mymethod"/> </event>

github - git go back to a previous commit before reset hard -

i changed code, ran git add . git commit -m "message1" but after that, did git reset hard git pull git push (the push did nothing, of course.) now want retrieve state of files @ point of commit "message1". how can that? git reset hard resets index (not working directory) state of branch called hard . nothing changed: can simple git reset reset index. nothing else has changed anyway. if did git reset --hard that’s different thing. reset index , uncommitted changes in working directory state of head, i.e. last commit of current branch. since made commit directly before command, lose nothing in case included changes of working directory in commit. if did not, you’re out of luck, , uncommitted changes never made index lost. the git pull fetch remote , merge changes branch, might have changed. since did commit locally, there 2 cases: date , nothing changed; there changes on remote , git created merge commit. in latter case, can revert usin

php echo javascript alert() not working -

i display popup message when user logged out, use echo "<script>alert(\"you logged out\");</script>"; but doesn't work. below coding. there logic problem in coding? <?php session_start(); if(isset($_session['username']) == "admin") { ?> <!doctype html> <html> <head> <meta charset="utf-8"> <style type="text/css"> @import "../css/style.css"; @import "../css/admin.css"; </style> <title>admin home page</title> </head> <body> <div class="body"></div> <?php if(isset($_get['id']) == "logout") { session_destroy(); echo "<script>alert(\"you logged out\");</script>"; header("location: ..\main.php"); } else { ?> <div class="menu"> <a href="managestaff.php">manag

Displaying Groupby data with Google Charts -

i want use google charts(stack bar) visualize data, has 2 string fields , 1 number field. data->[string,string,number] when try implement same getting following error " all series on given axis must of same data type " check data format barchart only first column may 'string'

android - SQLCipher can't open database after apprestart -

what i'm trying do in app i'm creating we're saving secret user data needs encrypted. we'd use sqlcipher. we've implemented in documentation. now i'm facing following problem. if create database first time can read , write db. if restart app i'm unable read database again , tons of errors. doing wrong? here's code of our sqliteopenheler: public database (context ctx){ super(ctx, database_name, null, database_version); try{ mkeysaver = new keysaver(ctx); file databasefile = ctx.getdatabasepath(database.database_name); if(databasefile.exists()){ sqlitedatabasehook hook = new sqlitedatabasehook(){ public void prekey(sqlitedatabase database){ database.rawexecsql("pragma kdf_iter = 5000"); } public void postkey(sqlitedatabase database){} }; mdb = sqlite

javascript - header checkbox not working first click -

hey have 2 view 1- index 2- edit i have grid header have 1 checkbox want click checkbox rows checkbox checkbox. in header checkbox not working first time when click uncheck check work fine. dont know why , problem in code please help here index view have script function check_uncheck() { $('#selectall').click(function () { if (this.checked) { $('.checkbox:enabled').each(function () { this.checked = true; }); } else { $('.checkbox:enabled').each(function () { this.checked = false; }); } }); } and here edit have checkbox <input type="checkbox" id="selectall" onclick="check_uncheck();" tabindex="3" /> if want select , unselect checkboxes of gridview row, can below:-

javascript - how to parse a JS usernames? -

my string is: "@john @jerry @kerry hello world" my goal obtain array: ["john","jerry","kerry", "hello world"]; infact @ marker username , last array item rest of string. any idea ? you can take rest of string , after can extract users , append last string in array. var data = "@john @jerry @kerry hello world"; // rest of string var laststring = data.match(/ \w+/g).join('').trim(); // users var array = data.match(/@\w+/g).join('').split('@'); array = array.slice(1,array.length); // add rest of string end of array array.push(laststring); var data = "@john @jerry @kerry hello world"; // rest of string var laststring = data.match(/ \w+/g).join('').trim(); // users var array = data.match(/@\w+/g).join('').split('@'); array = array.slice(1,array.length); // add rest of string end of array array.push(laststring); alert(array);

ios - Xcode keeps returning "fatal error: unexpectedly found nil while unwrapping an Optional value", when attempting to add an impulse -

i trying add impulse ball reffered in code, xcode keeps returning "fatal error: unexpectedly found nil while unwrapping optional value" class gamescene: skscene { override func didmovetoview(view: skview) { super.didmovetoview(view) let borderbody = skphysicsbody(edgeloopfromrect: self.frame) borderbody.friction = 0 self.physicsbody = borderbody physicsworld.gravity = cgvectormake(0, 0) let ball = childnodewithname(ballcategoryname) skspritenode ball.physicsbody!.applyimpulse(cgvectormake(10, -10)) } } i know late, have real solution! using this tutorial, i'm assuming. came across question while searching same issue. so xcode throwing error because ball you're referencing nil. reason because line: let ball = childnodewithname(ballcategoryname) skspritenode is referencing sprite .sks file name of ballcategoryname or "ball" . funny thing is: tutorial never told set name. so, can't find sprite named &quo

three.js - Changing easing parameters -

i have tweening function animate camera angle using "easing.elastic.out". how change period , amplitude of easing? camera.lookat(scene); var controls = new three.orbitcontrols(camera, renderer.domelement); function camtweenleft (startangle){ var prevangle=startangle; var tween = new tween.tween({angle:startangle}) .to({angle:startangle - 40*math.pi/180},1000) .easing(tween.easing.elastic.out) .onupdate(function(){ controls.rotateleft(this.angle-prevangle); prevangle=this.angle; }) .start() } check tween js documentation library used three.js not part of it. https://github.com/tweenjs/tween.js/blob/master/docs/user_guide.md the graphs example shows easing functions can have @ https://github.com/tweenjs/tween.js/blob/master/examples/03_graphs.html you can create own custom easing function.

Can We Configure txt file in Nginx Locaton -

i have server different type of project deploy . project in php ans in java war file jboss . using nginx layer working fine following configure for php project location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param script_filename /usr/local/nginx/html$fastcgi_script_name; include fastcgi_params; } location ~ ^/(images|javascript|js|css|flash|media|static)/ { root html/static; expires 30d; } location ~ attendance/(js|css|images)/ { # root html; expires 30d; } for java project server { listen 80; server_name ncmmi02; #charset koi8-r; access_log /mnt/vol1/nginx_logs/host.access.log; location / { root html; access_log off; proxy_pass http://10.20.9.13:9090; pro

java - Jsoup iterate over Elements causes duplicated output -

Image
i have page link extract data (i want tables' tds attributes). i used for-loop iteration via elements have extract attributes of . duplicated output. the output should output @ image on end of post document doc = jsoup.connect("http://www.saudisale.com/ss_a_mpg.aspx").get(); elements elements = doc.select("table").select("tbody").select("tr").select("td") ; for(element e:elements) { system.out.println(e.select("span[id~=label4]").text() + "\t" + e.select("input[id$=imagebutton1]").attr("src") + "\t" + "" + e.select("span[id~=label13]").text()); } this output them, duplicated!!! : the output should this:- would please try below code? elements description = doc.select("tbody"); doc=jsoup.parse(description.html()); description = doc.select("td"); for(int j =

What are differences between linux kernel compiled for generic x86/64 vs Xeon or others -

in linux kernel config there option change cpu family, precompiled kernels generic x86/64 . i have xeon e3 cpu wondering happen if pick core duo/newer xeon there. what differences here? there point in compiling kernel cpu family, instead of generic one? kernel optimized xeon work on non-xeon cpu's? did ever measured differences in performance , on? it select corresponding config option (from arch/x86/kconfig.cpu): config mcore2 bool "core 2/newer xeon" generally speaking, config_mcore2 enable compiler option -mtune=core2 on 32-bit builds , -march=core2 (it can found in makefiles arch/x86/makefile , arch/x86/makefile_32.cpu ). these options described in gcc manual page: -march=cpu-type generate instructions machine type cpu-type. in contrast -mtune=cpu-type, merely tunes generated code specified cpu-type, -march=cpu-type allows gcc generate code may not run @ on processors other 1 indicated. specifying -march=cpu-type imp

android - how to make a difference on Imagebutton click -

i design button in round shape using below code , want show text on button used frame layout , put text on button. challange button still.it doesnot show effect on click drawable , src both used 1 roundshape button , other image on button (respectivitly). now button doesnot make effect on design on click how make effect. <framelayout> <imagebutton android:id="@+id/btn_profile_view" android:layout_width="70dp" android:layout_height="67dp" android:layout_marginleft="20dp" android:layout_marginright="20dp" android:layout_margintop="20dp" android:layout_weight="1" android:onclick="comparebuttonclick" android:background="@drawable/roundedbutton" android:src="@drawable/ic_action_person" /> <textview android:layout_width="45dp" android:layout_height="20dp" android:layout_gravity="bottom" android:layout_marginleft="38dp" and

node.js - Running setTimeout and showing log in terminal -

i trying show the log using below code in terminal, showing 1 time, wrong in code ? i created file time.js below code settimeout(function() { console.log("settimeout: it's been 1 second!"); }, 1000); and running code in terminal this node time.js the output given below apples-macbook-pro:s3 apple$ node time.js settimeout: it's been 1 second! apples-macbook-pro:s3 apple$ while expecting settimeout: it's been 1 second! log every minute you should use setinterval method instead: setinterval(function() { console.log("setinterval: it's been 1 second!"); }, 1000); however, beware code dependent on event loopback , if have code occupies event loopback long, code may not execute every second ideally want to.

python - Sorting list by values -

i'm trying sort dictionary values code has been erroring. have 3 files consisting of scores (in format "bob:4", line breaks between each score. for k in d.keys(): nlist = d[k][-3:] v in nlist: nlist2 = max(nlist) sortd = sorted(nlist2.items(), key=lambda x: x[1]) print('{}: {} '.format(k, sortd)) this resulted in error "attributeerror: 'list' object has no attribute 'items'". what causing error? for revised question could: nlist2 = {k:max(d[k][-3:]) k in d} sortd = sorted(nlist2.items(), key=lambda x: x[1]) in sortd: print('{}: {} '.format(a[0], a[1])) or use -x[1] if want highest first

asp.net mvc 4 - The requested Performance Counter is not a custom counter, it has to be initialized as ReadOnly After installing of .Net Reflector -

i have installed .net reflector , after installation .net code not working given me 2 error could not load file or assembly 'ballytech.library.utilities.xmlserializers, version=14.0.0.14, culture=neutral, publickeytoken=null' or 1 of dependencies. system cannot find file specified. the requested performance counter not custom counter, has initialized readonly after uninstalled same issue persist, thanks

c - Why in XV6 the constant PHYSTOP is defined as 0xE000000? -

as far know, in xv6, phystop should 1gb. if so, phystop should 0x40000000 (1gb) , not 0xe000000 (224mb) appear in http://pdos.csail.mit.edu/6.828/2014/xv6/xv6-rev8.pdf : 0203 #define phystop 0xe000000 // top physical memory further more, in xv6, process might mapped 0 0x80000000(kernbase). is, process might use 2gb address space. how possible if phystop isn't 2gb? what missing? phystop constant defined 0xe000000 performance reasons. if phystop set higher, need map of free memory using mappages . oses today map free pages on fly, on xv6 map them on os initialisation. mapping 2gb slow. note change value before compilation bigger virtual memory.

visual studio - Git for TFS: opening 2 branches on the same time -

situation i have application on tfs git (2013) i need open source vs in 2 different branches @ same time on same pc. branch1 , branch2. my problem when launch branch1 (f5), run takes files in branch2 instead branch1. vs branch2 declared branch1 if has code source of branch2 what tried i copied branch2 code directory not git repository. solved nothing. don't understand git retrieve new location. i tried disconnecting vs tfs. what need doing job on same computer. need commit on branch1 any idea? i end creating opening alternative branch on vm not best solution, it's working

ruby on rails - Rspec - how to write a test for class method -

being new ror , rspec struggling write test scenario. # table name: countries # # id :integer not null, primary key # code :string(255) not null # name :string(255) # display_order :integer # create_user_id :integer not null # update_user_id :integer # created_at :datetime not null # updated_at :datetime # eff_date :date # exp_date :date i want test method in country model: def self.get_default_country_name_order countries = country.in_effect.all.where("id !=?" ,wbconstants::default_country_id).order("name") result = countries end in country_spec have this: describe country before(:all) databasecleaner.clean_with(:truncation) end let(:user){create(:user)} let(:country3){create(:country,code:"aus", name:"australia", create_user:user, eff_date: time.new(9999,12,31), exp_date: time.new(9999,12,31))} after(:all)

matlab - Using model arguments for a referenced model with inline parameters -

i having issues passing model arguments through referenced models contain inline parameters. my simulink model consists of 3 modelreference blocks refer same referenced model (let's call submodel ). submodel contains dozens of parameters should same in each instance , few want different each instance. currently, within model explorer, submodel workspace populated using matlab script. if add model arguments within model explorer , again @ modelreference block level error: 'model arguments can not used in non-tunable expressions. expression '(acc.vref)^2' in parameter field 'gain' of 'submodel/force transducer/gain1' can not tuned refers variables (acc (model argument))' so next logical step disable inline parameters, error: 'model 'submodel' referenced in normal mode , not have 'inline parameters' enabled. go optimization > signals , parameters pane of configuration parameters dialog model 's

phpmyadmin - Preserving character set when importing .CSV file to MySQL -

i want import .xlsx file ~60k rows mysql. columns contain vietnamese characters. managed convert .xlsx .csv without messing character set. can't same when importing .csv mysql. i used load data infile. looks this: load data local infile 'c:/projekt/big data/events.csv' table database.table fields terminated ',' enclosed '"' lines terminated '\n' ignore 1 lines; (source: http://blog.habrador.com/2013/01/how-to-import-large-csv-file-into-mysql.html ) this method imports data fine character set of vietnamese characters totally messed up. did change table's collation utf8_unicode_ci . i test traditional import method of mysql smaller datasets , preserves font perfectly. cannot use since file's size exceeds limit of mysql. really appreciate if me this. try explicit character set specify import: load data local infile 'c:/projekt/big data/events.csv' table database.table character set utf8 fields t

shell - Searching symbol patterns -

i trying use awk script: awk -v count=0 '/`),`/ { count++ } end { print count }' sample.sql but following error: error: awk: line 1: runaway regular expression /\),/ {.. why getting error , can fix it? the target count line backticks , closing parenthese like: insert test (`id`, `address`) values (1,'delhi'),(2,'mumbai') thanx @tensibai. added \ line ),. , works. .sql contain insert test ( id , nm ) values (1,'delhi'),(2,'mumbai'),(3,'chennai')...; so, did search ), starting count=1. have idea search better count.? if correctly understood try achieve (counting lines wich contain ), ) should do: awk '/\(`.*`\)`/ { count++ } end { print count }' sample.sql no need initialize variable, match line containing (` text here `) and increment counter printed @ end. as i've small doubt on original question here how count number of value in each line: awk '/\(.*\),/ { n=split($0

android - How to use getfiledescriptor with setdatasource -

how should pass in setsourcefile work correctly. want record , play audio concurrently. here code: public class mainactivity extends actionbaractivity { string outputfile; mediarecorder recorder; mediaplayer player; parcelfiledescriptor[] pfd; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); recorder = new mediarecorder(); pfd = new parcelfiledescriptor[0]; try { pfd=parcelfiledescriptor.createpipe(); } catch (ioexception e) { e.printstacktrace(); } } public void start(view v) throws ioexception { recorder.setoutputfile(pfd[1].getfiledescriptor());//this working recorder.setaudiosource(mediarecorder.audiosource.mic); recorder.setoutputformat(mediarecorder.outputformat.three_gpp); recorder.setaudioencoder(mediarecorder.outputformat.amr_nb); try { recorder.prepare(); } catch (ioexception e) {

scala/spark mapping [String,List[String]] to String pairs -

i have rdd structures of rdd:[string a,list(strings bs)] map rdd:[string a,string b] , each element in list matched string a. efficient way this? i using flatmapvalues , efficient way? (i have huge dataset) rdd.flatmapvalues(identity) should job done. that should pretty efficient , simple way. optimize performance, compare implementation using mappartitions , pick better of two. wouldn't expect huge difference in both cases wrapper objects need created anyway. rdd.mappartitions(iter => iter.flatmap(elem => elem._2.map(v => (elem._1,v)))

c# - Weighted Random Selection from a Sorted List -

i have problem in have large list of items sorted "weights". need able randomly select items list, items closer start (greater weights) must have greater chance of being selected based on "elitism" factor. i realize similar questions have been asked before, catch here list changing on time. new values sorted list last item deleted (to keep constant sized pool of "optimized" values). first off, efficient way of doing selection? selection must happen in real time list anywhere 50 1000 item long. second, best data structure use here? i'm using c#. thanks! i thought of possible solution, i'd feedback on idea. if generate random float value within range, , along lines of squaring it? small values return small values, , large values return larger values. can tell, mapping result length of list should give desired effect. sound right? create binary tree, sorted weight (sorting not required except it's specified in question), , eac

slim optional route parameter suffix not working -

i want define route have .suffix param in end. want use in app return user needs. eg .json or .xml or none!. how should define route? example address want: /user/all.json or /user/all.xml or /user/all # default json this route defined. it's not working expected. /user/:method(\.(:type)) in slim route segments defined forward slash, , not interchangeably dot. however, can either add logic route closure, or add route conditions multiple routes. in closure: $app->get('/user/:methodtype', function ($methodtype) { if ($path = explode($methodtype, '.')) { if ($path[1] === 'json') { // json... } elseif ($path[1] === 'xml') { // xml... } } }); or use route conditions, 1 each mutually exclusive: // json requests $app->get('/user/:methodtype', function ($methodtype) { // json... })->conditions(array('methodtype' => '.json$')); //

unit testing - How to reset the meta store with Hive on Spark? -

i want reset hive meta store hive on spark in unit test. so far, i've reconfigured jdo use in-memory derby db: system.setproperty("javax.jdo.option.connectionurl", "jdbc:derby:memory:metastore_db;create=true"); system.setproperty("javax.jdo.option.connectiondrivername", "org.apache.derby.jdbc.embeddeddriver"); there seems no proper life cycle management jdo in hive, hive/jdo complains if drop or shutdown database. does know of way reset meta store each test case runs fresh, clean meta store?

php - Return a JSON response in Laravel 4 from within a route model binding -

i'm creating api access blog entries, , rather laravel model binding returning 404 automatically, i'd rather return 200, , json in same format api controller returns. i use code below, when returning json response works within controllers, can't working within route::bind, instead json output follows: {"success":true,"data":{"headers":{}}} here code within app/global.php route::group(array('prefix' => '/api/blog'),function() { route::bind('blog', function($id) { $blog = blog::find($id); if (!$blog) { return response::json(array('status' => false, 'message' => 'blog not found'), 200); } }); route::get('index', array('uses' => 'blogcontroller@index')); route::get('create', array('uses' => 'blogcontroller@create')); route::get('read/{blog}', array('uses'

php - How to insert value of multiple selectbox in mysql using cakephp -

i'm new cakephp , try store value of multiple select box in mysql my controller file is:- $this->model_name->save($this->request->data); value coming in $this->request->data is:- array( [model_name] = array( ['field_name'] = array( [0] => 'a', [1] => 'b' ) ) ); i'm using same field name column name stored in database. tell me how resolve problem. try savemany() - $this->model_name->savemany($this->request->data);

css - Dropdown menu items hides behind main menu in bootstrap customized navigation bar -

Image
i trying create navigation bar in bootstrap. have added customized styles in bootstrap-theme.min.css file. way able created navigation bar dropdown menu items hide behind main menu in small screen devices. code , screenshots of output below: styles added in bootstrap-theme.min.css file: #custom-bootstrap-menu.navbar-default .navbar-brand { color: rgba(255, 255, 255, 1); } #custom-bootstrap-menu.navbar-default { font-size: 14px; background-image:url('https://s3.amazonaws.com/static.bizmerlin.net/bg_header.png'); background-repeat:repeat-x; background-size:100% 100%; border-width: 1px; border-radius: 4px; height: 40px; background-color: rgba(70, 131, 176, 1); } #custom-bootstrap-menu.navbar-default .navbar-nav>li, .navbar-brand { color: rgba(255, 255, 255, 1); background-color: #528cb4; height: 38px; border: 1px solid #ffffff; margin-top:4px; border-radius: 5px; margin-right: 6px; font-size: 14px; } #cu