Posts

Showing posts from February, 2012

php - I'm hitting a race condition in my Laravel application when trying to conditionally INSERT or UPDATE, any suggestions...? -

my users need able upload files site, i've implemented file uploader widget on frontend. allows multiple uploads @ once, , each upload triggers code 1 file @ time save file db. the problem files need stored array in single row in database (i know, know... legacy reasons). in english pseudocode, here's what's happening: laravel sees new file has been uploaded laravel checks whether or not files (at all) have been uploaded entity no files have been uploaded yet? create new record store file. there files entity? update existing record add file array. the problem when multiple files uploaded @ once in quick succession first time, laravel has entered first file in database moments after second file has conducted it's check see if files exist. end duplicate rows, rather updating them in single record. if upload 5 files @ once, typically i'll 4 rows in database - 3 single entries , 1 double-entry, managed catch in time. any practical ways around probl...

Regex Hive not working -

i trying extract 44 string created rsa key 45555 intelligent expense id 44|54?hotel?345555||||| using hive regexp_extract . the regex have (^\id\s)\d* , not working. can me please ^ marks beginning of string not case, because not start id . can use (id\s)\d* for capturing numbers after id , should use \d+ instead of \d* id\s(\d+) this capturing group can accessed using 1 mentioned here

iphone - AVAssetImageGenerator cancelAllCGImageGeneration doesn't cancelAllCGImageGeneration -

