Posts

Showing posts from July, 2012

routing - Rails dynamic redirection -

i need create dynamic redirection model rails app. sort of similar wordpress redirection plugin, if have used anytime. http://wordpress.org/plugins/redirection/ what model store redirect_this_path string, , final_path should redirected to. if user comes app requesting redirect_this_path , redirected final_path . if however, there no matching entry found in database, request should forwarded other routes defined in routes.rb file. so, redirection model filter requests , redirect requests has data , relay other requests routes defined in routes.rb file. is there way can achieved, suggestions? you should this: (for example in application controller) def path_check if request.path == path_that_needs_redirecting redirect_to final_path end end then use: (in application or every controller need in) before_filter :path_check hope helps edit if have many paths need redirecting do if paths_that_need_redirecting.include? request.path

java - Video Thumbnailer App Android Issues -

i have problem android app i've wrote. the app accesses media store(of device) using specific folders , creates thumbnails of videos included in these folders, goes ahead , lists these thumbnails in listview. when install app on gingerbread or jelly bean device have no issues @ all. when install app in device running ice cream (api 15) app breaks. logcat can see app picking filename , foldername. have @ logcat, , please let me know of ideas or if have ever came accross error before : the link logcat here

android - Apportable & CoreMotion -

i'm trying game working on android. i've ported free version of apportable , works quite well, haven't been able implement gyroscope feature. cmmotionmanager gets initialized motion updates never start (or @ least handledevicemotion: never gets called). motion manager's isaccelerometeractive property no, isaccelerometeravailable yes. using [nsoperationqueue mainqueue] doesn't either. this how initialize motion manager: self.motionmanager = [[cmmotionmanager alloc] init]; self.motionmanager.gyroupdateinterval = .2; [self.motionmanager startdevicemotionupdatestoqueue:[[nsoperationqueue alloc] init] withhandler:^(cmdevicemotion *motion, nserror *error) { dispatch_async(dispatch_get_main_queue(), ^{ [self handledevicemotion:motion]; }); ...

javascript - Is there any solution to redirect facebook fan page after submission -

in facebook app, pull website form enter data. after submit form it's showing message. want re-direct facebok fan page. can't. used several method i'm going crazy :( <?php echo "<div class='success'><font color='green' size='5'>congratulation!. submited recipe. thank you.</font/></center></div>"; //header("refresh:5; url=fan_page_url"); //echo "top.location.href='fan_page_url'"; //header("refresh: 1;"); //header("location: fan_page_url"); ?> <script type='text/javascript'> window.location.href = 'fan_page_url'; </script> you may need this <script type='text/javascript'> window.top.location = 'http://www.facebook.com/fanapage'; </script>

html - Need to span my <td> across several rows, not working, using Razor syntax -

Image
here's code (look says rowspan="6" - not working: <table> <thead> <tr> <td>ingredient</td> <td>qty (gm)</td> <td>% of capsule</td> </tr> </thead> @foreach (var in model) { if (convert.todecimal(i.qty) < 0) { <tr> <td style="border: 1px solid red; color: red;">@i.ingredient</td> <td style="border: 1px solid red; color: red;">@i.qty</td> </tr> } else if (convert.todecimal(i.qty) == 0m) { continue; } else ...

entity framework - Code Based Code First Migration -

how implement code first migrations without package manager console commands. want implement code first migrations logic using code. don't want write following commands pm > enable-migrations pm > add-migration pm > update-database please tell me best practice. thanks in advance have @ using migrate.exe tool supplied when install ef package. http://msdn.microsoft.com/en-gb/data/jj618307.aspx you theoretically call code.

Store GitLab repositories on Amazon S3 -

is there possibility config gitlab can keep repositories on s3? i've found aws.yml , configured it, else should do? keeping repos on s3 not idea. it's better create dedicated ebs volume repo storage.

ios - UITableView change image on cell select and reset others -

i'd change uiimage inside uitableviewcell when user selects row. thats dificult. can in didselectrowatindex fine. however, , heres problem, want other cells (each cell has standard image) have standard image again. (if cells have standard image again, selected image should "marked" (meaning non-marked image replaced marked image, have code for) see checkbox know html . here attempt: - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { [tableview cellforrowatindexpath:indexpath]; [tableview reloadrowsatindexpaths:@[indexpath] withrowanimation:yes]; //little flashing animation [tableview deselectrowatindexpath:indexpath animated:yes]; [uiview animatewithduration:2.0f animations:^{ } completion:^(bool finished) { ; }]; //mark selected cell uitableviewcell *cell = [tableview cellforrowatindexpath:indexpath]; alog(@"%i", cell.imageview.tag); alog(@"%i...

