Posts

Showing posts from March, 2015

node.js - How do I test child processes using chai and mocha? -

i'm creating framework execute processes @ specific time (cron-like) , test i'm using chai-mocha-grunt. the architecture of solution based on this example . basically, have: a master process, calls child (via child_process.fork) specific number of times. a child process, executes using setinverval(); a process call master.start() function. with architecture how test ensure threads executed @ correct time using mocha , chai (with 'assert' library)? in other words, how make chai 'listen' threads , check if executed @ correct time? i'm not sure need chai listen threads. if you're building off of example linked should pretty straight forward because master.js eventemitter , it's emitting events hears child processes. your test structure simple this: describe('forkexample test', function() { // set appropriate test timeout here this.timeout(1000); it('should stuff @ right time', function(done) { ...

WordPress Admin Loging 404 Error re .htaccess -

i've wordpress site hosted on openshift , can't access admin login page. when going /wp-admin or /wp-login.php pages 404 / "page not found" error. wordpress forum suggestions have advised deleting .htaccess file @ app's root , app shout reset file granting me access. because openshift uses different directory structure, can't find correct .htaccess file specific wordpress. can advise? your .htaccess file should still located core wordpress files, accessing server via sftp? viewing hidden files? should located in /app-root/data/current/

excel - Convert VBA code to run in vbscript -

this question has answer here: vba conditional formatting if cell not between 1 answer i have vba code conditional formatting. selection.formatconditions.add type:=xlcellvalue, operator:=xlnotbetween, _ formula1:="=$i$10", formula2:="=$j$10" selection.formatconditions(selection.formatconditions.count).setfirstpriority selection.formatconditions(1).interior .patterncolorindex = xlautomatic .color = 255 .tintandshade = 0 end selection.formatconditions(1).stopiftrue = false end sub i have vbscript creates excel sheet , need apply vba code cell in excel sheet created. having issues getting run. know need sub actual values excel constants there's more don't get what i've done far pricerange = "k"&rownum + 2 objworksheet.range(pricerange).formatconditions.add type:=1, operator:=2, formula1...

c# - DbUpdateConcurrencyException for tables with foreign keys -

Image
update: ahh! dumb error: had 2 instances of repository available, and, our implemntation requires provide connection string each repo, 2 repos pointing different databases, , adding entity 1 db another, , id not found in updated db. i'm running .net mvc 4.0, ef 5. implement repository pattern. in following delete method of webapi controller have following code: int userid = userhelper.getcurrentuserid(); datetime = datetime.utcnow; exhibitlinkrepository el = new exhibitlinkrepository(); el.setcase = caseid; exhibitlink link = el.all.singleordefault(l => l.id == id); //mark link deleted link.usermodified_id = userid; link.datetimemodified = now; link.deleted_flag = true; exhibitlinkrepository.insertorupdate(link); exhibitlinkrepository.savechanges(); where exhibitlinkrepository.insertorupdate : public void insertorupdate(exhibitlink exhibitlink) { if (exhibitlink.id == default(int)) { // new entity context.exhibitlinks.add(exhibit...

Missing last input in java -

with inputs such as; 1 2 3 4, arranged in column, code misses read last number. wrong? here code: public static void main(string[] args) { scanner sc = new scanner(system.in); while(sc.hasnextint()){ system.out.println(sc.nextint()); } sc.close(); } the problem 'sc.hasnextint()' since there isn't int after last entry, program not print it. if change call 'hasnextint()' 'hasnext()' code should work (as final newline character read). you'll note following code has blank space @ end of input string. similar , use while sc.hasnext(). on other hand, structure code differently don't print based on existence of next character/int in input string. import java.util.*; public class scannerdemo { public static void main(string[] args) { string s = "hello world! 3 + 3.0 = 6 "; // create new scanner specified string object scanner scanner = new scanner(s); while (scanner.hasnext()) { // check i...

php - Getting services from the command class -

