Posts

Showing posts from September, 2011

python - Override a field in parent class with property in child class -

where looks this: class a(object): def __init__(self, val): self.x=val self.y=42 # other fields class b(object): def __init__(self): self.a=22 # other fields class c(a,b): def __init__(self, val): super(c,self).__init__(val) @property def x(self): # if a.x none return value can compute a.y , b.a # if a.x not none return @x.setter def x(self, val): # set field value sometimes want set assumed value x hand, in case use a . in other cases want use more complicated approach involves computing a.x 's value on basis of information organized b . idea in code make c class can a (in terms of x field) doesn't need field value set hand, instead gets derived. what can't figure out how have c.x property shadow a.x field in sensible way. the line self.x = val in a.__init__ method invoke c.x setter . have handled here. handling per instance attributes here,

java - How to add to an arraylist without creating an embedded array -

i know arraylist has .add() method, reason, whenever add prexisting arraylist, end getting embedded array.... have method returns objectinputstream, 1 or more objects , depending on conditional, wanted add , present user, however, it's embedding objectinputstream array. for example: 1. [item1] 2. [item1, item2] 3. [[item1, item2], item3] 4. [[[item1, item2], item3], item4] it keeps going this. i'd prefer if more this: [item1, item2, item3, item4] the issue is, using arraylist.add() method instead of arraylist.addall() method. add() method adds object passed on list, addall takes collection, , adds each element in collection list- want. another issue note is, not using generics. have avoided error completely. i have sample code convenience in online java compiler ide . as side note, in future when asking programming questions, embed small sample of relevant code in online ide codiva or ideone , want answer.

html5 - passing information of an item selected in a select tag to a table with mvc 4 -