android - edittext always gets back focus onFocusChange -

so code service call when edittext1 loses focus when click on edittext. focus same edittext1 everytime after service call. how can fix it. here code edittext1.setonfocuschangelistener(new view.onfocuschangelistener() { @override public void onfocuschange(view v, boolean hasfocus) { if(!hasfocus) { if (edittext1.gettext().length() >= 5) { searchtask = new searchtask(); searchtask.execute(edittext1.gettext().tostring()); } } } }); try call edittext1.requestfocus(); after searchtask.execute(...);

PHP HTML select box selected from MYSQL -

a simple code inserts list of teams in select box. set selected team id , in href http://localhost/teams.php?id=7&years=2011&cups=8 <?php $query = "select distinct t.team_id,t.team teams t,years y,cups c t.team_id=c.team_id , y.year_id=$_get[years] , c.cup_id=$_get[cups] order t.team asc"; $res = mysql_query($query); $option = ''; while($row = mysql_fetch_assoc($res)) { $option .= '<option value = "'.$row['team_id'].'">'.$row['team'].'</option>'; } ?> <form> <select id="tteam" name="team"> <?php echo $option; ?> </select> </form> the problem set team_id=$_get[id], shows 1 team. want team=7 selected, others still showing in select box please aware you're vulnerable sql injections. see: how can prevent sql injection in php? with said, need use conditional statement co...

php - How to get type from this array -

i have following array want type , (if set) amount value (default amount should 1). how do so? array(10) { [0]=> array(1) { ["type"]=> string(3) "empty" } [1]=> array(1) { ["type"]=> string(7) "beer" } [2]=> array(2) { ["type"]=> string(8) "beef" ["amount"]=> int(3) } [3]=> array(1) { ["type"]=> string(3) "wood" } [4]=> array(1) { ["type"]=> string(3) "cheese" } [5]=> array(1) { ["type"]=> string(3) "empty" } [6]=> array(1) { ["type"]=> string(3) "empty" } [7]=> array(1) { ["type"]=> string(3) "empty" } [8]=> array(1) { ["type"]=> string(3) "empty" } [9]=> array(1) { ["type"]=> string(3) "empty" } } edit: well, i've tried foreach, did before.. since no json anymore died foreach($json $ke...

java - How I can change default timeout for web services call on Google app engine? -

my google app engine application use web service, web service pretty slow respond , application crashes : java.net.sockettimeoutexception: timeout while fetching url: http://... to call web service, use classes generated wsimport (java tool parse existing wsdl file , generate required files). i need change default deadline (5 seconds) either call or globally app url fetches. app engine docs : you can set deadline request, amount of time service wait response. default, deadline fetch 5 seconds. maximum deadline 60 seconds http requests , 10 minutes task queue , cron job requests. when using urlconnection interface, service uses connection timeout (setconnecttimeout()) plus read timeout (setreadtimeout()) deadline. source : https://developers.google.com/appengine/docs/java/urlfetch/#java_making_requests i tried add lines (in strong below) in code change deadline did'nt work : url urlconnection = new url(url); urlconnection connection = urlcon...

breeze rejectChanges issue with unmapped properties -

in previous question , stated that: "on client unmapped property behaves in other respects mapped property" "rejectchanges() reverts property original value" i'm experiencing same issue described in question: entitymanager.rejectchanges() doesn't revert unmapped properties original value, while entityaspect.rejectchanges() does. in responses question, suggested due coding error. i've made plunker demonstrating issue. there error in code causing this? edit - updated test case: test("reject changes reverts unmapped property - unmapped property changed", 1, function () { var store = clonemodulemetadatastore(); var originaltime = new date(2013, 0, 1); var customer = function () { this.lasttouched = originaltime; }; store.registerentitytypector("customer", customer); var manager = newem(store); // create fake customer var cust = manager....

Is it possible to have type parameters (generics) on classes which are not collections in scala? -

as questions suggests. ever make sense think generics on non-collections? have been trying think through. collection 'wrapper' of other objects, there has 'wrapper' direct generic at? thanks yep. minimal example, here class wraps of type t , t generic: scala> class wrapper[t](val x: t) defined class wrapper if give int , it's wrapper[int] : scala> new wrapper(5) res0: wrapper[int] = wrapper@578ef2b6 if give string , it's wrapper[string] : scala> new wrapper("this") res1: wrapper[string] = wrapper@3b16bf07 this directly analogous collection of items of type t : scala> vector(1,2,3) res2: scala.collection.immutable.vector[int] = vector(1, 2, 3)