how can service command class? have been trying use containerawarecommand parent of command class, , using $this->getcontainer()->get('my_service') , when run command in cli, following error: call undefined method symfony\component\console\application::getkernel() inside getcontainer() method of containerawarecommand class. the file through run command is: <?php require_once __dir__.'/../vendor/autoload.php'; require_once __dir__.'/appkernel.php'; use appbundle\console\command\changeemailcommand; use symfony\component\console\application; use symfony\component\console\input\argvinput; use symfony\component\debug\debug; $input = new argvinput(); $env = $input->getparameteroption(array('--env', '-e'), getenv('symfony_env') ?: 'dev'); $debug = getenv('symfony_debug') !== '0' && !$input->hasparameteroption(array('--no-debug', '...

objective c - How to draw a border around an NSTexturedSquareBezelStyle button -

Image
i noticed other day 1 of web pages looking ugly. buttons on page looked totally different , based on whether contained 1 line of text or two. after digging, i've learned typical button uses nsroundedbezelstyle , has fixed height. so, if text going wrap, firefox (and chrome , safari) change button use nsshadowlesssquarebezelstyle can have variable height. i'd petition maintainers of these browsers change , researching best alternative. after finding already-filed bug , doing reading, suggested maybe use nstexturedsquarebezelstyle instead. turns out in mavericks looks same nsroundedbezelstyle button. same in yosemite, except has no border. changing setbordered has no effect. so question, on behalf of browser developers everywhere: is possible draw nstexturedsquarebezelstyle button border ? or, there way around browser vendors have missed? rewritten answer i'm not seeing nstexturedsquarebezelstyle button showing borderless in yosemite: this stoc...

streaming - How to update Song name shoutcast in iOS? -

i'm trying create iphone app station on shoutcast. i'm using streamingkit( https://github.com/tumtumtum/streamingkit ) stream music i'm not sure how current song , artist name. has ever done before or knows how song name , artist? edit: trying https://github.com/alvarofranco/afsoundmanager now. you should registester kvo player this [playeritem addobserver:self forkeypath:@"timedmetadata" options:nskeyvalueobservingoptionnew context:nil]; then use update ui: - (void) observevalueforkeypath:(nsstring*)keypath ofobject:(id)object change:(nsdictionary*)change context:(void*)context { if ([keypath isequaltostring:@"timedmetadata"]) { avplayeritem* playeritem = object; (avmetadataitem* metadata in playeritem.timedmetadata) { //assign metadata nsstring info nsstring *info = [nsstring stringwithformat:@"%@", metadata.stringvalue]; mpmediaitemartwork *albumart = ...

ios - Mixing Blocks and Delegates in Objective-C -

this question has answer here: custom completion block own method [duplicate] 3 answers is possible run block when delegate receives message? for example, if had framework took void block parameter (we'll call "success" block), , using nsurlconnection delegate stuff method arguments, when receive response webpage, how can call "success" block passed in method parameters? this really hard me explain, , don't have code this, can clarify if have questions. you absolutely can. how all completion handlers / callbacks work. in fact, block for . to take simple example, consider nsurlconnection class method: + (void)sendasynchronousrequest:(nsurlrequest *)request queue:(nsoperationqueue *)queue completionhandler:(void (^)(nsurlresponse *response, n...

java - Reading Config File Contents -

i trying read "db_config_file.properties" file reason following error occurring: exception in thread "awt-eventqueue-0" java.lang.nullpointerexception @ java.lang.class.forname0(native method) @ java.lang.class.forname(class.java:186) my class handling reading of config file looks following: public class database { public static connection conn; public static void dbconnection() throws filenotfoundexception, ioexception, classnotfoundexception, sqlexception { properties props = new properties(); driver = props.getproperty("driver"); string url = props.getproperty("url"); string username = props.getproperty("username"); string password = props.getproperty("password"); string configfile = "f:/project/java project/src/mainscreen/db_config_file.properties"; inputstream ins = new fileinputstream(configfile); props.load(ins); cl...

visual studio 2008 - SSIS How To Extract Multiple .ZIP Files To Multiple Folders -

Image
problem/scenario: inside of directory have multiple .zip archives. each of these contain mulitple .csv files. need extract contents of each .zip archive directory of same name source .zip archive: c:\mydirectory\data1.zip extract files c:\mydirectory\data1 c:\mydirectory\data2.zip extract files c:\mydirectory\data2 i have foreach loop contains execute process task. task uses 7zip extract contents of each directory. task has following variables set: varzipsourcefolder = \\<server>\c$\mydirectory varzipdestination = \\<server>\c$\mydirectory\ varzipfilename varexepath = c:\program files\7-zip\7z.exe the problem of now, task runs , extracts files first archive successfully. however, when moving extract next .zip archive trying extract first directory created: c:\mydirectory\data1.zip extracting c:\mydirectory\data1 c:\mydirectory\data2.zip extracting c:\mydirectory\data1 below screen grabs ssis project in vs2008: foreach loop: execute pro...

ruby on rails - i dont understand how the devise admin model work -

i building rails app, , want users , admin (me), dont understand how devise admin model work, because if have have admin model, cant go link (/admins/sign_up) , sign_up admin on site? i have tried around on internet cant seem find answer. if can explain me how can on problem, love :d thank - peace if run rake routes | grep 'admin' see there no route admin/sign_up. admin user should created on rails console or within admin. when install devise (with migrations , all) creates default admin user email: "admin@example.com" , password: "password". you should login create real admin user , them delete default one. and here excellent devise tutorial: http://www.gotealeaf.com/blog/how-to-use-devise-in-rails-for-authentication :)

Loop Audio in Javascript Until Alert Dismissed -

i've been doing research , haven't found helpful explain/lead me in right direction. have far. works alert plays preset time. want play until "ok" button on alert clicked. thanks <script type="text/javascript"> setinterval(function(){ var old_count=<?php echo $arr['counter'];?>; var audio=document.getelementbyid('audiotag1'); $.ajax({ type : "post", url : "dbcheck.php", timeout: 4000, success : function(data){ if (data > old_count) { alert('new hot part has been entered.'); document.getelementbyid('audiotag1').play(); old_count=data; window.settimeout(function(){ location.reload(); }, 10000); } } }); },5000); </script> <audio id="audiotag1" src="alert.wav" preload="auto"></audio> ...

ios - Adjust frame of presented view in UIPresentationController after presentation -

i'm using custom presentation controller make similar uialertview . want move when keyboard shows. in uikeyboardwillshownotification handler, i'm grabbing new keyboard frame, storing in property, , calling: self.presentedview.frame = [wself frameofpresentedviewincontainerview]; in implementation of -frameofpresentedviewincontainerview , take current keyboard height account. this works perfectly, feels little dirty modifying frame of self.presentedview directly. tried triggering layout on container view various permutations of setneedslayout , layoutifneeded , nothing causes presented view move other setting frame directly. is there better way change frame myself?

c# - Nhibernate/linq query is extremely slow -

i updating project written in c#/wpf , makes use of nhibernate , sql server. when tested program noticed slow when retrieving specific list database. below data access code snippet: public static list<ticket> getlistfromperiod(datetime begindatum, datetime einddatum) { list<ticket> list = new list<ticket>(); using (var session = nhibernatehelper.opensession()) { using (var transaction = session.begintransaction()) { list = session.query<ticket>() .where(x => x.tijdstip.date <= einddatum && x.tijdstip.date >= begindatum).tolist(); } } foreach (var item in list) { item.issaved = true; } return list; } this little piece of code troublemaker , takes 90 seconds retrieve 558 objects: list = session.query<ticket>() .where(x => x.tijdstip.date <= einddatum && x.tijdst...

ios - Show array elements in textView (Swift) -

how can add elements array textview 1 second delay? language- swift (still relatively new programming) i think need class viewcontroller: uiviewcontroller { @iboutlet weak var textview: uitextview! var array = ["string1", "string2", "string3"] var = 0 var str: string = "" var timer = nstimer() func testfunc() { str += "\(array[i])\n" textview.text = str if == count(array) - 1 { timer.invalidate() } += 1 } override func viewdidload() { super.viewdidload() timer = nstimer.scheduledtimerwithtimeinterval(1.0, target: self, selector: selector("testfunc"), userinfo: nil, repeats: true) } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } }

Make Foundation columns span multiple "rows" of columns -

this incredibly dumb question, i'm @ loss on how make 3 sets of columns line foundation's grid. here's js fiddle html <div class="row"> <div class="medium-9 columns"> <div class="medium-4 columns" style="height: 250px; background: green;"></div> <div class="medium-4 columns" style="height: 250px; background: blue;"></div> <div class="medium-4 columns" style="height: 250px; background: red;"></div> </div> <div class="medium-9 columns"> <div class="medium-4 columns" style="height: 250px; background: yellow;"></div> <div class="medium-4 columns" style="height: 250px; background: orange;"></div> <div class="medium-4 columns" style="height: 250px; background: purple;"></div> </div> <di...

actionscript 3 - How can I convert string to boolean? -

i have code: trace(arr[0][2]); cb.selected = boolean(arr[0][2]); this outputs "false" checkbox selected. how can fix this? this expected behaviour. using the top level function boolean / explicitly converting different type . if argument non-empty string return true . why have string in first place? why don't store boolean values?

How to use an array of strings to handle the cases in a switch statement in C#? -

i have array public static string[] commands = { "command1", "command2", "command3", "command4", "command5", "command6", "command7" }; i want use array in function public static bool startcommand (string commandname) { //stuff if (commandname == commands[0]) { //stuff return true; } else { //stuff switch (commandname) { case commands [1]: //stuff break; case commands [2]: //stuff break; case commands [3]: //stuff break; case commands [4]: //stuff break; case commands [5]: //stuff ...

JQuery: scrolling stops before reaching element -

i'm using jquery's scrolltop scroll specific element but, weirdly, scrolling stops before reaching element. can have codepen have made. here's html: <div id="events"> <div id="event-list"> <div class="content"> <h2>vendredi 17 octobre</h2> <ul id="event-1" class="event-title"> list items </ul> <h2>vendredi 21 octobre</h2> <ul id="event-2" class="event-title"> list-items </ul> </div> </div> <div id="event-details"> <div class="content"> <section id="event-1" class="details"> stuff </section> <section id="event-2" class="details"> ...

c - How can a function create a struct? -

one of assignments c programming course define function called create_card. function receives suit character , card value, , returns card_t struct. question: how function supposed create struct? can't create values struct? did misinterpret meaning of question or assignment written down wrong? this example of function returning struct. struct test { int a; }; struct test fun(int k) { struct test d; d.a=k; return d; } replace struct test name of struct , definition of struct test struct's definition. how use int main() { struct test test=fun(6); printf("%d",test.a); // prints '6' return 0; }

c# - Visual Studio 2012 "Reset All Settings" Bug -

i´m having problem described in post: changing default enviromnent setting when starting visual studio 2010 my bigger problem cannot reset ide settings. if click on tools => import , export settings ... => reset settings => next window closes , nothing happens (i have started vs admin). i´m using vs 2012 premium. instead of trying reset settings, see if loading new defaults , overwriting old settings works you: tools => import , export settings import selected environment settings no, import new settings, overwriting current settings select [desired defaults] next finish

sql server - Entity Framework 6.1 - Code-First One-to-Many on single entity: Can't map PK to FK? -

i'm trying one-to-many on single table/entity using code first. entity looks , works fine: public class stockindex { [key] [databasegenerated(databasegeneratedoption.identity)] public int id { get; set; } [stringlength(45, minimumlength = 3)] public string name { get; set; } [stringlength(500)] public string description { get; set; } public list<component> components { get; set; } public stockindex parentstockindex { get; set; } public list<stockindex> stocksubindices { get; set; } public stockindex() { stocksubindices = new list<stockindex>(); } } it creates table pk , fk, you'd expect: create table [dbo].[stockindex] ( [id] int identity (1, 1) not null, [name] nvarchar (45) null, [description] nvarchar (500) null, [parentstockindex_id] int null, constraint [pk_dbo.stockindex] primary key clustered ([id]...

Run Registry File Remotely with PowerShell -

i'm using following script run test.reg on multiple remote systems: $computers = get-content computers.txt invoke-command -computername $computers -scriptblock { regedit /i /s "\\server\c$\registryfiles\test.reg" } the script doesn't error, registry entry doesn't import on of systems. i know test.reg file valid registry file because copied over, ran manually, , registry key imports. made sure powershell remoting enabled on remote computers. any ideas why registry key isn't importing? i found best way not mess issues related server authentication , cut down on complexity pass reg file parameter function. $regfile = @" windows registry editor version 5.00 [hkey_local_machine\system\currentcontrolset\services\tcpip\parameters] "maxuserport"=dword:00005000 "tcptimedwaitdelay"=dword:0000001e "@ invoke-command -computername computername -scriptblock {param($regfile) $regfile | out-file $env:temp\a.reg; ...

Possible to send Python code to RStudio console from knitr chunk like normal R code? -

i use r , rstudio lot @ university homework assignments. assignments along lines of: "proof theorem xy , implement solution in r". currently, rely on wolframalpha , maple symbolic computations, work in rstudio solve such problems. i know r has interface sympy called rsympy , there computer algebra systems ryacas. however, since rstudio can execute python scripts if stored in .py file , send them rstudio console, wondering if somehow possible use python code within knitr chunks engine="python" , send script rstudio console without having knit entire document? the workflow looking following: have .rmd file in rstudio chunk engine="python" import sympy , symbolic computations execute python chunk , see output in rstudio console (like 1 can normal r chunks) without knitting entire document ideally, possible access python results can convert them r formula etc. see link screenshot: https://www.dropbox.com/s/hn8azii7cji4suz/stackexchange_quest...

make error in OpenCV installation on ubuntu (ffmpeg CODEC_ID_XXXX was not declared in scope) -

i trying install opencv following this tutorial. through cmake.(the configuration given @ end.) make shows error : make[2]: ***[modules/highgui/cmakefiles/opencv_highgui.dir/src/cap_ffmpeg.cpp.o] error 1 1 link pointed out reason different version of opencv , ffmpeg, found piece of code in cap_ffmpeg_impl.hpp appears handling it. #if libavcodec_build >= calc_ffmpeg_version(54,25,0) # define cv_codec_id avcodecid # define cv_codec(name) av_##name #else # define cv_codec_id codecid # define cv_codec(name) name #endif not sure if ok commented. also, try installing ffmpeg seperately, not sure how dependencies handled in installation around libav. would thankful in solving problem, tips/links opencv installation in general. make configuration: -- general configuration opencv 2.4.11 ==================================== version control: unknown -- -- platform: -- host: linux 3.16.0-32-generic i686 -- cmake: ...

ant - How do i generate a junit report with fail -

i have junit testscript creates different , unique id. when finds existing id or wrong id want test script report via ant show failed following record passed rest of records correct. @test public void testcreatetrade() throws exception driver.findelement(by.id("vin")).clear(); driver.findelement(by.id("vin")).sendkeys(vvin); string str = driver.getcurrenturl(); if(str.contains("step1")) // existing id { driver.findelement(by.cssselector("body > div.bootbox.modal.in > div.modal-footer > a.btn.null")).click(); break; } driver.findelement(by.id("mileage")).sendkeys(vmileage); driver.findelement(by.id("odometertype")).sendkeys(vkm); driver.findelement(by.id("passengers")).sendkeys(vpassengers);...

java - Getting text from previous activity and adding it another activities list view -

how add items list dynamically when button clicked? text added listview . @ moment adds 1 item list view, , when try add changes added item in list. here code: this button on click activity gets text: schedule.setonclicklistener(new onclicklistener() { public void onclick(view view) { addschedule(); intent = new intent(scheduleactivity.this, mainactivity.class); string str = event_name.gettext().tostring(); i.putextra("myextra", str); startactivity(i); } }); then in activity b gets text activity b adds final listview listview = (listview) findviewbyid(r.id.listview); adapter = new arrayadapter(this, android.r.layout.simple_list_item_1, list); listview.setadapter(adapter); intent = getintent(); if (i.hasextra("myextra")) { list.add(i.getstringextra("myextra")); adapter.notifydatasetchanged(); } you...

jquery - Redirect after all nested AJAX requests are successful -

i working on feature uses ajax in case uses multiple optional nested ajax requests. cant seem figure out best approach perform redirect after ajax requests successful. idea run main ajax request , in success function call other ajax functions. please bear in mind nested ajax requests optional. $.ajax ({ type: "post", contenttype: "application/json; charset=utf-8", data: "{'articlename':'" + webname + "', 'title':'" + titlecontent + "', 'body':'" + content + "', 'categoryid':'" + $('.js-category-select').val() + "'}", datatype: "json", url: "/internal-service/service.asmx/editblogpost", success: (function (data) { var r...

objective c - iOS app crashes in Guided Access -

i work on team has developed app typical use case run uninterrupted in guided access indefinitely. in our last release, we've encountered 1 client has repeatedly encountered instances of devices appearing have our app 'crash home screen'. stated despite being on 'home' screen, devices (we told client, not onsite) still in guided access - didn't make sense until testing scenario ourselves, running special build force crash , observing results. found was: after 5 crashes of our app in guided access mode (and guided access re-starting app each time designed), guided access give , display keypad enter passcode leave guided access. if did not interact keypad after period of time (approx 1 minute), keypad go away, , 'home' screen displayed, user not interact view other swipe pagination of screen view second page of app icons. touching app launch result in animation recognize touch touched app not launch. device in bricked state requiring reset....

ruby on rails - How to use private submit with activities feed? -

how can give user option make activities private? give users privacy posts want eyes only. i told code isn't working because might have "not setting 'private' checkbox work correctly" , yet private checkbox works hiding submissions on public profiles (just not on activities feed). class activitiescontroller < applicationcontroller def index #added .public @activities = activity.visible.order("created_at desc").where(user_id: current_user.following_ids) end end class activity < activerecord::base belongs_to :user has_many :comments, as: :commentable belongs_to :trackable, polymorphic: true scope :visible, ->{ where(:hidden => false) } def visible? !hidden end end create_table "activities", force: true |t| t.boolean "hidden", default: false t.integer "user_id" t.string "action" t.integer "trackable_id" t.string "trackable_type" t.d...

android - Intel's HAXM equivalent for AMD on Windows OS -

is there equivalent of intel's haxm amd (windows os) or has been able hack haxm make work on amd processors (windows os)? also, genymotion ( http://www.genymotion.com ) faster compared default google apis arm / x86 system images provided google? my exact dev machine specs: os: windows 7 ultimate processor: amd fx 8120 8 core 2.81 ghz thanks in advance! from android docs (march 2016): before attempting use type of acceleration, should first determine if development system’s cpu supports 1 of following virtualization extensions technologies: intel virtualization technology (vt, vt-x, vmx) extensions amd virtualization (amd-v, svm) extensions (only supported linux) the specifications manufacturer of cpu should indicate if supports virtualization extensions. if cpu not support 1 of these virtualization technologies, cannot use virtual machine acceleration. note: virtualization extensions typically enabled through c...

osx - Is it possible to ignore a particular executable file using .gitignore? -

suppose myprogam executable file on mac result of compiling code this: gcc -o myprogram myprogram.c how can induce .gitignore file ignore myprogram file? i'm not looking solution make separate folder executable files. my question might seem obvious many cannot find solution online although i've searched few pages , tutorials stackoverflow resources. i'll grateful hints. add myprogram on separate line in .gitignore file

cryptography - File encryption using Android dev key -

i need download files web server. want avoid user can download files public address , use them. can encrypt content symmetric key, should store key in app. instead, use in way android developer key? in way app decrypt files. how can do? make sense?

c++ - Snake Game - Can't get snake body to follow snake head -

i have been working on snake game using sfml , c++ having trouble getting tail of snake follow snake head defined snake[0] in code below. have implemented code think should work doesn't following (int = 1; < snakesize; i++) { snakepartx[i] = snakepartx[i-1]; snakeparty[i] = snakeparty[i-1]; } the way understand (and incredibly wrong , appreciate if point out happening here) that, piece of code should set value of snake body part position of previous body part located when program loops set follow snake travels. what happen though when snake eats apple snake gain 1 block tail, not grow farther. in classic snake game, snake made of segments. each segment contains coordinate of segment (among other attributes). specifically, snake container of segments. container choice, recommend queue. with queue, new head segment added queue , tail segment removed. here's code fragment help: class snake_segment { public: int ...

javascript - Weird iframe loads src but displays blank in firefox and safari -

i'm facing weird issue can't seem figure. i'm using iframe in scroll box type widget, , loads fine in chrome. however, in firefox iframe loads displays blank 80%+ of time. , in safari, displays blank until move on cursor. what's driving me crazy shows correctly time time, has problem of time despite best efforts. any ideas why? the iframe loads in corner box scrolls 30% down page. here's outputted code of whole scroll box on page <div id="lf-widget" class="scroll-triggered-box stb stb-bottom-right" style="position: fixed; right: 0px; border-top-width: 7px; border-top-style: solid; border-top-color: rgb(52, 152, 219); margin-right: 20px; z-index: 9999; visibility: visible; background-size: 50px; padding: 0px !important; background-image: url(https://s3.amazonaws.com/asdfasdf/assets/load.gif) !important; background-position: 50% 50%; background-repeat: no-repeat no-repeat;" data-trigger="percentage" data-trigg...

javascript - Produce a bundle layout with a csv file -

i'm trying produce bundle layout , managed it. however, i'd able use simple csv field instead of json. i've tried replace d3.json d3.csv function can't make work. any idea? my code: http://plnkr.co/edit/0hwljmehnyjqhucpdw5w <!doctype html> <meta charset="utf-8"> <style> .node { font: 300 11px "helvetica neue", helvetica, arial, sans-serif; fill: #bbb; } .node:hover { fill: #000; } .link { stroke: steelblue; stroke-opacity: .4; fill: none; pointer-events: none; } .node:hover, .node--source, .node--target { font-weight: 700; } .node--source { fill: #2ca02c; } .node--target { fill: #d62728; } .link--source, .link--target { stroke-opacity: 1; stroke-width: 2px; } .link--source { stroke: #d62728; } .link--target { stroke: #2ca02c; } </style> <body> <script src="http://d3js.org/d3.v3.min.js"></script> <div> <script> var diameter = 480, // diame...

Most python(3)esque way to repeatedly SELECT from MySQL database -

i have csv file of customer ids ( crm_id ). need primary keys (an autoincrement int) customers table of database. (i can't assured of integrity of crm_id s chose not make primary key). so: customers = [] open("crm_ids.csv", 'r', newline='') csvfile: customerfile = csv.dictreader(csvfile, delimiter = ',', quotechar='"', skipinitialspace=true) #only 1 "crm_id" field per row customers = [c c in customerfile] so far good? think pythonesque way of doing (but happy hear otherwise). now comes ugly code. works, hate appending list because has copy , reallocate memory each loop, right? there better way (pre-allocate + enumerate keep track of index comes mind, maybe there's quickler/better way being clever sql not several thousand separate queries...)? cnx = mysql.connector.connect(user='me', password=sys.argv[1], host="localhost", database="mydb") cursor = cnx.cursor() select_c...

c# - Consolidating await statements -

i consolidate following statements 1 line. var x = await a.method1async(); var y = await x.method2async(); var z = await y.method3async(); is possible remove intermediate objects , have in 1 line ? you need parentheses: var z = await (await (await a.method1async()).method2async()).method3async();

ruby on rails - Method errors during before_save -

i'm sure missing simple, have been racking brain past few days on this. i have booking , review table, booking has many reviews. can create review, run through error when trying define roles of user leaving , receiving review. here models. review class review < activerecord::base before_save :define_review_role after_create :call_update_rating belongs_to :booking belongs_to :client, class_name: "user", primary_key: "client_id" belongs_to :talent, class_name: "user", primary_key: "talent_id" def define_review_role if review_sender_id === self.booking.client_id review_receiver_id = self.booking.talent_id else review_receiver_id = self.booking.client_id end self.update end def call_update_rating user = user.find(self.review_receiver_id) if review_receiver_id == self.booking.talent_id user.update_talent_rating(self.rating) else user.update_client_rating(self.rati...

php - Store bidimensional array from Javascript in Cookie -

first of all, that's reading , trying me! i got online shop , have bi-dimensional array products that: 1. $arrayproducts[id][0] -> id 2. $arrayproducts[id][1] -> product name 3. $arrayproducts[id][2] -> price etc.. i know isn't best way system, it's done that. now, want store bi-dimensional array in cookie, because want store cart user if go away page, , load again when come back. i think best way cookie, don't know if should json_encode , json_decode bi-dimensional array, or best way fix problem. before saving data cookie stringify array. var x = json.stringify(yourarrayvar); then save x in cookie.

Can someone give me a direction about using DNS to change location? -

i in uk, planning build personal dns server use usa netflix. can give me direction how use dns change location uk us? what if use https://unlocator.com/ ? i'm curious how doing personally, let without reinventing wheel...

java - Jsoup recove text from div without selector -

i have html code <div itemprop="doseschedule"> text1 </div> <h3><a id="sp3">title</a></h3> <div>text2</div> <div itemprop="warning"> text3 </div> and try recover text2, can't still. how can it? this code want: public class jsouptest { public static void main(string[] args) throws ioexception { string html = "<div itemprop=\"doseschedule\">\n" + "text1\n" + "</div>\n" + "<h3><a id=\"sp3\">title</a></h3>\n" + "<div>text2</div>\n" + "<div itemprop=\"warning\">\n" + "text3\n" + "</div>"; document doc = jsoup.parse(html); element e = doc.select("h3").first().nextelementsibling(); system.out.println(...

ElasticSearch sort order for multiple fields -

what best way specify sort order in elasticsearch multiple fields? query string format not seem work @ all: http://elasticsearch_url/index/_search?sort=field1:asc&sort=field2:desc&size=100 one sort first field1, field2, 1 of fields seems sorted correctly. full notations works better, first entries have wrong search order: curl -s -xget http://elasticsearch_url/index/_search -d ' { "sort": [ { "field1": { "order": "desc" }}, { "field2": { "order": "desc" }} ], "size": 100 }' apparently second, full notation works better. there problem 1 of fields contained urls, parsed in odd ways elasticsearch. normal string fields can difficult sort, indexing url in elasticsearch more difficult.

jquery - field with multiple classes will if statement match -

this question has answer here: jquery , if statement not matching because of multiple classes 3 answers if have field has multiple classes: <input type='text' class='req small inside' id='car'> <input type='text' class='req small inside' id='truck'> <input type='text' class='small inside' id='boat'> will if statement below match id car , truck? $.each($('.inside'),function(){ if ($(this).attr('class') == "req"){ //do something; } }); if alert($(this).attr('class') result req small inside car , truck , small inside boat you use .hasclass() check it. $('.inside').each(function(){ if ($(this).hasclass('req')){ //do something; } }); and in selector. // el...