this part of view: 1- select tag content <select name="select1" id="select1" class="nostyle" style="width: 100%;"> <option></option> @{ foreach (var item in model) { <option value=""> @html.actionlink(item.title, "getvalindicateurs", new { idindicateur = @item.id_indicateur })</option> } } </select> 2-i can select item, problem need show parameters of item in following table: <tbody role="alert" aria-live="polite" aria-relevant="all"> @if (session["listvaleur"] != null) { foreach (sire_portail.models.valeurs_indcateur item in (list<sire_portail.models.valeurs_indcateur>)session[

javascript - Array only retriving first LatLng data from multiple locations an passes same all time to infowindow content -

ok problem facing trying retrive "latlng" array "locations" variable "tere" (sitelatlng). way shows value of first latlng value , keeps adding every marker. need passes "latlng" correspondant marker. appreciated. :) this code markers: var markers = []; function initmap() { var directionsdisplay = new google.maps.directionsrenderer; var directionsservice = new google.maps.directionsservice; var guanajuato = new google.maps.latlng(21.0158803, -101.2540116); var map = new google.maps.map(document.getelementbyid('map'), { center: guanajuato, zoom: 16 }); var locations = [ ['ocho', 21.017137, -101.253186, 1], ['siete', 21.017119, -101.252922, 2], ['seis', 21.017154, -101.253055, 3], ['cinco', 21.017444, -101.253144, 4], ]; var marker, i; var infowindow = new google.maps.infowindow(); google.

python - Looping through a paginated api asynchronously -

i'm ingesting data through api returns close 100,000 documents in paginated fashion (100 per page). have code functions follows: while c <= limit: if not api_url: break req = urllib2.request(api_url) opener = urllib2.build_opener() f = opener.open(req) response = simplejson.load(f) item in response['documents']: # here if 'more_url' in response: api_url = response['more_url'] else: api_url = none break c += 1 downloading data way slow , wondering if there way loop through pages in async way. have been recommended take @ twisted , not entirely sure how proceed. what have here not know front read next unless call api. think of like, can in parallel? i not know how can in parallel , tasks, lets try... some assumptions: - can retrieve data api without penalties or limits - data processing of 1 page/batch can done independently 1 other what slow io - can split

c++ - Why this code runs perfectly in visual studio with multibyte characher set but not with unicode char set? -

when run code on g++ , runs smoothly, when run code on visual studio wiith unicode char set option, doesn't print product id. can explain me how fix problem , why happens? #include <windows.h> #include <stdio.h> #include <iostream> using namespace std; wchar_t* getregistrykeyvalue(const char* regkey, const char* ppidname) { hkey registry; long returnstatus; dword regtype = 0; dword regsize = 0; char* ppid = 0; returnstatus = regopenkeyex(hkey_local_machine, regkey, 0, key_query_value | key_wow64_64key, &registry); if (returnstatus == error_success) { returnstatus = regqueryvalueex(registry, ppidname, 0, &regtype, 0, &regsize); ppid = new char[regsize]; /* value. */ returnstatus = regqueryvalueex(registry, ppidname, 0, &regtype, (lpbyte)ppid, &regsize); regclosekey(registry); if (ppid[regsize] > 127 || ppid[regsize] <

javascript - gzip compression is not detected by PageSpeed Insights (node.js) -

i build gzip-files gulp ( gulp-gzip ) , use them npm package connect-gzip-static : var app = express(); var servestatic = require('connect-gzip-static'); //... app.use(servestatic(__dirname)).listen(3000); however, pagespeed insights not detect gzip compression. but google chrome developer console says: response headers: content-encoding: gzip. other seo testing tools detecting gzip. why google doesen't ? i gziped html, js, css. should gzip svg's ? thanks! pagespeed insights should tell resources not gzipped. often third party resources out of control, or may types svg have not enabled yet. pagespeed insights should taken guide , not gospel. it's easy become hung on it. if ignore bigger reasons site slow save few bytes on 1 resource.

c# - The following code has the same result, but whichever is faster in bringing the result -

the first code used " join " but in second code not used " join " note result same. so have several questions which better ? which faster ? code01: (from member in dcontext.tb_familycardmembers select new { member.familycard_id, member.tb_familycard.nofamilycard, cardtype = member.tb_familycard.is_card == true ? "دفتر عائلة" : "بيان عائلي", firsn = member.tb_person.firstname, fathern = member.tb_person.fathername == null ? selectpersonbyid(int.parse(member.tb_person.father_id.tostring())).firstname : member.tb_person.fathername, lastn = member.tb_person.lastname == null ? selectpersonbyid(int.parse(member.tb_person.father_id.tostring())).lastname : member.tb_person.lastname, mothern = member.tb_person.mothername == null ? selectpersonbyid(int.parse(member.tb_person.mother_id.tostring())).firstname : member.tb_person.mothername, motherln = member.tb_pers

angularjs - Can't Inject Angular Controller in Mock Test -

Image
i can't inject controller in mocha test file, keeps showing error: i followed the documentation here , tried other approaches, here code in test file: var assert = chai.assert; var expect = chai.expect; var should = chai.should(); describe('suplements module', function(){ beforeeach(angular.mock.module('atari-app')); beforeeach(inject(function ($rootscope, $controller) { scope = $rootscope.$new(); controller = $controller('testcontroller', { '$scope': scope }); })); describe('list supplements',function(){ it('should list supplements', function(){ }); }); }); here app , controller: angular .module('atari-app', [ 'ui.router', 'ui.utils', 'oc.lazyload', 'ngresource', 'ngsanitize', 'ui.bootstrap', 'ui.select', 'authentication-app',

excel - How to conditional format data points on a chart -

so, using combination of tableau , excel create chart shows 2012 presidential election. on table, have cells of state names show red, if republican votes > democrat votes, , blue if democrat votes > republican votes. thing is, create chart, or scatter plot states data points, show 1 color, , in excel can change color manually, can't conditionally format data points on chart. how make colors change? to conditionally format, create calc field: if [rep votes] > [dem votes] 'red' else 'blue' end place on color shelf. i not sure type of chart wanted created few different ones. think gets you're looking for. https://dl.dropboxusercontent.com/u/60455118/160612%20stack%20question.twbx

java - How to create ArrayList properly? -

this question has answer here: type list vs type arraylist in java 14 answers below 2 ways how create arraylist : list<string/*or other object*/> arrlist = new arraylist();//imports list, arraylist arraylist<string/*or other object*/> arrlist = new arraylist();//imports arraylist what difference? method should used? the first form recommended for public interface of class (say, declaration of attributes in class). it's well-known advice should program interface, not concrete implementation (this stated in design patterns ) - number of classes have import has little quality of code , design. the advantage of first form it'll allow swap implementations later on, if need arises - whereas second implementation sets in stone implementing class, making code harder evolve , less flexible. there cases when it's ok declare , use concr

php - Laravel continously check if there is a new item in an array -

i new laravel , want implement system in projects "alerts" users when there new comment on 1 of there posts. i query comments on posts of logged in user , put in array , send view. goal make alert icon or when there new item in array. is there easy way laravel helper function or something? can't seem find in laravel documentation. is right way approach this? here's code: $uid = auth::user()->id; $projects = user::find($uid)->projects; //comments if (!empty($projects)) { foreach ($projects $project) { $comments_collection[] = $project->comments; } } if (!empty($comments_collection)) { $comments = array_collapse($comments_collection); foreach($comments $com) { if ($com->from_user != auth::user()->id) { $ofdate = $com->created_at; $commentdate = date

javascript - Ember.js - having a subnav display on application.hbs on click only without rendering a different template -

Image
i'm having issues trying subnav display on click in ember. in application template have nav bar, , @ root have index template full browser width template sitting behind navbar on application template. looks this: what want happen when 'about' clicked, subnav displays on white horizontal bar directly below main nav. white horizontal bar part of application template. that's thing on page want change though when 'about' clicked. when when click item on subnav, 'staff' renders about.staff template. my problem getting happen on application template. because if user on 'programs' template, , click about, want user stay on programs template subnav still drop down below main nav. i've tried nested routes: ew.router.map -> @.resource "about", -> @.route "philosophy" @.route "leadership" @.route "staff" @.route "affiliations" @.route "conditions" @.rou

IntelliJ: Delete Highlighted Portion With Just the Delete Key -

one of more annoying aspects of intellij me how default way delete portion of text highlight mouse press shift+delete, rather delete. i'm aware can go preferences --> keymap customize controls this, i'm not sure function change , how set delete key. i'm using 2016.1.3 community edition os x. i figured out going on — had rather absentmindedly installed ideavim plugin, adds weird (vim-like) keybindings, 1 of need press shift+delete delete highlighted portion.

python 3.x - How to decide whether use a for loop or list comprehensions/generator expression? -

i use loop long , complicated expressions way more readable. use list comprehension/generator expression short expressions or filter()/map(). , middle sized expression, decide use intuition. read pep 202 , pep 289 didn't find rules using list comprehension , generator expressions.

scheme - Define queue in a function -

i trying create new queue in 1 of functions, getting error define: found definition not @ top level how can resolve this? need create queue somewhere inside. cannot create auxiliary variables outside of it. (define (bfs-graph x g) (define q (make-queue)) (enqueue! q x) ... work queue ) (define (reachable? x y g) (cond [(empty? (graph-edges g)) #f] [else (bfs-graph x g)] ) ) edit: ok, seems works. try play code more. thanks. (define (reachable? x y g) (let ((q (make-queue))) (cond [(empty? (graph-edges g)) #f] [else (bfs-graph x g q)] ) ) ) (define (bfs-graph x g q) (enqueue! q x) ) the code posted should work, try changing language - set "determine language source" , add line @ beginning of file: #lang racket if reason can't use different language, equivalent wrote: (define (bfs-graph x g) (let ((q (make-queue))) (enqueue! q x) ; ... work queue ))

stateful - How to close a div permanently using jQuery -

i have 5 pages , including banner in 1st page, if user closes banner in 1st page banner should not appear in other pages too. $(document).ready(function(){ $(".alert-banner-hide").on("click", function(){ $("#alert-banner-container").hide(); }); }); could please me on this? in advance. use sessionstorage object have stateful : for on-close banner event : $(".alert-banner-hide").on("click", function(){ $("#alert-banner-container").hide(); sessionstorage.setitem("banner-closed","yes"); //add instruction }); and on pages load / document ready : // copy/paste whole code below & don't worry $(function(){ if (sessionstorage.getitem('banner-closed')==="yes"){ //trigger close banner $("#alert-banner-container").hide(); } })

java - How to access data in main Activity from a button pressed in listView? -

so have listview custom adapter , want whenever press button listen onitemclicklistener mainactivity. so question pass while calling onclick on button present in listview can read main activity? @override public view getview(final int pos, view convertview, viewgroup parent) { holder holder = new holder(); final customproductadapter p=this; final view rowview; rowview = inflater.inflate(r.layout.product_list_test, null); holder.productview=(textview) rowview.findviewbyid(r.id.productview); holder.descview=(textview) rowview.findviewbyid(r.id.descview); holder.imageview=(imageview) rowview.findviewbyid(r.id.imageview); holder.productcost=(textview) rowview.findviewbyid(r.id.productcost); holder.ibutton=(imagebutton) rowview.findviewbyid(r.id.imagebutton); holder.ibutton.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { //what put here? } }); holder.produc

jquery - Toggle the visibility of an element -

i have following markup: <a href="#" class="menu">menu</a> <ul> <li><a href="#">home</a></li> <li> <a href="#">content</a> <ul> <li><a href="#">files</a></li> <li><a href="#">posts</a></li> </ul> </li> <li><a href="#">shop</a></li> </ul> 1 - need toggle visibility of parent ul when first anchor (class="menu") clicked 2 - need toggle visibility of each child ul when anchor above clicked how can jquery? thank you, miguel jquery(function(){ $('a[href="#"]').click(function(){ $(this).next('ul').toggle() }) })

javascript - AngularJS debugging tools for IE like Batarang -

i wondering if there alternative plugins chrome extension batarang far debugging , profiling internet explorer (it can edge, fine). our organization has banned chrome , heavy angularjs development, nice have tool troubleshooting weird issues unfortunately, there no comparable tool ie extension comming edge : https://developer.microsoft.com/en-us/microsoft-edge/extensions/#available-extensions , wait , see....

csv - Trying to read a list of floats, integers, and strings from a file with sscanf() in C is not working as expected -

i working on program reads large table file, periodic table precise. struct periodic *createtable(){ char format[] ="%d\t%3s\t \ %20s\t%f\t \ %100[^\t]\t%f\t \ %d\t%f\t%d\t \ %d\t%d\t%20[^\t]\t \ %7s\t%17[^\t]\t \ %d\t%d\t%f\t \ %40[^\t]\t%7s\n"; struct periodic *tableptr = malloc(sizeof(*tableptr)*num_elements); file *fp; fp = fopen("periodictable.csv","r"); char buff[150]; int i,err; for(i=0;i<num_elements;i++){ if(fgets(buff,150,fp)){ printf("%s\n",buff); err = sscanf(buff,format,&(tableptr->num),&(tableptr->sym),&(tableptr->name), &(tableptr->weight),&(tableptr->config),&(tableptr->neg), &(tableptr->neg),&(tableptr->rad),&(tableptr->ion_rad), &(tableptr-&g

IOS what method is called when keyboard pops up -

i making custom ios keyboard. wondering if there method called whenever user selects keyboard, making pop on screen. because want run code whenever keyboard pops up. no method called. notification posted though. can read more in managing keyboard section of text programming guide ios .

Git stash freezes (console becomes unresponsive) -

Image
git freezing on kind of git stash command. press [enter] nothing happens...ever. but other git commands seem work fine. can pull, commit, etc. i tried command line multiple times. tried on multiple repository locations (some of clean checkouts.) restarted computer multiple times. uninstalled git, , reinstalled git same result: stash freezes until kill tm. as final added complication, i'm running sourcetree (1.8). i've got sourcetree running embedded git version: guess what? if stash using sourcetree...it works fine. windows 10, 64bit git 2.8.4 as alternate (hack), in light of other answer, i've decided piggyback on sourcetree's local "embedded" version of git work. i uninstalled 2.8.4 version. i manually added sourcetree git path windows environment path. me c:\users\{username}\appdata\local\atlassian\sourcetree\git_local\cmd works champ! temp fix until can sort out cylance issue.

how to migrate virtual machine scale set in windows azure (asp.net) -

i'm working on web app , want migrate web app virtual machine scale set in windows azure cloud,i'm new cloud computing ,till didn't got proper tutorial virtual machine scale set,please this a few things consider.. you build custom vm contains complete app, or use vm extensions deploy app on platform image each time new vm in scale set deployed. see: https://msftstack.wordpress.com/2016/04/20/deploying-applications-in-azure-vm-scale-sets/ thoughts on this. might depend on how need install on base image, , how fast want scaling be. do need autoscale based on resource usage or plan manually increase/decrease number of vms in set? see https://azure.microsoft.com/en-us/documentation/articles/virtual-machine-scale-sets-windows-autoscale/ a way started scale sets deploy existing template directly azure quick start templates. @ https://github.com/azure/azure-quickstart-templates , search vmss. these templates give idea of of options have. to learn basics vm sca

asp.net mvc - Dynamic SQL binding with MVC model -

in following code, know query output mapped class source. unlike this, have sql[this query not fixed], query output different[different column names , types, , number of columns]. how can make model on fly query not fixed? public ienumerable<source> get_all_sources() { string _sql = "select column1,column2 source"; var q = __context.database.sqlquery<source>(_sql); return q.tolist(); } eg: first time : query result : column1, column2, column3, second time might 1 column, column1. want build model grab query output on fly. you serialize data (eg json) , return serialized string deserialize on other end (wherever ends up). if return trypes similar enough, have them inherit same superclass. you use generics (see: dynamic return type of function )

hadoop - Deleting values in Hbase-Hive Integration -

i using hbase data storage , have hive table read data hbase using storage handler. i using composite rowkey (struct (region,country,date,id)) . is there way delete specific data hbase-hive integaration ,either hbase or hive?? can below done using hbase shell commands or hive queries delete table region=eu , country=us , date=2015-06-11; using hive 0.14 thanks in advance. based on https://cwiki.apache.org/confluence/display/hive/hive+transactions#hivetransactions-limitations tables must bucketed make use of these features. tables in same system not using transactions , acid not need bucketed. external tables cannot made acid tables since changes on external tables beyond control of compactor (hive-13175). so apparently there no way perform delete in hbase using hive.

Android exit transition excludeTarget not working inside android.support.v4.widget.DrawerLayout -

i have activity includes viewpager 3 fragments. first tab, calling activty , trying exclude toolbar , tab bar exit transition. if (build.version.sdk_int >= 21) { getactivity().getwindow().setexittransition(new slide(gravity.left).excludetarget(r.id.toolbar,true)); pair<view, string> pair1 = pair.create((view) matcvr, matcvr.gettransitionname()); pair<view, string> pair2 = pair.create((view)mattxt, mattxt.gettransitionname()); activityoptionscompat options = activityoptionscompat.makescenetransitionanimation(getactivity(),pair1,pair2); activitycompat.startactivity(getactivity(), matintent, options.tobundle()); } the issue excludetarget seems not working , whole view sliding left. have tried addtarget below including viewpager alone.but in case, default fade animation happening. getactivity().getwindow().setexittransition(new slide(gravity.left).

Trying to pull stock data from Yahoo Finance using Python 3.5 -

hello have code getting these errors main loop 'tuple' object has no attribute 'read' , main loop module 'urllib' has no attribute 'urlopen' def pulldata(stock): try: fileline = stock+'.txt' urltovisit = 'http://chartapi.finance.yahoo.com/instrument/1.0/'+stock+'/chartdata;type=quote;range=10d/csv' sourcecode = urllib.urlopen(urltovisit).read() splitsource = sourcecode.split('\n') eachline in splitsource: splitline = eachline.split(',') if len(splitline)==6: if 'values' not in eachline: savefile = open(fileline,'a') linetowrite = eachline+'\n' savefile.write(linetowrite) print('pulled',stock) print('sleeping') time.sleep(5) except exception e: print('main loop',str(e)) pulldata(

Android UiAutomator detecting WebView elements outside device area -

Image
i working on automation testing on hybrid apps using appium. while running tests, noticed elements of navigation bar on pages being detected outside device area in android uiautomator. makes commands operating on elements in region fail. can't detect element via xpath , can't click on it. i've attached screenshot showing way elements detected. is bug in uiautomator? if so, there way work around this?

objective c - append unsigned char '\0' to NSString in iOS -

this question has answer here: how convert unsigned char nsstring in ios 2 answers convert hex string ascii format [duplicate] 1 answer while converting unsigned char nsstring ,\0 not appending in nsstring. example : char str[]="123400005678"; unsigned char strval[20]; memset(strval,0x00,sizeof(strval)); int ret=unsignedchar2hex1byte(str,strval); after unsignedchar2hex1byte calculation strval output , strval[0] = '\x12' strval[1] = '4' strval[2] = '\0' strval[3] = '\0' strval[4] = 'v' strval[5] = 'x' but assigning strval nsstring upto \x124 output , 2 length of nsssting . can 1 explain , how assign entire strval nsstring or nsmutablestring , length of strval should 6.

javascript - Drawer menu performances -

i'm developing side menu web-application (in mobile version) using angular2. this class when menu closed .main-drawer { left: -300px; width: 300px; max-width: 100%; z-index: 2; transition-property: left; transition-duration: 300ms; transition-timing-function: ease-out; } when user press open-menu button add following class using jquery .main-drawer.opened { left:0; transition-property: left; transition-duration: 300ms; transition-timing-function: ease-out; } this js code: let drawer = jquery ('.main-drawer'); drawer.toggleclass ('opened', !drawer.hasclass ('opened')); using code on desktop computers performances good, on mobile version laggy. there way increase per performance? the menu pretty lightweight, not contain lot of nodes. noticed other websites have pretty performances if menu full of things. thanks lot translating x / y more performant transitioning or animation top / left

sql server - Rollback transaction from called stored procedure -

i have simple scenario: logger procedure , main procedure logger called. trying rollback transaction inside logger started in main, getting errors. not sure why. here 2 procs , error message receive: create procedure splogger begin if @@trancount > 0 begin print @@trancount rollback end end go create procedure spcaller begin begin try begin transaction raiserror('', 16, 1) commit transaction end try begin catch exec splogger end catch end go exec spcaller 1 msg 266, level 16, state 2, procedure splogger, line 15 transaction count after execute indicates mismatching number of begin , commit statements. previous count = 1, current count = 0. 1) error message clear: number of active txs @ end of sp should same number of active txs @ beginning. so, when @ execution of dbo.splogger begins number of active txs ( @@trancount ) 1 if execute within sp rollback statement this'l

Can I make a Wifi router using an Arduino? -

basically, need make @ least 2 arduino communicate each other via wifi. have brought wemos d1 (which similar arduino built-in wifi shield) , task make client , server communication without (real , big)router in between. after few weeks of "googling", found every examples of wifi communication required router in between. so, decided make arduino wifi router, possible? thanks million. :) well, found quite useful after time, , wemos d1 wap https://learn.sparkfun.com/tutorials/esp8266-thing-hookup-guide/example-sketch-ap-web-server

ruby on rails 3 - redirect_to external url passing params -

i need pass params in redirect_to method external url... i know can redirect: redirect_to my_url_path(param1: "foo", param2: "bar") but want external url. example: redirect_to "www.example.externaldomain.com/process/xightdjtrideor", param1: "foo", param2: "bar" you can use ruby uri module , create own helper: def generate_url(url, params = {}) uri = uri(url) uri.query = params.to_query uri.to_s end then url: redirect_to generate_url("www.example.externaldomain.com/process/xightdjtrideor", :param1 => "foo", :param2 => "bar")

mongodb - Take mongdb dump from amazon awz from local -

i trying take mongodb dump amazon aws server. kinldy share command from local working sudo mongodump -d db** -o /opt/backup/ how server sudo mongodump -d db** -i /opt/x.pem ubuntu@ip:/ there 3 things need in order make sure remote mongodump possible - make sure security group allows communications between computer , port 27017 (or other port mongo running on server) check if mongodb configured bind specific ip (by default binded 127.0.0.1 allows local communications only) change mongodump command - mongodump -d <db**> -u <username> -p <password> --host <server_ip/dns> having said that, better ssh server , dump data locally, zip , copy local machine in order minimize network load. if have ssh access server better (and more secure) approach dumping data.

python - Django website on Apache with wsgi failing -

so i'm lunch first django website , have server has been configured host php websites , i've decided test simple empty project familiar process so python version in server bit old (2.6) couldn't install latest version of django , installed 1.6 , since it's test that's not important (im going upgrade python version when website ready lunch ) so i've installed django , created new project called testing in dire /home/sdfds34fre/public_html/ which can see using domain http://novadmin20.com and after reading documentation on django (unfortunately have removed doc 1.6 , had use 1.9 ) , wsgi i've updated httpd.conf <virtualhost 111.111.111.111:80> servername 111.111.111.111 documentroot /usr/local/apache/htdocs serveradmin somemeail@gmail.com <ifmodule mod_suphp.c> suphp_usergroup nobody nobody </ifmodule> <directory /home/sdfds34fre/public_html/testing/testing> <files wsgi.py

swift - Assertion or Runtime Error holds execution in thread instead of code-line -

Image
whe using normal "assert()" statement xcode stops thread execution takes place. i tried play around adding exection breakpoints but still can't xcode stop @ line assertion happens. e.g. let x:string? = nil assert(x != nil ) one option add general exception breakpoint in breakpoints pane. before adding exception breakpoint, xcode stops in app delegate mentioned, enabled stop on assert statement itself.

google signin - Firebase authenticate with backend server -

this question has answer here: is still possible server side verification of tokens in firebase 3? 2 answers my android app uses google sign in , works well. add tokenid every server request , verify on server. easy implement using this example (i'm using python). i'm migrating go through firebase can add other authentication providers. problem can't seem verify token on server. need verification, no creation. firebase seems provide libraries node.js , java ccould use standard jwt library pyjwt . find firebase's public key in order verrify token? i found answer in this post . public keys firebase can found here . kid field in header determines key use.

ruby on rails - Leaderboard ranking via elasticsearch (with tire) -

i have mapping boils down following (unrelated fields removed): mapping indexes :id, type: 'integer', index: :not_analyze indexes :first_name, boost: 5, type: 'string', analyzer: 'snowball' indexes :votes, type: 'integer', index: :not_analyzed end at moment i'm calculating ranking via postgres, given following entries: | first_name | votes | ---------------------- | andy | 5 | | barry | 8 | | carl | 5 | | derek | 1 | using postgres, can following: | first_name | votes | rank | ----------------------------- | barry | 8 | 1 | | andy | 5 | 2 | | carl | 5 | 2 | | derek | 1 | 4 | is possible somehow calculate ranking via elasticsearch? i don't believe elasticsearch place it, since updating single document require recalculation of ranking values. not possible, far can tell. instead, once results can use ruby calculate rankin

javascript - How to use ng-repeat to show all the values coming from the API in which I need to show only one key value from all the objects? -

through api having 2 or more objects. in objects there different. different key values id , name , account etc. need show ids of objects, in select box. i using ng-repeat in html: <select ng-model="selectedid" class="form-control"> <option ng-repeat="id in editidoptionsdata" value="{{id}}">{{id}}</option> </select> and response doing : deal.getiddata($scope.accountdetail.accountusers[0].role, $scope.accountdetail.id) .then(function successcb(data){ $scope.editidoptionsdata=data; }); but in select box getting objects. can tell me how fetch id object in 1 value selected default? what think you're doing setting whole object option <select ng-model="selectedid" class="form-control"> <option ng-repeat="id in editidoptionsdata" value="{{id}}">{{id}}</option> </select> the 'id' in code 1 whole object. should is:

java - Regex Match word that include a Dot -

i have question have sentence example: "halloanna daveca.nn dave anna ca. anna" and wanna match single standing "ca." . my regex : (?i)\b(ca\.)\b but doesn't work , don't know why. ideas ? //update i excecute with: testsource.replaceall() and with pattern.matcher(testsource).replaceall(). both doesn´t work. you should use this: pattern.compile("(?i)\\b(ca\\.)(?=\\w)").matcher(a).replaceall("some text"); which if omit java escapes gives regex: (?i)\b(ca\.)\w . every \ in normal regex has escaped in java - \\ . also, before word have word boundary ( \b ), applies part in string have change whitespace alphanumeric character or other way around. in case have dot, not alphanumeric character, can't use \b @ end. can use \w means non-word character following dot. use \w need ignore in capture group (so won't replaced) - (?= . another issue used . , matches character, want match real dot, h

php - 2 different action in one form -

i have form called addcustomer.php . it's contain firsname, lastname, mobile fields.i have 2 button on form. onr button saving data , others sending sms customers. want when click second button 3 data fields passed form called smsinfo.php. action saving data works when direct smsinfo . there no data on form . <form method ="post" name = "custform" action=""> <div class="cell_2_2"><label class="lblfields">firstname:</label>&nbsp;<input type="text" name="firstname" autocomplete="off"/></div> <div class="cell_3_2"><label class="lblfields">lastname :</label>&nbsp;<input type="text" name="lastname" autocomplete="off"/></div> <div class="cell_5_2"><label class="lblfields">mobile :</label>&nbsp;<input type="text" name="

c++ - Glorious Crashing while copying lists -

so i'm ready toss computer out of window, , i'm @ point figure should ask before destroy expensive piece of equipment. my program has list filled in automatically (i manually input items), , outputs it. then, have block of code output again using assignment operators, , third copy copy constructor. the assignment operator crashes program, if comment out let copy constructor, list comes out empty. anything says "todo" can ignore, that's noted me fix later. here action happens: list.cpp (this not main function, there's nothing wrong there) list::list() : m_pfront(0), m_pback(0), _pdata(0) {} list::~list() { clear(); } list::list(const char* p) { if(!p) { _pdata = 0; return; } if(strlen(p) == 0) { _pdata = 0; return; } _pdata = new char[strlen(p) + 1]; strcpy(_pdata, p); } void list::c

Recursively monitor a HDFS directory spark streaming -

i need stream data hdfs direcory via using spark streaming. javadstream<string> lines = ssc.textfilestream("hdfs://ip:8020/directory"); above pretty job in monitoring hdfs directory new files, limited same directory level, does'nt monitor nested directories. i comes accross following posts mention adding depth parameter api https://mail-archives.apache.org/mod_mbox/spark-reviews/201502.mbox/%3c20150220121124.dbb5fe03f7@git1-us-west.apache.org%3e https://github.com/apache/spark/pull/2765 the problem in spark version 1.6.1 (tested) parameter not present, hence cannot use it, dont want change original source eighther javadstream<string> lines = ssc.textfilestream("hdfs://ip:8020/*/*/*/"); some post in stack overflow mention use above syntax, doesnt work eighter. am missing something? looks patch created never approved due difficulties s3 , directory depth. https://github.com/apache/spark/pull/6588

javascript - Set ID in PUT method nodejs -

have code on server apiroutes.put('/intake', function(req, res) { intake.findbyid({id, function(err, intake) { if (err) res.send(err); check : true; intake.save(function(err) { if (err) { return res.json({success: false, msg: 'error'}); } res.json({success: true, msg: 'successful update check state.'}); }); }}) }); i should set id value frontend, don't know how can set in function. try apiroutes.put('/intake', id, function(req, res), id not defined on front in controller.js: $scope.changecheck = function(id) { console.log(id); mservice.intake("put", $scope.intake, {"action": "put"}, id) .success(function(data, status, headers, config) { }).error(function(err) { mservice.errorhandler(status); }); }; and in services file: intake : function(method, data, params, value) { var endpoint = "";