java - JUnit test from commandline -

i trying run junit 4 test commandline. current command: java -cp c:\users\some\.m2\repository\junit\junit\4.11\junit-4.11.jar junit.textui.testrunner c:\some\path\target\test-classes\com\wicket\range\ui\mytest.class this gives class not found error. i have tried following: c:\some\path\target\test-classes>java -cp c:\users\some\.m2\repository\junit\junit\4.11\junit-4.11.jar junit.textui.testrunner com.wicket.range.mytest.class this gives class not found error; issue here? i assume test class under c:\some\path\target\test-classes (in appropriate subdirectory). command has junit in it. need class path test , other dependencies. try java -cp c:\some\path\target\test-classes;c:\users\some\.m2\repository\junit\junit\4.11\junit-4.11.jar junit.textui.testrunner com.wicket.range.mytest.class

java - running batch statements in Oracle: sendBatch() vs executeBatch() -

i'm writing java code execute batch of insert statements oracle database. i've seen in of documentation ( http://docs.oracle.com/cd/b28359_01/java.111/b31224/oraperf.htm ) can use sendbatch() or executebatch() this. i'm little confused differences between 2 approaches are, or why choose on over other. maybe missed in readings. is there can explain differences are, , how can decide when should use 1 approach instead of other? sendbatch() oracle version of batching. oracle says using better fitting oracle , gives higher performance. oracle batching supports preparedstatement . executebatch() jdbc standard version. if program should jdbc compliant use method batching. might less performant (according oracle documentation), code compatible other jdbc drivers.

iphone 5 - How to build an ipa file from a xCode 5 project without developer membership? -

i have appsync ios 7 in jailbroken device, i'm looking export project ipa. is possible without having developer membership apple costs 99 dollars per year. no not possible install application on device development testing without apple membership account. because install application have make provisioning file , without membership account can not make provisioning file thanks.

inheritance - C# calling parent property while the child property is being called -

i wanna see if there anyway when child property method being called, call parent property well. note child generated code generator edmx. can't change except adding partial class child class. (it might trouble change generator.) the situation having : have class "myclass" automatically generated database. can't change on except adding partial class or change code generator. now, need "do something" whenever property name being called. thinking if can put parent there , make call parent "something" when child property "name" being called. what want : public class classbase { public string name { { callmethod(); return name; } } } public class myclass : classbase { public string name { get; set; } } myclass myclass = new myclass(); myclass.name; < -- call parent well. is there anyway it? thanks in advance not related since you're not...

mongodb - how does mongo select primary shard in cluster? -

have created 3 mongod , 2 mongos , single config server. while in sh.printshardingstatus(). says node primary one. how mongodb select primary shard hold un shard collection , can change primary one. the primary shard in new cluster first shard. see manual

c# - XAML designer can't load resource file at design time -

we have 2 products share resource dll project. there 3 different resource classes in dll. 1 shared backend, second 1 product , last 1 other product. one of products wpf windows application. application has static class called mycommands : public static class carsystemcommands { public static routeduicommand camerastatus { get; set; } public static routeduicommand cancelchanges { get; set; } . . . static carsystemcommands() { camerastatus = new routeduicommand( car.dashboard_camerastatus, "camerastatus", typeof( carsystemcommands ) ); cancelchanges = new routeduicommand( car.common_cancelchanges, "cancelchanges", typeof( carsystemcommands ) ); . . . } } everything compiles , run fine. now, have user control, call cameraconfiguration , in project uses same resource file. when view user control in xaml designer, displays fine. the cameraconfigurtaion user control included in user control, call settingse...

android - SDCard not accurate -

i working on basic music player obtain songs on sdcard. @ stages , i've encountered slight problem. whenever run app on phone gets songs on sdcard great. when run app on teachers phone gets internal storage directory , not sdcard path. have implemented environment.getexternalstoragedirectory , still returns content on interal memory. there way can fix problem?? oh , way teacher's phone samsung s3. so there no direct solution external sdcard path samsung s3? no. moreover, should not need it. "basic music player obtain songs" should using mediastore , not scanning external storage directly. not faster, on many devices, mediastore have indexed alternative storage locations (e.g., removable media) you.

java - IntelliJ - No such instance method -

using intellij's 12 ultimate, i'm running following code in debugger: java import play.api.libs.json.jsvalue; public class foo { ... public jsvalue tojson() { ... } public class fooexample { ... foo foo = new foo(); system.out.println("...); //<-- breakpoint at breakpoint, right-clicked source code , picked "evaluate expression," typing in: foo.tojson() . but following error showed up: no such instance method: play.api.libs.json.jsvalue$class.com.foo.foo.tojson () am doing wrong? foo#tojson calls scala code, if matters. edit had breakpoint after instantiation of foo. downvoted it, deserved it. edit my answer no longer valid after op modified question (i.e. moved breakpoint actual is).. a breakpoint hit before line executed. in case foo has not yet been declared or instantiated (i.e. foo constructor has not yet been called). you'll need put breakpoint @ next line (or step on current line) if want evaluate foo ....

python - Plotting candlesticks with tight resolution - understanding "width" parameters -

Image
i have been using tutorials candlestick data , work daily charts. however, i'm guessing since rely on default behaviour matplotlib.finance candlestick function, there pieces i'm missing in understanding switching intraday. my data looks (but convert date/time numbers prior call finance.candlestick) high low open close volume vwap 2013-09-18 18:05:00 126.343750 125.468750 125.468750 126.046875 721 126.285909 2013-09-18 18:10:00 126.296875 126.078125 126.078125 126.187500 271 126.194649 2013-09-18 18:15:00 126.234375 125.843750 126.234375 125.843750 83 126.157003 2013-09-18 18:20:00 125.984375 125.953125 125.953125 125.953125 505 125.953311 2013-09-18 18:25:00 126.250000 126.250000 126.250000 126.250000 1 126.250000 2013-09-18 18:30:00 126.250000 126.250000 126.250000 126.250000 0 126.250000 and code (stripped of attempts i've made) i'm using follo...

java - Maven build throws JodaTime Exception at runtime -

i'm building maven-based java application using corenlp 3.3.1. the salient pom.xml dependencies are <dependency> <groupid>edu.stanford.nlp</groupid> <artifactid>stanford-corenlp</artifactid> <version>3.3.1</version> </dependency> <dependency> <groupid>edu.stanford.nlp</groupid> <artifactid>stanford-corenlp</artifactid> <version>3.3.1</version> <classifier>models</classifier> </dependency> running mvn dependency:tree gives: [info] +- log4j:log4j:jar:1.2.17:compile [info] +- commons-logging:commons-logging:jar:1.1.1:compile [info] +- edu.stanford.nlp:stanford-corenlp:jar:3.3.1:compile [info] | +- com.io7m.xom:xom:jar:1.2.10:compile [info] | | +- xml-apis:xml-apis:jar:1.3.03:compile [info] | | +- xerces:xercesimpl:jar:2.8.0:compile [info] | ...

php - Skip values in case they are empty -

i need skip values in case, empty. data in database looks similary: gender : man hair : blonde eyes : blue figure : slim gender : woman hair : blonde eyes : blue figure : slim when use query: select * people figure = 'slim' , hair = 'blonde' , eyes = '' , gender = 'man'; it returns me nothing, because eyes empty. data form in php , empty data fields, user don't fill. can me, how can fix it? driver database use pdo. you need step through values 1 one: $sql = "select * people " $appender = ""; if ( !empty($gender) ) { $sql .= ( $appender . " gender = '" . $gender . "'"); $appender = " , "; } if ( !empty($hair) ) { $sql .= ( $appender . " hair= '" . $hair. "'"); $appender = " , "; } ... ...

javascript - Meteor js: separating front end from back end -

so whole point of meteor js allow user code whole stack @ once, if working on 1 of older frameworks django , borrow front end code meteor js ? example, front end syncing of database, templating, or how meteor handles events template, etc. is there way extract meteor js front end code used in framework? no, there's no such method. whole point of meteor (well, 1 of key points @ least) have 1 framework works both on front end , end. way don't have write 2 separate logic layers, nor additional layer communication between them. it's big advantage. that said, theoretically use meteor front end django end, provided talk server manually ajax , wrap data own reactivity. however, you'll end rewriting large part of meteor yourself. it'll easier either rewrite old django code in meteor, or use dedicated front-end framework backbone.

sprite kit - Why are image sizes doubled when added to an SKScene -

i've switched cocos2d sprite kit. i've come across annoying problem. image added skscene doubled in size. same thing both in sprite kit , cocos2d. here's cococs2d version: ccsprite *sprite=[ccsprite spritewithfile:@"w64.png"]; sprite.position=cgpointmake(100.0,100.0); [self addchild:sprite];// self ccscene and here's sprite kit version: skspritenode *sprite=[skspritenode spritenodewithimagenamed:@"w64.png"]; sprite.position=cgpointmake(100.0,100.0); [self addchild:sprite];// self skscene in first case image actual size in second case sizes doubled, both width , height. don't scale anywhere. have tried available skscenescalemode options, none of them help ahh, problem indeed naming of images @dobroucudni tapir said. mentioned before, didn't @ first. tried cleaning project , worked. wonder why have suffix images in sprite kit while don't have in cocos2d. if application retina displays only?

apache - Can mod_rewrite be used to find an older version of a file? -

say there 4 files on server contain dates in filename in way: file_2014-01-20.txt file_2014-01-03.txt file_2014-01-02.txt file_2014-01-01.txt ...and server receives request dated file doesn't exist: file_2014-01-10.txt ...is there way use mod_rewrite or other .htaccess code make find recent file older 1 requested? e.g. in case return file_2014-01-03.txt , since recent existing file older (nonexistent) requested file. i know redirect 404's special script this: rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.+) getarchive.php?request=$1 ...where getarchive.php take request , use find , return correct file. however, not solution me several reasons, , i'd redirecting entirely .htaccess without using server-side scripts @ if possible. edit: to put question way, given nonexistent filename, can apache used find next file in list, when sorted reverse-alphabetically . example: a.txt b.txt z.txt ...

Rails select tag with required true -

i have following select tag <%= f.select :id, user.find(:all, :conditions => ["manager = ?", false]).collect {|u| [u.username, u.id]}, {:required => true}, {:class => "multiselect", :multiple => true} %> i try add :required => true it, view renders :required => true doesn't work!. try this: <%= f.select :id, user.find(:all, :conditions => ["manager = ?", false]).collect {|u| [u.username, u.id]}, {:multiple => true}, :class => "multiselect", :required => true %>

pdf - Google CSE (Custom Search Engine) different search button and fields? -

i getting strange (to me) results when using google cse on site. background: the site has main search field (google cse #1 we'll call it).. set in google cse admin panel.. , set site wide search. i added page front end search directory of pdf's. i went google cse admin page.. made new entry pdf sub-directory.. pointed directory , child/sub-directories.. set return .pdf results.. outside of these 2 differences, both cse accounts/entries set-up identical. the problem or question have is.. the 'results' pages (while have same exact settings, search field on top of results, full row...single page..etc)..are different bit. the 'new' page results has tan colored 'ad block' on top of results.. , 'more importantly' results page search field looks different, , search button looks different, , has 'x' (close/clear) button right after it if settings same,.. how getting different looks? if pdf file type or confined sub-direc...

C++ array of linkedlist segmentation fault -

i trying fix method takes function takes root of linked list , number of vertices in graph , organizes linked list array of linked list based on first vertex of edge struct, example, in struct node edge has firvertex = 1, sndvertex = 2, , weight = 2, sorted first element of array. , node edge has firvertex = 1 appended onto previous one, , etc. have fixed many times still giving segmentation fault when running. thanks tips, appreciate it. unfortunately, cannot leave code since school assignment. the variable arraylist if declared local array. therefore is destroyed @ end of function , shouldn't returned. should allocate dynamically new: edge** arraylist = new edge *[numbervertices]; by way compiler (if correctly configured) should warn you. here g++ -wall does: bli.cpp: in function ‘edge** _()’: bli.cpp:5:9: warning: address of local variable ‘arraylist’ returned [-wreturn-local-addr] edge* arraylist[500]; also looks suspicious me: for (int i=0; i<nu...

flowlayoutpanel - VB.NET FlowControlPanel scrolling automatically when it shouldn't -

very strange issue in vb.net. have simple winform has flowcontrolpanel takes entire form except status bar @ bottom. if add enough items panel vertical scrollbar needed, scroll bottom, anytime update status bar panel automatically scrolls top. ever see this? thanks, mark

c# sqlite encoding utf8 -

i have strange problem (i have searched - common problem, don't find working solution). i'm using c# (.net 4.0) , sqlite. pragma encoding shows me utf8, want save data in encoding. tried use somelike this: private string toutf8(string input) { encoding ecdng = encoding.default; byte[] bts = ecdng.getbytes(input); ecdng = encoding.utf8; return ecdng.getstring(bts, 0, bts.length); //return input; } private string fromutf8(string input) { encoding ecdng = encoding.utf8; byte[] bts = ecdng.getbytes(input); ecdng = encoding.default; return ecdng.getstring(bts, 0, bts.length); //return input; } but doesn't work. use toutf8 when i'm going save data , fromutf8 when selecting data. second solution found is: private idbdataparameter addparameter(idbcommand command, string paramname, dbtype type, object value) { idbdataparameter parameter = c...

java - Huge Storage for Weblogic JMS Server -

in weblogic server (4 nodes) defined migratable jms server (oracle) database storage. here receive 1000 messages per second. every message xml message of 1kb. i might have need stop java mdb 1 day , store several gb of data (due maintenance). how can (with little overhead) save these messages compressed in order reduce space? there 2 possibilities, speaking main idea compress data: compress message: suggested oracle compress tablespace; not suggetsed oracle then let me suggest first solution; then, can enable weblogic compression or custom compression on producer , consumer. weblogic compression navigate jms connection factory -> click configuration > default delivery tab. on default delivery page -> default compression threshold custom gzip compression compress xml message before sending uncompress when receive for instance use following code on mdb extract text if producer compressed message or not; protected string gettext(...

javascript - Cant use arrows inside input -

hi did not make script, posting form, simple html, this html in input <input class="text_box" type="text" name="title" id="title" size="19" value="title" onkeydown="specialreplace(this)" onkeyup="specialreplace(this)" onblur="specialreplace(this)" onclick="specialreplace(this)"/> and specialreplace() function function specialreplace(o) { o.value=o.value.replace(/[^a-za-z0-9 áéíóúÁÉÍÓÚÜüñѨ´,.¿?%&$!¡ªº#"()-_\/]/g,''); } i try use arrows, go specific letter "edit" cant use arrows in input, why?? and how can solve this? why these inline handlers if using jquery? anyway, here's how it: html <input class="text_box" type="text" name="title" id="title" size="19" value="title"> js $(function () { //you have escaped - character in character class ...

php - Laravel Routes Based On MySQL Queries -

i'm trying build catalog of movies own , set route so route::get('movie/{name}', array('uses' => 'moviecontroller@showmovie')); with controller of class moviecontroller extends basecontroller { public function showmovie($name) { $movie = movie::firstbyatrributes(array('name' => $name)); return view::make('movie', array( 'movie' => $movie)); } } however, want name pulled database, instance if have table called movies, within table have, id, title , cover_art. when type myurl.com/movie/findingnemo display relevant information movie me without having create movietitle.blade.php every movie own. i can figure out view, it's routing i'm struggling with how can accomplish this? thanks! if change code following, should work myurl.com/movie/{movieid} pull movie want. seems make more sense me, titles have spaces , things make pain put url. so you're looking at: class moviecont...

oracle11g - Complex SQL Queries (self joins and left joins) -

i have 2 tables department , employees. department has department information , each row different department identified deptid , name deptname. within each row there deptheadid holds employee id of manager department. employees has employee information each row different employee identified empid, name name , each row has deptid points department table. i'm trying figure out how find out how list manager name , employee names each department. can list manager id number , employee name going manager id manager name stumping me. thank help. it same going employee department. of course, if use 1 "copy" of employee table, where clause ( employeeid = managerid ) filter out employees not managers, maybe must use more 1 copy. select .... employee empl1, -- use data of employees department dep, -- join empl1 find employee department employee empl2, -- join dep manager data

javascript - Splitting an audio MP3 file -

i split song using nodejs. have been looking module can process audio files, couldn't find purpose. how can split mp3 file using nodejs? you use ffmpeg. command line based, great since accessible, subprocesses can die. here node interface abstracts ffmpeg usage out of command line calls: https://npmjs.org/package/ffmpeg your final commands, in command line this: ffmpeg -i long.mp3 -acodec copy -ss 00:00:00 -t 00:30:00 half1.mp3 ffmpeg -i long.mp3 -acodec copy -ss 00:30:00 -t 00:60:00 half2.mp3 this command states: -i : input file long.mp3 -acodec : use audio codec copy : making copy -ss : start time -t : length and output file name to handle potentially timeouts/hung processes should 'retry' , supply timeouts. not sure how error callbacks work. fail appropriately on process hangs.

c++ - How do I suppress skipping in boost::spirit for parsing a quoted string? -

this question has answer here: boost spirit skipper issues 1 answer i'm trying implement simple parser using boost::spirit (among other things) accepts strings in double quotes, e.g. "hello, world". here's stripped down program illustrates issue: #include <iostream> #include <boost/iostreams/filtering_stream.hpp> #include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/support_istream_iterator.hpp> namespace qi = boost::spirit::qi; static void print(const std::vector<char>& v) { std::cout << std::string(v.begin(), v.end()) << '\n'; } template<typename iterator> class grammar : public qi::grammar<iterator, boost::spirit::ascii::space_type> { typedef boost::spirit::ascii::space_type space_type; qi::rule<iterator, space_type> start; qi::rule<iterato...

javascript - Using Jquery's .getScript is it possible to pass variables to your current script -

this question has answer here: how pass data external script loaded $.getscript()? 3 answers say have js file stores singular object. in js script need access object. can use .getscript or there way? when try use .getscript variables set outside of scope , update in getscript scope not update. given following html: <script type="text/javascript" src="jquery-2.0.3.min.js"></script> <script> var external = false; $.getscript('test.js', function(){ console.log(external); }); </script> and following script in test.js: var external = { my:'object' }; the log show {my:'object'}

Loop in Ruby on Rails running twice -

i'm going crazy. each-loop in rails runs twice each collection item. have no clue why. locations = location.all locations.each |loc| # delay not overload le webservice sleep 1.0 if [... webservice call - runs fine ... ] # score calculation - v0.1 score = [... formula calculate score ...] score_total = score + loc.score_total score_count = loc.score_count + 1 # update current record fresh values webservice loc.update(:temp1 => temp[0], :temp2 => temp[1], :temp3 => temp[2], :temp4 => temp[3], :temp5 => temp[4], :condition1 => condition[0], :condition2 => condition[1], :condition3 => condition[2], :condition4 => condition[3], :condition5 => condition[4], :score_yesterday => loc.score_now, :score_now => score, ...

c# - Getting the DateTime for the end of a certain day -

i have following datetime today = datetime.today; // or datetime.utcnow.date; now, can not in linq-ef because date can not translated sql: context.records.where(r => r.creationdate.date == today); so, this: datetime dayend = today.adddays(1).addmilliseconds(-1); context.records.where(r => r.creationdate >= today && r.creationdate <= dayend); now, there better way getting end of time datetime instead of adding 1 day taking 1 millisecond? the problem like datetime today = datetime.today ; context.records.where(r => entityfunctions.truncatetime(r.creationdate) == today) ; is underlying sql going this: select * some_table r convert(date,r.creationdate) == @today since column part of expression , sql engine unable make use of covering indices has available. unless you've got other criteria use indices, you're going table scan. , big tables, cause performance issue. and should avoid obvious datetime today = datetime.t...

input - Change form value= attribute with Javascript -

i need simple javascript change value= attribute 2 when page loaded. <input type="number" step="1" min="1" name="quantity" value="1" title="qty" class="input-text qty text"> addeventlistener('load', function() { document.getelementsbyclassname('qty')[0].value = 2; }); you first add event listener load event, runs after page's loaded within event listener's callback function, select element. in script, select class qty , since class seemed specific of three. should add id attribute input accurately select though. you first result, @ index [0] , , set value 2.

jquery - Modify more than 1 css file with javascript -

i'm trying find way modify css while html running, far find possible little script next... $("button").click(function(){ $("p").css("color","red"); }); as can concern effective way modify local css stylesheet refered our html while webpage running (i.e. pushing div button). what i'm trying modify specific .class css stylesheet of jquery plugin replacing standard right-click context menu. i didn't found way in js call specific stylesheet modify .class or #id so html had following definitions: <script src="jquery.contextmenu.js"></script> <link rel="stylesheet" href="jquery.contextmenu.css"> <link rel="stylesheet" href="localstyle.css"> but when try update custom jquery css script this $('#red').click(function(){ $('.contextmenuplugin').css({'background-color': 'white'}); .contextmenuplugin (native in ...

c# - Add MobileServiceCollection to ObservableCollection -

i want know how insert mobileservicecollection windows azure observablecollection json web service private observablecollection<addressdetail> _hererestaddressdetail = null; public observablecollection<addressdetail> hererestaddressdetail { { return _hererestaddressdetail; } set { this.setproperty(ref this._hererestaddressdetail, value); } } private async void updatetransportdetail() { try { webclient client = new webclient(); client.downloadstringcompleted += (s, e) => { if (e.error == null) { rootobjectdetail result = jsonconvert.deserializeobject<rootobjectdetail>(e.result); hererestaddressdetail.clear(); hererestaddressdetail.insert(0,result); } else { isfailed = visibility.visible; isfailedmessage = "can't data web server, please refresh , make sure internet data connect...

How to display the value a user puts into an "input="date"" box and clicks submit button using Javascript? -

i new javascript , have believe simple problem - i have area on main page want use javascript populate date user inputs "input="date"" field on 1 page. user clicks page, puts in date , hits "submit" button, , on main page, dedicated area grabs value , displays it. thank in advance help! thus far have: <div data-role="content"> content <input id="date" type="date" name="airdate"> <input name="buttonexecute" onclick="execute(document.getelementbyid('date').value);" type="button" value="execute" /> <script> var text = document.getelementbyid('date').value; </script> </div> ok if understood correctly, want: <div id='display'></div> <div data-role="content"> content <input id="date" typ...

xslt - Merge two xml ... again -

my knowledge xslt limited, i've googeled hours , trying many different scripts without luck. here plot: have xml database file on our server software read every time start software. 10 users use file. new entries stored in similar file locally, , need update server file include our new locally stored entries weekly. have made upload feature upload local files. uploaded file stored in directory above database file. name same both files, stored in different directories. here closest thing i've come with, copying former solutin site, changing names. exemple files here few entries testing purpose only. "original" xml: companyroutes.xml <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xml" href="merge2.xsl"?> <companyroutes> <route name="engmekch">engm oksat l996 svd ekch</route> </companyroutes> uploaded xml: /upload/companyroutes.xml <?xml version...

ios - UIKit Dynamics doesn't allow me to animate a UIView's centre -

i have uiview attached uicollisionbehavior . i'm trying animate center when new location tapped on screen, appears using block of code not way it: [uiview animatewithduration:0.7f delay:0.0f options:uiviewanimationoptioncurveeaseout | uiviewanimationoptionbeginfromcurrentstate animations:^{ [self.maincharacter setcenter:location]; } completion:nil]; can suggest more uikitdynamics friendly way of doing this? thanks. update so first part of question similar 1 posted , possible duplicate, however, although technically solved issue in first part of question, seem interfere how collision testing in uicollisionbehavior . the second part of question ask if there better way of doing this. assumed possible accelerate uidynamicitem @ speed on given time using uipushbehavior seems constant. can recommend how use uipushbehavior abov...

Find location of node in tree using Clojure zippers -

i have tree of unknown structure. first, want find node containing string of text, "something". then, after identifying string's location in tree, want update different node relative string's location . data nested map several branches of lists. is possible zippers? i've studied approach editing trees: http://www.exampler.com/blog/2010/09/01/editing-trees-in-clojure-with-clojurezip/ . problem is, don't beforehand know location of string. yes! kind of task zippers designed for. repeatedly call zip/next until find node looking for. then call zip/path find out relative root. then call zip/up , zip/down , zip/left etc node modify. update node call zip/root new map containing these changes.

javascript - how can i find the angle of a reflecting line? -

Image
i trying make game pong ( math bad , working on it) , trying bouncing ball part. i trying calculate out going(reflecting) angel of ball after hitting walls or pedals (the walls horizontal , pedals vertical) here image demonstrate better : here tried far: var m = (y2-y)/(x2-x); var angle = (math.atan(-m)*57.2957795); how ever not seem work. since obstacles vertical or horizontal, not need angle calculations. if store ball's position (x, y) , it's velocity (v x , v y ) can @ each frame compute next position (x + v x , y + v y ) to bounce horizontal border, negate v y , bounce vertical borders negate v x .

java - ConcurrentHashMap memory management or alternative? -

the memory of concurrenthashmap of java-websocket websocketclients values growing unceasingly. i've isolated section of code tries reconnect whitelist of peers every second. i've tested see if entries being removed after connection failure, , are. i've looked @ can find "concurrenthashmap memory leak". i have no idea how implement this possible solution . solution solve problem? if so, please provide example code. i tried implement this suggestion concurrenthashmap<string, myclass> m = new concurrenthashmap<string, myclass>(8, 0.9f, 1); and think slowed growth rate somewhat, have no idea how tweak it. correct approach? if so, please provide example code. i tried switching hashtable recommended here, concurrentmodificationexceptions immediately, think that's out. how can memory of concurrenthashmap implementation managed when there rapid insertion , removal of thousands of entries per second? if can't, there alte...