Posts

Showing posts from January, 2014

eclipse - Unable to build meteor project remotely through a java application? -

i trying run meteor project java application , code have written it:- string[] command = { "/bin/bash", "-c" ,"cd /home/cloud2/music/mymeteorproject; meteor run android-device" }; processbuilder builder = new processbuilder(command); builder.redirecterrorstream(true); process process=null; try { process = builder.start(); } catch (ioexception e1) { e1.printstacktrace(); } inputstream = process.getinputstream(); bufferedreader reader = new bufferedreader(new inputstreamreader(is)); string line = null; try { while ((line = reader.readline()) != null) system.out.println(line);// line display error message on console } catch (ioexception e) { e.printstacktrace(); } building meteor project java application shows following error in eclipse console:- your system not yet seem fulfill requirements b...

java - HandleSignInResult = false when trying to Google sign in -

i followed this google documentation , copy , pasted whole signinactivity xml files , string resources needed. everytime when try sign in emulator in logcat shows handlesigninresult: false . i've been trying google sign in work week setup achievements , leaderboard. hope me solve huge headache. edit: part have choose email sign in working, actual sign in not. edit: got release key sha 1 , added json file app/ module, still after has shown me email pick sign in click on 1 , still doesn't connect!!! edit: 4 seconds ago saved edit , after worked!!!!:d:d:d:d!!!!!! , in case if sees , has problems sha1 download this program, it's easier getting headache freaking terminal/cmd. , i'm off celebrate win against evil google sign in. oh , got working on phone , it's still not working on emulator, that's not problem. first check manifest, add internet permission? <uses-permission android:name="android.permission.internet" />

android - Error in TextInputLayout dont show again even call setErrorEnabled(true) -

i have textinputlayout this <android.support.design.widget.textinputlayout android:id="@+id/input_layout_name" android:layout_width="match_parent" android:layout_height="wrap_content"> <edittext android:id="@+id/edt_name" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/title_what_should_we_call_you" /> </android.support.design.widget.textinputlayout> for valid name when tap on submit button use private boolean validatename() { if (edtname.gettext().tostring().trim().isempty()) { inputlayoutname.seterrorenabled(true); inputlayoutname.seterror("enter name"); return false; } else { inputlayoutname.seterrorenabled(false); } return true; } ...

php - Create associative array from three flat arrays -

consider following: $a = array('q1', 'q2', 'q3', 'q4'); $b = array('2014' => '101', '2014' => '102', '2014' => '103', '2014' => '104'); $c = array('2015' => '101', '2015' => '102', '2015' => '103', '2015' => '104'); how transform these 3 arrays 1 this: array( 'q1' => array( '2014' => '101', '2015' => '101' ), 'q2' => array( '2014' => '102', '2015' => '102' ), 'q3' => array( '2014' => '103', '2015' => '103' ), 'q4' => array( '2014' => '104', '2015' =...

python - how to do a query with multi-table related sqlalchemy -

i have next models. class provider(base): __tablename__ = "providers" providerid = column(integer, primary_key=true) thirdpartyid = column(integer, foreignkey("thirdparties.thirdpartyid")) thirdparty = relationship("thirdparty") class thirdparty(base): __tablename__ = 'thirdparties' thirdpartyid = column(integer, primary_key=true, nullable=false) economicactivityid = column(integer, foreignkey('economicactivities.economicactivityid')) class economicactivity(base): __tablename__ = 'economicactivities' economicactivityid = column(integer, primary_key=true, nullable=false) puc = relationship(u'puc', secondary=economicactivitypuc, primaryjoin=economicactivityid == economicactivitypuc.c.economicactivityid, secondaryjoin=puc.pucid == economicactivitypuc.c.pucid, lazy="dynamic") ...

Android OnTouch swipe up/down direction change -

i'm trying detect when swipe direction changed while user still swipes on screen. i have (very basic) detecting swipe direction: @override public boolean ontouch(view view, motionevent motionevent) { int action = motionevent.getactionmasked(); switch (action) { case motionevent.action_down: { log.d(tag, "ontouch: down _y = " + motionevent.getrawy()); mlasttouchy = mprevtouchy = motionevent.getrawy(); break; } case motionevent.action_move: { log.d(tag, "ontouch: move _y = " + motionevent.getrawy()); final float dy = motionevent.getrawy(); if (dy >= mlasttouchy) { /* move down */ } else { /* move */ } break; } case motionevent.action_cancel: case motionevent.action_outside: case motionevent.action_up: { log.d(tag, "ontouch: _y = ...

Java "For" loop output repeats -

i beginner trying program java code produce output numbers prime factor of 2 , five. for example, if input 8 , output should 2 4 5 8 . however, whenever print output, result 2 5 4 5 8 5. please advice on have gone wrong. thank you import java.util.scanner; class twofive { public static void main(string [] args) { scanner sc = new scanner(system.in); system.out.print("enter n:"); int n = sc.nextint(); double num = 0; double num2 = 0; (int = 1; (((math.pow(2,i))<= n) || ((math.pow(5,i)) <=n) || (((math.pow(2,i))<= n) && ((math.pow(5,i)) <=n))) ; i++) { if (( math.pow(2,i)) <= n) num = (math.pow(2,i)); int convert = (int) num;{ system.out.print(convert + " "); } if ((math.pow(5,i)) <= n) num2 = (math.pow(5,i)); int convert2 = (int) num2; {system.o...

reactjs app working properly on desktop but not visible on mobile -

i'm new react , created small app. works fine on desktop, react part of app doesn't show on mobile. can sby tell me should do? http://dry-wildwood-76655.herokuapp.com/ package.json { "name": "udacitytransportationapp", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "start": "node ./node_modules/webpack-dev-server/bin/webpack-dev-server.js", "prod": "node_env=production node server.js", "postinstall": "webpack -p" }, "author": "", "license": "isc", "dependencies": { "babel-core": "^6.11.4", "babel-loader": "^6.2.4", "babel-preset-es2015": "^6.9.0", "babel-preset-react": "^6.11.1", "babel-preset-stage-1": ...

SB Admin Laravel 5 line chart data -

Image
am using following package. there chart displayed in resources/views/mcharts.blade.php. code following; @section ('cchart1_panel_title','line chart') @section ('cchart1_panel_body') @include('widgets.charts.clinechart') @endsection @include('widgets.panel', array('header'=>true, 'as'=>'cchart1')) so code refers widgets.charts.clinechart. looking file, code follows: this prints out nice line chart: where date draw lines. expect come controller, can't seem find it. correct way provide linechart data coming application it in javascript here https://github.com/start-laravel/sb-admin-laravel-5/blob/master/resources/js/frontend.js you create api laravel , ajax data.

Call Php function through Ajax -

i want know how call php function through ajax , if person matches parameters display form. here php code want call, microsub.php: <?php $ip = $_server['remote_addr']; $public_ip_ranges = array(); $range = (object) array(); $range->name = 'xxxx xxxxx'; $range->lower = '10.1.0.0'; $range->upper = '10.1.255.255'; $public_ip_ranges[] = $range; $range = (object) array(); $range->name = 'xxxxxxx'; $range->lower = '141.228.0.0'; $range->upper = '141.228.255.255'; $public_ip_ranges[] = $range; $range = (object) array(); $range->name = 'xxxxxxxxx'; $range->lower = '146.127.0.0'; $range->upper = '146.127.255.255'; $public_ip_ranges[] = $range; if (($lngip=ip2long($ip)) < 0) $lngip += 4294967296; foreach ($public_ip_ranges $ip_range) { if (($lnglow=ip2long($ip_range->lower)) < 0) $lnglow += 4294967296; if (($lnghigh=ip2long($ip_range->upper)) < 0) ...

Odd PowerShell Get-ACL permission translations -

i have powershell script matches get-acl access control entries standard windows permissions using access mask. oddly, aces "readandexecute, synchronize" seem yield permission of "fullcontrol". here script: #match current ace permissions regular permissions via access mask comparison (binary , / -band) $acl = get-acl "c:\program files (x86)" $accesses = $acl.access #enumerate current directory's access rights foreach ($access in $accesses) { $enumeration = $access.filesystemrights $keys = @() [system.enum]::getvalues($enumeration.gettype()) | where-object { $enumeration -band $_; write-host ($enumeration -band $_) -foregroundcolor red} | % {write-host -foregroundcolor green $_;} | select-object -unique | foreach-object { write-host -foregroundcolor cyan $_; $keys += $_ } $keys } perhaps not understand how appropriately translate these access control ...

javascript - Using Google Visualization, why is DataView content showing in ChartRangeFilter but not in its associated LineChart? -

Image
the code below should populate dataview csv file. dataview fed dashboard inludes linechart , chartrangefilter bound together. problem while chartrangefilter shows proper chart preview , allows me select range linechart shows empty data set right data type , axis labels. assumption dataview content ok since chartrangefilter capable of showing it. why can't linechart same? google.load('visualization', '1', {packages: ['controls', 'charteditor']}); google.setonloadcallback(drawchart); function drawchart() { // create csv string csvstring = 'time,temp0,hum0\n13:00:04,24.7,50\n13:01:05,26.7,60\n13:02:04,22.7,52\n13:03:05,14.7,40\n13:04:04,34.7,80\n13:05:05,24.7,50'; // parse string array var arraydata = $.csv.toarrays(csvstring, {onparsevalue: $.csv.hooks.casttoscalar}); // convert array datatable var data = new google.visualization.arraytodatatable(arraydata); // create dataview datatable var view = new g...

javafx 8 - Add a decorative area around a node, that behaves like an Effect -

Image
for card game, i'm writing, created custom "control" represents card. can flipped, dragged around, selected, , scaled, translated , forth during course of game. one core feature of card is can "highlighted" in different ways. basic form of highlighting showing glowing border (animated) around card. i started javafx effects here (dropshadow animated spread/radius) turned away this, because performance turned out bad. so, replaced effect animated imageview "behind" card (basic sprite animation sprite sheet pre-rendered glow animation). solves performance issue, introduced numerous other problems i'm trying tackle... since, don't want "anchor point" top-left corner of glow around card top-left corner of card itself, tried offset imageview within card node -x/-y. (different highlights can "expand" node different amounts, should not affect location of node, , when setting location of node should not have care potent...

node.js - Error Running custom blockchain(hyperledger) application with security enabled -

i'm running blockchain application on local network setup using vagrant. network (ca , vp ) running inside vagrant vm while application resides outside vagrant. when ran application security disabled, works fine. when tried security enabled, i'm getting following error: himanshus-mbp:bcapplication himanshutyagi$ node app.js loading hardcoded peers loading hardcoded users [ibc-js] peer: vp0-dev_vp0...:5000 [ibc-js] no membership users found after filtering, assuming network w/o membership [ibc-js] found chaincode in local file system [ibc-js] scanning files [ '.ds_store', 'chaincode_finished.go', 'finished' ] [ibc-js] parsing file shim version [ibc-js] found shim version: github.com/hyperledger/fabric/core/chaincode/shim [ibc-js] parsing file invoke functions - chaincode_finished.go [ibc-js] found cc invoke function: init [ibc-js] found cc invoke function: delete_product [ibc-js] found cc invoke function: delete_offering [ibc-js] found cc inv...

mysql - Combining between two queries -

Image
i have 2 big queries, individually both work , produce want. query 1: select pt.map, pt.time, pt.jumps, pt.id playertimes pt auth = '[u:1:204506329]' , style = 0 order map; (in action, [u:1:204506329] variable) query 2: select count(*) rank playertimes pt left join users u on u.auth = pt.auth pt.time <= ( select time playertimes map = 'bhop_horsepoop_8' , style = 0 , auth = '[u:1:204506329]' limit 1 ) , pt.map = 'bhop_horsepoop_8' , pt.style = 0 order time asc limit 1; (again, [u:1:204506329] , bhop_horsepoop_8 variables) the purpose of query 1 retrieve list of map s, time s, jump s , id s auth define. the purpose of query 2, find auth 's position ('rank') in playertimes table on defined map , style . intention, sum both of single query. receive both want in first query, , rank field every row retrieved in query 1. this tried: select pt.map, pt.time, pt.jumps, pt.id, ( select count(*) rank ...

javascript - Callback method after for delayed job - render js alert -

i have app delayed job. want use callback once action finish (after, success or finish) , inform user on client side. have this: class scannerjob < applicationjob queue_as :default def perform(links, count = 0) links |url| broadcast_it(url.to_s, count +=1) end after end def after respond_to |format| format.js { render :js => "alert('congratulations');" } end end i got this: unterminated string meets end. found source telling impossible it. what best way handle , why can't call respond js? thanks! yeah it's impossible it. let's find out why. positive how normal http request cycle work. in traditional way client asks server fullfill request. whether it's querying data or it's sending data store on server. server handle client's request , send response client. after server has full filled client's request there no way server gonna communicate client unless client asks/r...

python - Calculating cosine distance between the rows of matrix -

i'm trying calculate cosine distance in python between rows in matrix , have couple questions.so i'm creating matrix matr , populating lists, reshaping analysis purposes: s = [] in range(len(a)): j in range(len(b_list)): s.append(a[i].count(b_list[j])) matr = np.array(s) d = matr.reshape((22, 254)) the output of d gives me smth like: array([[0, 0, 0, ..., 0, 0, 0], [2, 0, 0, ..., 1, 0, 0], [2, 0, 0, ..., 0, 0, 0], ..., [0, 0, 0, ..., 0, 0, 0], [0, 0, 0, ..., 0, 0, 0], [1, 0, 0, ..., 0, 0, 0]]) then want use scipy.spatial.distance.cosine package calculate cosine first row every other else in d matrix. how can perform that? should loop that? not experience matrix , array operations. so how can use loop second argument (d[1],d[2], , on) in construction not launch every time: from scipy.spatial.distance import cosine x=cosine (d[0], d[6]) you can use simple loop scipy.spatial.distance.cosine : dis...

html - Horizontal CSS colums with fixed header -

Image
how can arrange horizontal columns fixed top header on each text block? text blocks overlaps each other on overflow. i want see on screenshot you can see problem @ jsfiddle or this: p { margin: 0; } .container { outline: 1px dotted gray; height: 200px; width: 400px; white-space: nowrap; overflow-x: auto; } .column { outline: 1px dotted green; display: inline-block; vertical-align: top; white-space: normal; column-width: 100vw; width: min-content; min-width: 50%; height: 100%; } .header { column-span: all; white-space: nowrap; } <div class="container"> <div class="column"> <h2 class="header">lorem ipsum dolor sit..</h2> <p>lorem ipsum dolor sit amet, consectetur adipisicing elit. pariatur, dicta aut @ sunt quasi aspernatur. ullam porro, consequatur est quo voluptatum atque. delectus, dicta, saepe...

c++ - boost:bad_any_cast: failed conversion using boost:any_cast error -

running issue boost program options. added multiple use option let's call "--opt". when run program.exe command line 2 "--opt" following error boost. terminating uncaught exception of type boost::exception_detail::clone_impl >: boost::bad_any_cast: failed conversion using boost::any_cast i unsure causing boost::bad_any_cast. novice when comes c++ , boost. below example of code using , think boost::bad_any_cast might occurring. error appeared after added std::vector . thoughts issue? or resources point me figure out on own too? po::value<std::vector<std::string>>() i aware of this previous question well.

npm - gulp-typings - Issues with Beautylog -

up until today having no problems in our typescript solution appears dependency of gulp-typings having issues update dependency beautylog? have tried installing/uninstalling gulp-typings , beautylog no success. have thoughts or seen yet? failed run "c:\xxxx\gulpfile.js"... cmd.exe /c gulp --tasks-simple c:xxxx\node_modules\beautylog\dist\beautylog.classes.table.js:3 const plugins = require("./beautylog.plugins"); ^^^^^ syntaxerror: use of const in strict mode. @ module._compile (module.js:439:25) @ object.module._extensions..js (module.js:474:10) @ module.load (module.js:356:32) @ function.module._load (module.js:312:12) @ module.require (module.js:364:17) @ require (module.js:380:17) @ object.<anonymous> (c:\xxxx\node_modules\beautylog\dist\index.js:4:33) @ module._compile (module.js:456:26) @ object.module._extensions..js (module.js:474:10) @ module.load (module.js:356:32) @ function.module._load (module.js...

typescript - Property 'status' does not exist on type 'Error' -

i'm using angular 2 , passing error http request logandpasson method. getting error "property 'status' not exist on type 'error'." typeof error object seems typeof error recognized typeof file is. private logandpasson (error: error) { if (error.status == 403) { things } return observable.throw(error); } i got around setting error's type 'any' seems there should better way. there library import typeof error? there way handle besides writing own error class , importing it? the object passed http error callback of type response @angular/http module. same response initial http call. if there error response, response sent error through subscriber. import { response } '@angular/json'; http.get(..) .subscribe( (res: response) => { dosomething(res.json()) } (res: response) => { ... }); so basically, trying use error not correct. works when use any , during runt...

Formatting JSON Data for Postman -

Image
i trying send json data post through postman keep getting following error: when json validated jsonlint result: error: parse error on line 1: { taco: { name: "", --^ expecting 'string', '}', got 'undefined' the object keys should strings. valid json: {   "taco": {     "name": "",     "price": "",     "photo_url": ""   } }

fortran - How to start a project using a Watcom compiler? -

i need evaluate fortran 77 code wrote using watcom compiler. long story short, have no other option compiler. must one. as of now, project, have read .dat files , print read in desired format. on setting new project, watcom makes distinction between "targets" , "sources" have no idea means. so far, created new project , loaded code "source", don't know if right. haven't figured out how load .dat file, or if need load them @ all, given perhaps watcom may access without bringing interface. for record, have read manual of little help. ( ftp://ftp.openwatcom.org/pub/manuals/1.5/f_readme.pdf ) i'm still beginner @ coding , appreciated. thank you.

github - GO script runtime error for Amazon AWS S3 -

i'm attempting run following golang build first time on amazon linux distro: https://github.com/adammck/s3-graphite readme here: go github.com/adammck/s3-graphite cd $gopath/adammck/s3-graphite go build after this, set variables in .bashrc file below: # aws keys read access bucket export aws_access_key_id=xxxxxxxxxx export aws_secret_access_key=yyyyyyyyyy export aws_region=us-east-1 # bucket watch export s3_bucket=my-bucket export s3_prefix=dir/subdir # server send metrics export graphite_address=metrics.example.com export graphite_prefix=s3-count.my-bucket.dir.subdir i set gopath following: export gopath="$home/work/" i cd dir run go build works should, when go run following after go build: ./s3-graphite i following error: info[0000] starting s3-graphite... panic: runtime error: invalid memory address or nil pointer dereference [signal 0xb code=0x1 addr=0x20 pc=0x4e3256] goroutine 1 [running]: github.com/aws/aws-sdk-go/service/s3.new(0x0, 0x0...

Using Regex to match numbers on rows of different size in Python -

i have file contain positive , negative numbers in row of different sizes. trying extract numbers using regex.however, skips rows below. part of input file: . . . ...s -- -0.28096 -0.27907 -0.27770 -0.27730 -0.27573 ...s -- -0.27149 -0.27076 -0.27036 -0.26883 -0.26794 ...s -- -0.26301 -0.26114 -0.26098 -0.25950 -0.25891 ...s -- -0.25536 -0.25209 -0.24952 -0.24903 -0.24533 ...s -- **-0.24351 -0.23272 -0.07408** ...s -- -0.01149 -0.01028 -0.00892 -0.00888 -0.00665 ...s -- -0.00445 -0.00268 -0.00006 **0.00109 0.00187** ...s -- **0.00295 0.00318 0.00470 0.00575 0.00696** . . . my code: with open('input') x: file.write('output') file.write("\n") t in itertools.islice(x,7821,7831): k = re.search(r'(?<=s\s\s\s\s\s\s)[+-]?\d+\.\d+|\d+\s\s\[-+]?\d+\.\d+|\d+\s\s\[-+]?\d+\.\d+|\d+\s\s\[-+]?\d+\.\d+|\d+\s\s\[-+]?\d+\.\d+|\d+' , t) if k: r1.append(k.group())...

html - content not resizing to full width within jumbotron -

i'v been trying couple of days fix on own; apparently more complicated expected. what want achieve: want both iframes use full heigth , width of screen. have been abble make iframes use full heigth making div enclosing video 100% heigth on css. cant seem make strech use full width. after i'm facing new problem, chat iframe getting moved below video iframe. thank patience! this code. body { font-family: 'gloria hallelujah'; font-weight: 300; } .jumbotron { display: flex; align-items: center; background-image: url('jumbobg.png'); background-size: cover; color: #ffffff; text-shadow: 0.25px 0.25px 0.25px #000000; padding: 0px; padding-left: 0px; padding-right: 0px; } .twitchvideo { width: 100%; height: 100%; } .twitchchat {} .nopadding { padding: 0 !important; margin: 0 !important; } .nomargin { margin: 0 !important; padding: 0 !important; } <html> <head> <title...

html - Image path, src diacritics, php -

edit 1: have created new laravel project blank 1 , diacritics doesn't work, meta char included. html code: <div class="row"> @foreach ($tagnames $tagname) <div class="col-sm-4"> <p>{{$tagname->tagname}}</p> <img style="min-width:35%; min-height:35%"; class="img-responsive"; src="images/{{$tagname->tagname}}.jpg"> </div> @endforeach </div> everything works fine getting images until path name has diacritics (romanian ones î,â,ț,ă,ș), tried adding <img style="min-width:35%; min-height:35%"; class="img-responsive"; src="images/dude1withî.jpg"> and doesn't work too. <meta charset="utf-8"> is added doesn't anything. examples of images stored in images folder: măr.png, pîine.png, pastă.png , on how can solve this? given appreciated. if imag...

asynchronous - How to pass data to external javascript script, loaded asynchronously -

i followed answer https://stackoverflow.com/a/7719185/842837 load javascript asynchronously. how pass data external file? current code: <script id="js-widget-o2ba1y" type='text/javascript'> (function() { function async_load(){ var config = { 'module': 'hyperdesign', 'user-name': 'john doe', 'user-email': 'john@doe.com' }; var id = "js-widget-o2ba1y"; var embedder = document.getelementbyid(id); var s = document.createelement('script'); s.type = 'text/javascript'; s.async = true; var u = 'http://external.javascript.file.js'; s.src = u + ( u.indexof("?") >= 0 ? "&" : "?") + 'ref=' + encodeuricomponent(window.location.href); embedder.parentnode.insertbefor...

python - How can I jump to next page in Scrapy -

Image
i'm trying scrape results here using scrapy. problem not of classes appear on page until 'load more results' tab clicked. the problem can seen here: my code looks this: class classcentralspider(crawlspider): name = "class_central" allowed_domains = ["www.class-central.com"] start_urls = ( 'https://www.class-central.com/courses/recentlyadded', ) rules = ( rule( linkextractor( # allow=("index\d00\.html",), restrict_xpaths=('//div[@id="show-more-courses"]',) ), callback='parse', follow=true ), ) def parse(self, response): x = response.xpath('//span[@class="course-name-text"]/text()').extract() item = classcentralitem() y in x: item['name'] = y print item['name'] pass the second page website seems gen...

python - differentiate sudo <command> and <command> -

i make user run sudo , normal user depending on choice.he use sudo or normal on not using sudo have disable functionalities rid of errors.so how know user given me sudo permissions execute or not? building application on python. after having read question few times, think know asking. correct in thinking want know how tell whether or not python script root permissions during runtime? if want check ahead of time, query system user id os.geteuid() , if returns 0 , script running root. however, alternative approach run code needs root privileges in try block. depending on trying do, may or may not better solution. have know type of exception expect if don't have needed privileges. makes little harder write code may end more flexible changing circumstances, such users enough privileges not root. may make more portable code, although exception may change 1 os another. e.g. try: function_that_needs_root() except mynotrootexception: print "skipping fu...

How can I perform efficient Deletions in Accumulo across multiple ranges? -

i have index table following schema: row cf cq name pob dob how efficiently delete multiple rows (i.e. john doe:new york:01/01/75 , jane doe:miami:06/21/80)? use batchdeleter , setranges of range (rows) want delete https://accumulo.apache.org/1.7/apidocs/org/apache/accumulo/core/client/batchdeleter.html

c# - LINQ group collection by an arbitrary lattice -

apologies if i'm missing basic. for given lattice array in lattice values represent minimum bucket, best way group array of values. e.g. double[] lattice = { 2.3, 2.8, 4.1, 4.7 }; double[] values = { 2.35, 2.4, 2.6, 3, 3.8, 4.5, 5.0, 8.1 }; groupbylattice(values, lattice); such groupbylattice returns igroupings like: 2.3 : { 2.35, 2.4, 2.6 } 2.8 : { 3, 3.8 } 4.1 : { 4.5 } 4.7 : { 5.0, 8.1 } edit: i'm green enough linq queries best can with: values.groupby( curr => lattice.first( lat => curr > lat) ) issues this: everything ends in first bucket - can understand why (of course first bucket satisfies case each after) i'm having hard time wrapping head around these in-place operations predicate want. i suspect having linq query inside of linq query not performant post-mortem solution , results: dmitry bychenko provided great answer, wanted provide followup may come across answer in future. had been trying solve: how can simplify huge da...

reactjs - Appending React States to another State -

is there proper way append state state in react? eg. state of have state of cat, dog , fish this.state = { cat:true, dog:true, fish:true, all: cat, dog, fish } this have currently: var chosenanimals = {}; chosenanimals["cat"] = this.state.cat; chosenanimals["dog"] = this.state.dog; chosenanimals["fish"] = this.state.fish; is there better way of doing this? to push elements in state array need : var chosenanimals = []; chosenanimals.push(this.state.cat, this.state.dog, this.state.fish); if @ array.push ( https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/array/push ) returns length, in code provided chosenanimals contain 3 , not array looking for. calling push on array , not assigning (or itself) add items array.

python - Elasticsearch delay in store and search immediately -

Image
i using elasticsearch python. , use dsl driver in python. my script below. import time elasticsearch_dsl import doctype, string elasticsearch import exceptions es_exceptions elasticsearch_dsl.connections import connections elasticsearch_index = 'test' class studentdoc(doctype): student_id = string(required=true) tags = string(null_value=[]) class meta: index = elasticsearch_index def save(self, **kwargs): ''' override set metadata id ''' self.meta.id = self.student_id return super(studentdoc, self).save(**kwargs) # define default elasticsearch client connections.create_connection(hosts=['localhost:9200']) # create mappings in elasticsearch studentdoc.init() student_doc_obj = \ studentdoc( student_id=str(1), tags=['test']) try: student_doc_obj.save() except es_exceptions.serializationerror ex: # catch both exception raise elasticse...

ios - Xcode 7.3.1 Working with iAd Bannerviews Objective-C -

after following countless tutorials , trying different methods, iad banners not show while running simulation, , if do, fade without displaying anything. this current code using display iad banner: -(void)bannerviewdidloadad:(adbannerview *)banner { [uiview beginanimations:nil context:null]; [uiview setanimationduration:1]; [banner setalpha:1]; [uiview commitanimations]; } -(void)bannerview:(adbannerview *)banner didfailtoreceiveadwitherror:(nserror *)error { [uiview beginanimations:nil context:null]; [uiview setanimationduration:1]; [banner setalpha:0]; [uiview commitanimations]; } i have delegated banner view, have imported iad framework in viewcontroller.h, , followed other necessary steps. however, while launching simulator (in phone size) ad not appear, after waiting considerable amount of time. have no errors or other indications have done wrong, , have been stuck on while. why won't banner show?

swift - How do I reset a variable at the start of each day? -

i have variable keeps track of user statistic want reset @ beginning of each day. how can that? since application not allowed run in background, seems have check every time application active don't know how reset variable have once. function wanted use: let beginingofday = nscalendar.currentcalendar().startofdayfordate(nsdate()) func resetcurrenttime(){ // date comparision compare current date , begining of day. let datecomparisionresult:nscomparisonresult = nsdate().compare(beginingofday) if datecomparisionresult == nscomparisonresult.ordereddescending || datecomparisionresult == nscomparisonresult.orderedsame { // current date greater or equal end date. currenttime = 0 //reset time tracker } } i wanted use function check when application launched problem application launched many time day. how can reset variable once @ beginning of day if user using application or when application becomes active or launched first time day? thanks...

Word Frequency from a CSV Column in Python -

i have .csv file column of messages have collected, wish word frequency list of every word in column. here have far , not sure have made mistake, appreciated. edit: expected output write entire list of words , count (without duplicates) out .csv file. import csv collections import counter collections import defaultdict output_file = 'comments_word_freqency.csv' input_stream = open('comments.csv') reader = csv.reader(input_stream, delimiter=',') reader.next() #skip header csvrow = [row[3] row in reader] #get fourth column open(output_file, 'rb') csvfile: row in reader: freq_dict = defaultdict(int) # "int" part # means values of dictionary integers. line in csvrow: words = line.split(" ") word in words: word = word.lower() # ignores case type freq_dict[word] += 1 writer = csv.writer(open(output_file, "wb+...

swift - Code runs fine on Playground; at the same time it yields an EXC_I386_GPFLT error -

Image
i'm having curious issue in playground prints expected result @ same time see error telling me execution stopped because of exc_i386_gpflt error. i'm using playground model how should api wrapper i'm writing used. idea of doing plan nice api future developers. the following entire "planning" code have written plan out wrapper. feel free copy , paste on playground see problem in action: class anilist { init() {} internal class userapis { weak var parent: anilist? = nil init(parent: anilist) { self.parent = parent } } lazy var user: userapis = { [unowned self] in let userapi = userapis(parent: self) return userapi }() } extension anilist.userapis { func me(_ completionhandler: (results: [string]) -> void ) { // logic, fetching stuff parent completionhandler(results: ["lorem", "sammet"]) } } let andy = anilist() andy.user.me { results...

Unable to work with Django (python 2.7, OS X 10.11.1) -

i'm pull hair out in frustration. trying start django project on new imac os x el capital. python 2.7 came installed on computer, , seems django. however, can't run django-admin. i've got django installed on laptop , didn't have trouble. per official documentation, try pip install --upgrade django==1.9.8 and terminal returns requirement up-to-date: django==1.9.8 in /library/python/2.7/site-packages/django-1.9.8-py2.7.egg then try in python: >>> import django >>> print(django.get_version()) 1.9 great! next try: django-admin.py --version and returns -bash: django-admin.py: command not found after googling it, seems path may issue? try: echo $path and get /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin on docs troubleshooting, "django-admin should on system path if installed django via python setup.py" try that. sudo python setup.py install a bunch of stuff happens, , extracting django-1.9.8-py2.7.egg /librar...