there doesn't seem info around avassetimagegenerator , less cancelallcgimagegeneration hope isn't bug. i'm calling generatecgimagesasynchronouslyfortimes , getting frames , if let process entire file. when cancelallcgimagegeneration ... ...it takes while cancel - strange, no big deal. ...it continues call completion block every frame requested, result avassetimagegeneratorcancelled - seems odd design choice , inconvenient. but major problem after series of calls avassetimagegeneratorcancelled starts calling avassetimagegeneratorsucceeded again. ideas? (i workaround setting flag when cancel, , ignore images after this, user can restart operation video logic gets confusing. i'm getting "out of memory" errors on place.) the code: avurlasset* asset = [avurlasset urlassetwithurl:self.cameraselection.movieurl options:[nsdictionary dictionarywithobjectsandkeys:[nsnumber numberwithbool:yes], avurlassetpreferprecisedurationandtimingkey, nil]...

flash - How to pass actionScript 2 value to php -

i have decompiled flash game. there variable called totalscore . need send variable leaderboard.php . how can in secure. currently i'm passing value this. geturl("mydomain.com/leaderboard.php&value="+totalscore,'_top','get'); i have accessed above value this: leaderboard.php $totalscore = $_get['value']; but method not secure. because 1 can change value press enter. value of 'value' store in db. i tried using post method on actionscript . not worked. please me solve problem? you can use loadvars has send() , sendandload() methods. the third argument of both of these lets determine method want use send data (get or post). example: var vars:loadvars = new loadvars(); vars.value = totalscore; vars.send("mydomain.com/leaderboard.php", "_blank", "post");

Split an array of strings into 2, use one as key and the other as value php -

i have athe following array of strings: (var_dump result) array(17) { [15]=> string(14) "07-04-16 10:00" [16]=> string(14) "07-04-16 10:30" [6]=> string(13) "07-04-16 8:00" [0]=> string(14) "08-04-16 13:00" [1]=> string(14) "08-04-16 13:30" [7]=> string(14) "12-04-16 16:00" [8]=> string(14) "12-04-16 16:30" [9]=> string(14) "12-04-16 17:00" [10]=> string(14) "12-04-16 17:30" [11]=> string(14) "12-04-16 18:00" [12]=> string(14) "12-04-16 18:30" [13]=> string(14) "12-04-16 19:00" [14]=> string(14) "12-04-16 19:30" [2]=> string(14) "13-04-16 11:30" [3]=> string(14) "13-04-16 12:00" [4]=> string(14) "13-04-16 12:30" [5]=> string(14) "13-04-16 13:00" } is there way split values on " "...

How can/should I include Ruby project file dependencies in config/environment? -

new rubyist here. in lectures on ruby, i've come across various tricks/shortcuts adding file dependencies config/environment file one's program runs smoothly. has been unclear me of these, when combined, redundant; best practices; , useless and/or wrong , should done long way. clarification appreciated! the ones i've come across: require_relative "../lib/test1.rb" : << '.' & require "lib/test1.rb" : << '.' & dir['lib/*.rb'].each {|f| require f} require file.dirname(__file__) "require-all" gem feel free include other ways, too! config/environment.rb file rails framework has opinions about. on lifetime of application, positively incented not modify file (if can avoid it). allow easiest possible upgrade path. consider placing initialization in file in config/initializers . if code alters behavior of rails in such fundamental way placement in config/initializers loses pote...

php - Fusioncharts does not diplay on mobile devices -

i have problem fusioncharts, use php , javascript. here code: <div id="chartdiv_krpb" class="chartdiv_krpb"></div> <script type="text/javascript"> var mychart; mychart = new fusioncharts("swf/pie2d.swf", "mychart_krpb", "100%", "240", "0", "1"); mychart.setdataurl("data/krpb.php?thnang=<? echo $thnang; ?>"); mychart.render("chartdiv_krpb"); </script> krpb.php $sql = mysql_query("select acronym 'kode', sum(rphreal) rphreal t_sai left join rosi_chat.t_perk2 on kdperk2 = left(perksai, 2) thnang = '$thnang' , rphreal > 0 , t_perk2.kdtrn = '3' , kdkem = '0' , kdperk2 in ('51','52', '53', '57') group kdperk2") or die(mysql_error()); $strxml = "<chart pieradius='90' showpercentagevalues='1' showvalues='1' numberscalevalue...

Filter a List in Python With List Elements -

i have following list list = ['bucket1', 'ranbuck0', 'ranbuck1', 'ranbuck2', 'ranbuck3', 'ranbuck4', 'ranbuck5', 'ranbuck6', 'ranbuck7', 'ranbuck8', 'ranbuck9'] is there way filter list , create new list, have elements named "ranbuck". not able figure out way how iterate ranbuck1, ranbuck2 append these in list. thanks in advance you use list comprehension syntax of python : new_list = [_ _ in list if 'ranbuck' in _] instead of _ s introduce own variable name temporary variable inside list comprehension. instead of 'ranbuck' in _ write down condition whether element of list should in new 1 or not.

How to test the value of an argument using Mocha and assert.throws in JavaScript? -

i want see if value equals 'x' cause function throw exception. have unit test checks if block throw exception, want exception thrown if argument = 'x', not if empty. how do using assert? here's code illustrate mean: // function check if color not transparent. function checkcolor(color) { if (color == 'transparent') { throw new typeerror('cant have transparent colors!'); } else { return color; } } here's assert: assert.throws(checkcolor, /cant have transparent colors!/); now, know assertion fail because function throws exception if color == 'transparent'. using mocha , assert, how test assertion want it? don't want merely test if color !== undefined or of type. want see if exception raised under specific circumstance above - circumstance want exception raised (since having empty color, handled elsewhere). assert.throw(function() { ithrowerror(argument) }, error) now make sure argument = x; ...

java - Is it possible to freeze System.currentTimeMillis() for testing -

for testing purposes predict system.currenttimemillis() return. there way in can freeze or manually set return when system.currenttimemillis() called? i suggest avoid using system.currenttimemillis (and new date() etc) in general code. instead, create clock interface representing "a service give current time" , create 1 implementation does use system.currenttimemillis or whatever, , fake implementation can control explicitly. use dependency injection make instance of service available code needs it. in production, use system.currenttimemillis version, , in testing use fake. this gives ability not stop time, set whatever want - can have static test data know never expire, , can test tricky things around boundaries etc. i've used approach in many projects, extent in noda time project it's the way of getting @ "the current time". note if you're doing serious amount of time work in java, i'd recommend using joda time , , mak...

javascript - Google Maps Direction Service ZERO RESULTS -

i getting 0 results status when make call using google directions service when shouldn't, far can see. have walked through debugger , looks values correct. using directions service route method waypoints. origin, need use lat, lng vals because changing, waypoints , destination, use full address. waypoint addresses don't have country @ end , stops @ state, destination have country value in address. wouldn't think that's problem. addresses in us, in same state. anybody see wrong code , how causing this, assuming values being filled in correct? function setroute() { var waypts = ""; var caddress = $("#companyaddr").text(); //slice zip code off caddress = caddress.slice(0, -6); var driverdisplay = $("#orders").find('.driverdisplay'); (i = 0; < driverdisplay.length; i++){ var directionsservice = new google.maps.directionsservice(); var dlats = $(driverdisplay[i]).find('.dlat'); var dlat = $(dlats[0]).text()...

bash - error in sudo config, need help to fix -

my shell give me error when trying sudo /etc/sudoers: syntax error near line 30 << i did not modify file... anyway 30th line end of file. paste here last 3 rows, 27 30 # see sudoers(5) more information on "#include" directives: #includedir /etc/sudoers.d please me understand problem , fix it. newbie on linux. if 30th line last 1 might indicate have problems in file somewhere along way. the parser has reached end of file , telling there error (might looking unclosed brackets of kind etc). if can parse full file or try read , go line line figure out error.

javascript - Highlighting marker in Google Maps Api 3 -

Image
i created map using this code . but, create button equal created google maps ? example, when click in <a href="#">show cocklebiddy wa waypoint b</a> on map highlight waypoint b example, on click in maker or b: show maker: does know how can create own custom button ?

Python finding index of elements with certain conditions -

this question has answer here: find longest repetitive sequence in string 5 answers i have following string: array = "tqtdtqd" for each d in array, there anyway know how many consecutive t's or d's before , after each d same letter right before each d. 1st d, letter right before t, want find how many consecutive t's before , after 1st d. 2nd d, letter right before q, want find # of consecutive q's before , after 2nd d. for instance, 1st d, there 1 t before d , 1 t after showing until there q. (e.g: 1st d, "tdt") for 2nd d, there 1 consecutive q before or no q after i did start following python codes find positions of each t,q,d: get_indexes = lambda x, xs: [i (y, i) in zip(xs, range(len(xs))) if x == y] t_position = get_indexes("t",array) q_position = get_indexes("q",array) d_position = get_indexes(...

ruby on rails - ActiveRecord: Scope to get parents with no children created at a specific date -

i want parent records no records created @ specific date on one-to-many relation in rails 4 activerecord , postgres database. migrations: class createparents < activerecord::migration def change enable_extension 'pgcrypto' unless extension_enabled?('pgcrypto') create_table :parents, id: :uuid, default: 'gen_random_uuid()' |t| t.string :name t.timestamps null: false end end class createchilds < activerecord::migration def change create_table :childs, id: false |t| t.uuid :parent_id, null: false t.date :created_at, null: false t.string :name end add_foreign_key :childs, :parents add_index :childs, [:parent_id, :created_at], :unique => true end end models: class parent < activerecord::base has_many :childs end class child < activerecord::base belongs_to :parent end now want parents no child @ specific date scope: class parent < activerecord::base has_many :c...

bash - git clone fatal: cannot create work tree dir permission denied -

so i'm trying clone repository git, folder know have write access in. i'm trying clone using intellij's built in vcs capabilities, , git bash program git-scm.com both of them return following error: fatal: not create work tree dir '<repo name>' : permission denied what doing wrong? the error pretty simple. don't have permissions on given directory. you can several things simple 1 try , clone repository vi git bash # go other directory have permissions write cd <some path> # check see if have permissions: mkdir dummy # once have verified have write permissions - # clone project command line git clone <url> once have cloned project - open in intellij's.

javascript - Parsing a json response from swift -

i have following code manage response via json form api. let url: nsurl = nsurl(string: "http://jsonplaceholder.typicode.com/posts")! let request:nsmutableurlrequest = nsmutableurlrequest(url:url) request.httpmethod = "post" let bodydata = "title=foo&body=bar&userid=1" request.httpbody = bodydata.datausingencoding(nsutf8stringencoding); nsurlconnection.sendasynchronousrequest(request, queue: nsoperationqueue.mainqueue()){ (response, data, error) in let res = nsstring(data: data!, encoding: nsutf8stringencoding) print(res) } i trying learn swift thought bit javascript getting response this. optional({ "title": "foo", "body": "bar", "userid": 1, "id": 101 }) normally javascript value running response.body or along lines cannot figure out how parse json response swift. any please tha...

Detect Android deployment target from Gradle build file -

i'm looking extend gradle build call external tool. issue need provide current cpu architecture being targeted, example armeabi or arm64-v8a if user has chosen deploy physical device. having trouble finding way of determining information in gradle build file. currently performing action in custom task runs before prebuild, similar this solution . there way detect cpu architecture @ point? task customtask(type: exec) { commandline "mytool.exe", "-architecture=$something" } prebuild.dependson customtask i'm using experimental plugin 0.7.0-beta3. thanks you can cpu architecture (abi) of connected device adb shell command: adb shell getprop ro.product.cpu.abi for nexus 5 return armeabi-v7a example. now have wrap command gradle method: def getdeviceabi() { return "adb shell getprop ro.product.cpu.abi".execute().text.trim() } then can call method task: task customtask(type: exec) { commandline "m...

python - Certain elements in for loop outputting differently -

i have array this: array=[['001', 'playing cards', '0.99', 2, 1.98], ['003', 'keyboard', '12.99', 1, 12.99], ['n/a', 'unavailable', 'n/a', 'n/a', 'n/a'], ['002', 'notebook', '0.59', 4, 2.36]] in program, have loop this: for subarray in array: element in subarray: length=((20 if element==subarray[1] else 6)-(len(str(element)))) if element != subarray[4]: print((element)," "*length,end=" ") else: print((element)," "*length) if run this, program outputs: 001 playing cards 0.99 2 1.98 003 keyboard 12.99 1 12.99 n/a unavailable n/a n/a n/a 002 notebook 0.59 4 2.36 what want program output is: 001 playing cards 0.99 2 1.98 003 keyboard 12...

java - Not a statement requiring while and other errors -

public class test { public static void main(string[] args) { nata = new nata(); } } makes lot of errors c:\users\irmantas\documents\netbeansprojects\penkiasdesimtmuzikosatspalviu\src\penkiasdesimtmuzikosatspalviu\test.java:4: error: not statement nata = new nata(); c:\users\irmantas\documents\netbeansprojects\penkiasdesimtmuzikosatspalviu\src\penkiasdesimtmuzikosatspalviu\test.java:4: error: ';' expected nata = new nata(); c:\users\irmantas\documents\netbeansprojects\penkiasdesimtmuzikosatspalviu\src\penkiasdesimtmuzikosatspalviu\test.java:4: error: illegal start of expression nata = new nata(); c:\users\irmantas\documents\netbeansprojects\penkiasdesimtmuzikosatspalviu\src\penkiasdesimtmuzikosatspalviu\test.java:4: error: while expected nata = new nata(); c:\users\irmantas\documents\netbeansprojects\penkiasdesimtmuzikosatspalviu\src\penkiasdesimtmuzikosatspalviu\test.java:8: error: illegal start of e...

objective c - iOS Static Library | Linking only USED symbols -

i using third party ios static libraries , having trouble keeping binary size small. libraries using have objective-c interface backed native c/c++ code. issue of symbols library (checked nm ) being included in app when linked (even if don't reference of code in library). contrary understanding of static libraries code application (or other linked libraries) reference pulled application. i've done bunch of reading , have found due dynamic nature of objective-c, there particular issues can arise linking object files or static libraries containing objective-c category methods. because of this, can pass -objc flag linker have linker pull in object files containing objective-c classes or categories. ensures classes , categories defined @ runtime, bloats app's binary unused objective-c classes/categories/method definitions. strangely enough, seeing effects of adding -objc linker flag while not using anywhere in build. of objective-c symbols being included, , consequen...

ios - ngCordova demo application build failed -

i trying build the demo app of ngcordova . cordova platform add ios cordova run ios but build failed following error messages. the following build commands failed: compilec build/ngcordova\ demo.build/debug-iphonesimulator/ngcordova\ demo.build/objects-normal/i386/applicationpreferences.o ngcordova\ demo/plugins/com.simonmacdonald.prefs/applicationpreferences.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler (1 failure) error running 1 or more of platforms: error code 65 for command: xcodebuild args: -xcconfig,/users/westhigh/github/demo/platforms/ios/cordova/build-debug.xcconfig,-project,ngcordova demo.xcodeproj,archs=i386,-target,ngcordova demo,-configuration,debug,-sdk,iphonesimulator,build,valid_archs=i386,configuration_build_dir=/users/westhigh/github/demo/platforms/ios/build/emulator,shared_precomps_dir=/users/westhigh/github/demo/platforms/ios/build/sharedpch

sql server - Can default SQLServer instance name be empty string? -

can default sqlserver instance name empty string? client argues has ".\" server\instance name. there 2 kinds of instances: default , named instance , seems logical not named has no name. msdn says: default name mssqlserver. as stated, msdn state default instance name mssqlserver . states instance name does not need specified default instance make connection. so answer question, default instance name isn't empty, but reference can be . reference using server / pc name. more info related default , named instances can found here .

java - how to use the count() function to get an element with a specific number of inner tags -

i using java , selenium write test. in dom, have 2 svg tags. 1 of them has more 2 inner path tags. need svg used: wait.until(expectedconditions.presenceofelementlocated(by.xpath( "//*[local-name() = 'svg' , count(.//path)>'2']"))); or wait.until(expectedconditions.presenceofelementlocated(by.xpath( "//*[local-name() = 'svg'] [count(.//path)>'2']"))); but doesn't work. need know what's wrong please offer other ways around. thanks. by way worked for: //*[local-name() = 'svg' , count(.//*[local-name() = 'path' ])>'1'] or //*[local-name() = 'svg'][ count(.//*[local-name() = 'path' ])>'1'] the problem trying find .//path svg element. far know, cannot because svg elements different namespace. mentioned in question, can fix using [local-name() = 'path' ] . workaround using jsexecut...

java - Android creating library project without source code -

i developing android library project.i don't want share source code.i want create jar file.but can't create jar file includes xml layouts.so there way build project without including source code? i can give example of such library. open android sdk manager , download google play services library. this library contains 'libs' folder google-play-services.jar contains source code . there 'res' folder , android manifest file able add library every android project.

python - How can I shift the index of a DataFrame when using Float64Index? -

as question mentions, have pandas (v. 0.18.0) dataframe consists of few columns of 1d data (simulated optical spectra). a sample dataset looks following: photon energy (ev), spin_up (a.u.), spin_down (a.u.), difference 1.520040, 0.000000, 0.00000, 0.000000 1.520515, 0.000000, 0.00000, 0.000000 1.520990, 0.000000, 0.00000, 0.000000 1.521465, 9.742188, 0.00000, 9.742188 1.521940, 35.432140, 24.41665, 11.015490 1.522415, 69.708160, 99.48898, -29.780820 1.522890, 140.897400, 198.71710, -57.819700 1.523365, 369.593200, 401.61710, -32.023900 1.523840, 1688.481000, 1034.93300, 653.548000 1.524315, 1822.535000, 4645.04600, -2822.511000 1.5...

c# - Trying to Understand UWP Data Binding -

so, made simple attempt try out data binding property of class have, but, whatever reason, code anything. it's not throwing errors, must not working right. i'm testing if it'll behave want to, which, in case, set opacity of rectangle zero. here's xaml data template doesn't seem want respond correctly: <hubsection x:name="china" width="440" height="460" background="#ff343434" header="china" isheaderinteractive="true" tapped="{x:bind hubsectiontapped}" horizontalalignment="left" verticalalignment="center" margin="50,0,0,0"> <datatemplate x:datatype="data:mainpageview"> <grid height="460" width="410" verticalalignment="bottom" x:name="chinabackground"> <image source="assets/chinaflag.bmp" x:name="chinaflag"/> ...

Android: create barcode image and display in imageView -

my goal: generate pdf417 format 2d- barcode , display in imageview in application. using zxing2.1 library's core.jar , j2se.jar. following code trying create barcode , display in imageview. imageview imageview = (imageview) findviewbyid(r.id.imageview); try { writer writer; bitmatrix bitmatrix = null; writer = new pdf417writer(); bitmatrix = writer.encode("123456789", barcodeformat.pdf_417, 580, 150); bytearrayoutputstream bytearrayoutputstream = new bytearrayoutputstream(); matrixtoimagewriter.writetostream(bitmatrix, "png", bytearrayoutputstream); inputstream decodedinput=new bytearrayinputstream(((bytearrayoutputstream) bytearrayoutputstream).tobytearray()); drawable d = bitmapdrawable.createfromstream(decodedinput, "src"); imageview.setimagedrawable(d); system.out.println("pdf417 code generated."); } catch (exception e) { } when execu...

algorithm - C++ Binary Search Tree Implementation -

i working on project in c++ in have create binary search tree inserts items array. have use following insert algorithm: tree-insert(t, z) y = nil x = t.root while x != nil y = x if z.key < x.key x = x.left else x = x.right z.p = y if y == nil t.root = z else if z.key < y.key y.left = z else y.right = z here have far: #include <iostream> using namespace std; struct node { int key; node* left; node* right; node* p; node* root; }; void insert(node*, node*); void printinorder(node*); int main() { node *root; node* tree = new node; node* z = new node; int array [10] = {30, 10, 45, 38, 20, 50, 25, 33, 8, 12}; (int = 0; < 10; i++) { z->key = array[i]; insert(tree, z); } printinorder(tree); return 0; } void insert(node *t, node *z) { node *y = nullptr; node* x = new node; x = t->root; while (x != null) { y = x; if (z-...

c# - Get Latest Tweets from Users home_timeline Using Tweetsharp with Api v1.1 -

im working on windows phone app in need user home_timeline tweets app , show in listbox how can latest tweets users home_timeline using tweet-sharp (json) using api v1.1 because api v1 retirement complete https://dev.twitter.com/blog/api-v1-is-retired

javascript - vue.js - Add new value to object after click -

i have similar this: arr = [ { val1: a, val2: b }, { val1: a, val2: b }, { val1: a, val2: b } ] <div v-for="single in arr"> <button v-on:click="addsome"></button> </div> and when click example second button in loop, want add 'val3': 'c' clicked object. tried $add, $set, , tried pass current 'single' , $index... , nothing. correct way add/edit specified object loop? sorry english ;) thank in advance try this: <div v-for="single in arr"> <button v-on:click="addsome($index)"></button> </div> and then ... "addsome": function (index) { vue.set(this.arr[index], "val3", "c"); } ...

SQL Server how can I use COUNT DISTINCT(*) in HAVING clause? -

i have procedure counts unique [customerid] values , displays them in select list. i'm trying sort [customerid] "> 1" using having clause, sql won't let me use distinct count inside having. in mind makes sense having should work count not: use mycompany; go select distinct count(customerid) numberofordersmade, customerid customerid tblitems_ordered group customerid having distinct count(customerid) > 1 go you want select count(distinct orderid) instead of distinct count(customerid) : use mycompany; go select count(distinct orderid) numberofordersmade, customerid customerid tblitems_ordered group customerid having count(distinct orderid) > 1 go when outside of count , distinct eliminate duplicate rows result set, have no effect in query because doing group by . when inside count , distinct limit count unique values of column pass count function. thus, makes more sense use orderid column instead of customerid when you're aliasing n...

iphone - How i can send a message to a specific device with identifierForVendor or openUDID? -

i'm writing app manage accounts stored in server,like other social app. wanna forbid double login same account in 2 devices. when user log app have log out other devices logged same credentials. identify device use openudid ios<6 , identifierforvendor ios>=6. devices id stored in server db. there's way take id , send notification/messagge related device? know can check actual device id , stored id know if same device...it's not enough, need send notification device. how can do? the way send message other device through apns. take @ tutorial -> h ttp://www.raywenderlich.com/32963/apple-push-notification-services-in-ios-6-tutorial-part-2

java - Spring doesn't file properties files -

i'm having troubles accessing properties files spring. here arborescence : web-inf - application-context.xml - properties -applicationperperties.xml -csvheader.properties here import in application-context.xml : <?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:util="http://www.springframework.org/schema/util" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/sch...

Collapse daily data frame down to weekly data frame in R -

this question has answer here: aggregate data weekly level every week starting monday 3 answers i have data frame follows: office string_date b c d e 1: 11 2010-06-01 0 0 1 0 0 2: 11 2010-06-02 0 0 0 1 0 3: 11 2010-06-03 0 0 0 1 0 4: 11 2010-06-04 0 0 0 1 0 5: 11 2010-06-05 0 0 0 1 0 6: 11 2010-06-06 0 1 0 0 0 7: 11 2010-06-07 0 1 0 0 0 8: 11 2010-06-08 0 1 0 0 0 9: 11 2010-06-09 0 1 0 0 0 10: 11 2010-06-10 0 1 0 0 0 11: 11 2010-06-11 0 1 0 0 0 12: 11 2010-06-12 0 1 0 0 0 i need aggregate sums of each column week, not day listed. left each week each office, sums of each column. first line be... office week b c d e 11 1 0 2 1 4 ...

c - How to block on a semaphore until its value is positive -

i want use semaphores make threads block until semaphores become positive; when threads block on semaphore, unblock on first sem_post called on it, regardless of value of semaphore afterwards. the situation follows: semaphore set -1 . a thread started wait 5 seconds before posting semaphore. once 5 seconds pass, thread posts semaphore. the semaphore's value 0 , main process unblocks anyway. here code demonstrating situation: /** * testing whether sem_post on semaphore unblocks threads * despite still being negative. **/ #include <semaphore.h> #include <pthread.h> #include <stdio.h> #include <unistd.h> sem_t sem; void *proc(void *arg) { sleep(5); puts("posting"); sem_post(&sem); } void setup() { pthread_t pt; pthread_create(&pt, 0, proc, 0); } int main(int argc, char **argv) { sem_init(&sem, 0, -1); setup(); sem_wait(&sem); return 0; } i have found crude way over...

How do I install ruby 1.9.3-p429 using rbenv? -

i tried install ruby 1.9.3-p429 using rbenv follows; (on ubuntu linux 12.04) % git clone https://github.com/sstephenson/rbenv.git /path/to/rbenv % ln -s /path/to/rbenv ~/.rbenv % cd ~/.rbenv % echo 'export path="$home/.rbenv/bin:$path"' >> ~/.zshenv % echo 'eval "$(rbenv init -)"' >> ~/.zshenv % exec $shell -l % git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build but, ruby-build dumps error message. % rbenv install 1.9.3-p429 downloading yaml-0.1.4.tar.gz... -> http://dqw8nmjcqpjn7.cloudfront.net/36c852831d02cf90508c29852361d01b -> http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz build failed inspect or clean working tree @ /tmp/ruby-build.20130701184855.7206 results logged /tmp/ruby-build.20130701184855.7206.log last 10 log lines: checksum mismatch: yaml-0.1.4.tar.gz (file corrupt) expected 36c852831d02cf90508c29852361d01b, got 956baf72fd20659d7045498cc3954bf2 : -q curl: ...

mysql - CakePHP 3 Post Method '403 Forbidden' -

i came across strange issue today , couldn't find solution. using cakephp 3 along mysql , apache. working perfect until today when tried edit 1 of forum post, didn't save , got 403 forbidden response. following response got: request url:https://www.example.com/users/edit/2 request method: post status code:403 forbidden the strange part is working fine when try create new forum post get request when load edit page. when modify fields , try save, stuck 403 forbidden . i tried every mean in last 6 hours not find solution. checked database user edit permissions, tried remove .htaccess file completely, cleared browser cache , cookies nothing helped @ all. other websites in hosting account working fine , there no issue them. the notable thing did today initialized git repository , uploaded project files on git. appreciate in solving issue. constant headache not able modify anything. just future reference, solved issue explicitly defining request type post in...

jenkins - git clone gets hung and gets timedout -

i use bitbucket(git) server , git clone randomly getting hung. same repo gets cloned , hung unexpectedly , gets timed out. server memory, cpu utilization, disk space fine. please advise other areas needs attention find root cause.this happening on 5 different jenkins slave not restricted single server. following error log: error: error cloning remote repo 'origin' hudson.plugins.git.gitexception: command "/usr/bin/git -c core.askpass=true fetch --tags --progress http://bitbucket.net/project.git +refs/heads/*:refs/remotes/origin/*" returned status code 128: stdout: stderr: remote: counting objects: 2506, done. stdout: stderr: remote: counting objects: 2506, done. remote: compressing objects: 0% (1/2405) remote: compressing objects: 1% (25/2405) remote: compressing objects: 2% (49/2405) remote: compressing objects: 3% (73/2405) remote: compressing objects: 4% (97/2405) remote: compress...

javascript - How can i transfer a value in php? -

i have html-file , php-file. index.html transfers value php script ajax. want servo.php file writes every value gets index.html in file /dev/servoblaster. you can find files here: html-file php-file question: in example value want transfer p1-11=160. want value (and not create single switch every value). if( isset($_get['dir']) ) { // $_get['dir'] -> direction (up|dn|lt|rt|stop) $handle = fopen("/dev/servoblaster", 'w'); switch($_get['dir']) { case "p1-11=160": fwrite($handle, "p1-11=160\n"); //write in /dev/servoblaster - p1-11=160 break; } fclose($handle); } instead of having switch statement looking specific text write, following: $handle = fopen("/dev/servoblaster", 'w'); fwrite($handle, $_get['dir']."\n"); fclose($handle); henc...

couchdb - Can a database be considered idle even when continuously replicating? -

i'm considering couchdb project (still in research phase). want many users, each own database (for authentication purposes), 1 big read-only database they're replicated, can generate reports , make dashboard. let's assume databases running on same machine , in same process. normally, small fraction of human users online , doing things, should able keep max_dbs_open setting lot lower total number of users. couchdb should have no problem determining ones idle. however, i'm worried database throw wrench this. having continuous replication user databases 1 big database keep them awake time? (and if so, bad? logged-in users lose priority advantage , thrashed @ bad times?) or couchdb smart enough consider database idle long it's not being queried or written to, if there's ongoing continuous replication session? note replication in 1 direction: big database watches changes user databases. suggestions other ways approach problem welcome. i'm vaguely awar...

ggplot2 - Color the control group using geom_bar in R -

Image
i have data set looks this: a<-data.frame(strain=rep(letters[1:3], each=2), mean=rnorm(6,0.5,0.1), treat=rep(letters[1:2],6)) and plot in bar graph using ggplot, having different fill colors strain corresponding "c". don't know if have proper approach, add layer particular code, says length of fill not correct. b <- ggplot(data=a, aes(x=factor(strain), y=mean, fill=factor(treat))) + geom_bar(position='dodge', stat='identity') + geom_bar(data=subset(a,a$strain=="c"), fill=c('red','blue'), position='dodge', stat='identity') sorry basic question far haven't been able go around it. help! like this? a$treat2 <- as.character(a$treat) a$treat2[a$strain=="c"] <- paste("c",a$treat2[a$strain=="c"],sep=".") #function create ggplot default colours ggcolours <- function(n) force(hcl(h=seq(15, 3...

Is there any disadvantage wrapping socket.io in a callback function in AngularJs Service? -

i made service in angular.js use socket.io inside controllers callback function. in service emitter , listener in same function use in controllers follow. service.js (function () { /* socket io service */ var service = angular.module('myservice', ['']); service.factory('sio', ['$http', function($http){ var socket; socket = io.connect('http://localhost:3000'); return { /* queries user */ login: function(authdata, callback){ socket.emit('__app auth login', authdata); var response = socket.on('__app auth login', function(res){ callback("", res); }); return response; }, finduser: function(conditions, callback){ socket.emit('__app user find', conditions); var response = socket.on('__app user find', function(res){ callback("", res); ...

mysql - Limit results in join query -

this question has answer here: get top n records each group of grouped results 7 answers i have 2 tables: list of cities, , list of categories each city. table tv_village id | name -------------- 1 | london 2 | paris table tv_village_category village_id | category | total ----------------------------- 1 | event | 10 1 | realestate | 15 1 | job | 8 1 | place | 20 2 | event | 42 2 | realestate | 66 2 | job | 83 2 | place | 55 my question i need top 3 categories each city (sort total). what tried when try query, tells me field v.id unknown subquery. select * tv_village v inner join ( select * tv_village_category vc2 vc2.village_id = v.id , vc2.total > 0 order vc2.total desc ...

r - rgdal - read a table within a ESRI geodatabase (gdb) -

i trying read table esri geodatabase (.gdb) has no geometry using r. readogr throwing error because there no geometry defined, kind of make sense: library(rgdal) readogr("gssurgo_co.gdb","mutext") #error in readogr("gssurgo_co.gdb", "mutext") : no features found #in addition: warning message: #in ogrinfo(dsn = dsn, layer = layer, encoding = encoding, use_iconv = use_iconv, : #ogrinfo: features null my current solution access directly gdal , dump cvs of table read r: # here example same layer system("ogr2ogr -f csv mutext.csv gssurgo_co.gdb mutext") mutext <- read.csv("mutext.csv") it works, there better way this? thanks!

linked list - What happens when iterating over a Java LinkedList using the native foreach syntax? -

i'm trying understand basic behavior of linked list when iterating on using foreach syntax. let's linkedlist contains a, c, b, d added in order, order should -> a-c-b-d. if iterate on linkedlist using foreach (which uses iterator implicitly udnerstand it), contract guarantee items retrieved in order? api doesn't seem this, though maybe it's obvious mention? i'm looking @ java 7 api: https://docs.oracle.com/javase/7/docs/api/java/util/linkedlist.html api mentions iterator fail-fast, , goes lot of detail that, says nothing can see iterator guaranteeing order of linked list. the api doesn't seem this oh yes does. "returns iterator on elements in list (in proper sequence)."