Posts

Showing posts from March, 2010

swift - Overriding a function outside its class -

i came across strange behaviour. following code produces compile error call bar() message: "missing argument parameter #1 call" func bar() { println("bar no argument") } class classa { func bar(varofanytype: string) { println("bar argument") } func foo() { bar() } } if change bar() function's name no errors: func barnamechanged() { println("bar no argument") } class classa { func bar(varofanytype: string) { println("bar argument") } func foo() { barnamechanged() } } what's reason compiler not allowing override function outside class? cheers, daniel at moment, swift compiler cannot distinguish between method , global function same name, regardless of overloading. the solution prefix global function module name, e.g., func bar() { } class classa { func bar(anything: string) {} func foo() { module.bar() } }

html - Need Help Cleaning CSS Script / Overriding Bootstrap -

i'm not computer programmer, i've been assigned task of designing webpage. here's have: <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>example</title> <!-- bootstrap --> <link href="file:///users/theresa/desktop/1page/bootstrap/css/bootstrap.min.css" rel="stylesheet" media="all"> <!---custom --> <link href="file://localhost/users/theresa/desktop/1page/custom.css" rel="stylesheet"> <!-- html5 shim , respond.js ie8 support of html5 elements , media queries --> <!-- warning: respond.js doesn't work if view page via file:// --> <!--[if lt ie 9]> <script src="htt...

android - How do I logout from AccountManager for my own Authenticator? -

i following answer this question . but error: java.lang.nosuchmethoderror: no virtual method removeaccount(landroid/accounts/account;landroid/app/activity;landroid/accounts/accountmanagercallback;landroid/os/handler;)landroid/accounts/accountmanagerfuture; in class landroid/accounts/accountmanager; or super classes (declaration of 'android.accounts.accountmanager' appears in /system/framework/framework.jar). how logout properly? public void logout() { final account accounts[] = maccountmanager.getaccounts(); if (accounts.length > 0) { maccountmanager.removeaccount(accounts[0], (activity) context, new accountmanagercallback<bundle>() { @override public void run(accountmanagerfuture<bundle> future) { try { bundle bnd = future.getresult(); log.d(tag, string.valueof(bnd)); } catch (exception e) { e.printst...

excel - Using simplemail in Haskell throws broken pipe error -

i have haskell program wrote on year ago , has been running fine until couple of months ago. what changed? program builds series of excel report files using spreadsheetml (of contributor) , emails them attachments list of users. program controlled comma separated text file each line represents single report , contains report title, list of database keywords (separated |), , list of recipient email addresses (also separated |). three months ago file restructured change reports generated , whom distributed. since then, 1 line in file killing program broken pipe error. error message program is: createexcel: fd:7: hputbuf: resource vanished (broken pipe) the program accepts command line parameter control whether or not send reports. if parameter false, sendreport method (below) never called , no error reported. therefore, believe before call sendreport solid. here code produces error: makeaddress :: string -> address makeaddress addr = address nothing (t.pack addr) sendre...

python - OpenCV detection with different colorspace -

i using opencv detect objects cascade classifiers trained on grayscale images , testing detection on different color spaces (images color) , calculating precision/recall/harmonic mean. im wondering why same results greyscale , rgb different in other colorspaces? # read image image = cv2.imread(imagepath) # convert grayscale (default algorithm) if colorspace == "gray": colorcvt = cv2.cvtcolor(image, cv2.color_bgr2gray) elif colorspace == "hsv": colorcvt = cv2.cvtcolor(image, cv2.color_bgr2hsv) elif colorspace == "hls": colorcvt = cv2.cvtcolor(image, cv2.color_bgr2hls) elif colorspace == "lab": colorcvt = cv2.cvtcolor(image, cv2.color_bgr2lab) elif colorspace == "luv": colorcvt = cv2.cvtcolor(image, cv2.color_bgr2luv) elif colorspace == "yuv": colorcvt = cv2.cvtcolor(image, cv2.color_bgr2yuv) elif colorcvt --"rgb" ...

ios - Swift create instance of custom cell before loading the tableView? -

i've run issue. have created dynamic tableview 2 prototype cells. if imagine instagram profile. has information user , underneath has feed of posts. recreated ui making tableview 2 cells, 1 profile part thats first cell, cells after generated each post have made. problem lot of logic of loading user's information first cell in viewdidload , viewwillappear of viewcontroller, not custom cell class. therefore, trouble having sharing outlets custom cell class view. want able access outlets custom cell , give them title, text, color, etc. before loading table. there anyway this? how preload custom cell? wish make cell non-reusable can connect outlets viewcontroller , avoid "outlets cannot connected repeating content" error. first cell not repeating content specific user loads page. idk do, suggestions? tried making first cell view(not table cell) above posts table repeating cells not scroll 1 on page. i lot of logic of loading user's information first...

Best practise - C# .Net console app POST to a url -

what best approach make post request web service url, in console app? i tried using webclient.uploadstring fails whenever posted data bigger. i tried httpclient it's async call.. had additionally use manualresetevent keep alive till server response received.. i'd know what's best way this. please let me know if mpre info required. what mean "huge"? if posting large amounts of data url, exceeding maximum request size, in case no method of requesting url amount of post data work.

linux - Triggering AutoKey Script via Mouse Button - How To? -

Image
i trigger autokey script pressing middle mouse (restricted application via window filter). unfortunately autokey lets me set keyboard short-cuts while mouse buttons ignored. seems autokey not @ allow mouse buttons triggers. (see selection screen below.) is there workaround lets me run autokey script via pressing mouse button? take @ xbindkeys. use make single modifier keys hotkeys (such rctrl), read capable of using mouse buttons trigger. https://www.linux.com/news/start-programs-pro-xbindkeys then can assign command "bash -c 'xdotool key ctrl+shift+super+alt+1'" mouse button, , make hotkey-script in autokey waiting combination.

c# - XmlSerializer adds namespaces to all elements on serializing -

i have serialize function serializes entity (customer object). xmlserializer created using new xmlserializer(entity.gettype()) i have 2 test cases call function. first test gets a list of customers , sends 1 of active customer serialized works well. xml output created has namespace in root element (i.e. customer element/tag) example: <customer xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" domain="xxx" sparse="false" xmlns="http://schema.xxx.com/finance/v3"> <id>1099</id>... second test calls customer queryservice , uses linqextender query results query service , returns active customer. when second test calls serialize method causes xml output have namespace added elements instead of having root element. example: <customer xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:xsi="http://www.w3.org/2001/xmlschema-insta...

graph - OrientDB Edge Query -

i have time series model uses linkmaps , connects vertex event edge called registered_events year->month->day->hour -> edge (registered_events) -> event i trying expand edge display events having no success. query select expand(month[12].day[3].hour[23]).out('registered_event') year year = 2015 the output of query below metadata properties out @rid @version @class hour registered_events #24:7 41 hour 23 #27:0 #27:1 #27:2 #27:3 #27:4 #27:5 have tried this? select expand(month[12].day[3].hour[23].out('registered_event')) year year = 2015 if using v 2.1 rcx suggest use unwind operator instead of expand: select month[12].day[3].hour[23].out('registered_event') events year year = 2015 unwind events

matlab - mat2cell to divide 3D image into blocks -

i have 4d image of size 60 x 80 x 12 x 350 , i.e. 3d image each voxel has time series (of 350). now want use mat2cell divide 3d image cubes of dimension k*k*k . each voxel in cube vector of size 350 (the time series). i think mat2cell don't know how exactly. each cell should contain in end 3d block of image each voxel of block vector of size 350. assuming 4d matrix called m . need have vectors elements sum size(m, i) i = 1:4 . assuming k has value, tried both 4 (because it's common factor of sizes specified) , 3 (because it's not). k = 3; mprime = mat2cell(m, ... [k*ones(1, floor(size(m,1)/k)), mod(size(m,1), k)], ... [k*ones(1, floor(size(m,2)/k)), mod(size(m,2), k)], ... [k*ones(1, floor(size(m,3)/k)), mod(size(m,3), k)], ... ones(1, size(m,4)));

java - Unformat formatted String -

i have simple formatted string: double d = 12.348678; int = 9876; string s = "abcd"; system.out.printf("%08.2f%5s%09d", d, s, i); // %08.2f = '12.348678' -> '00012,35' // %5s = 'abcd' -> ' abcd' // %09d = '9876' -> '000009876' // %08.2f%5s%09d = '00012,35 abcd000009876' when know pattern: %08.2f%5s%09d , string: 00012,35 abcd000009876 : can "unformat" string in way? eg. expected result 3 tokens: '00012,35', ' abcd', '000009876' this specific pattern. general parser formatstring, (because call unformatting parsing) different. public class unformat { public static integer getwidth(pattern pattern, string format) { matcher matcher = pattern.matcher(format); if (matcher.find()) { return integer.valueof(matcher.group(1)); } return null; } public static string getresult(pattern p, string format,...

paypal - retrieve all credit cards by payer_id or external_customer_id -

i'd store user's credit cards on paypal. all credit cards stored external_customer_id unique , same id of our system. i'd retrieve credit cards external_customer_id paypal. is possible? or should store credit card token (or id) , find token? thank in advance.

c - GTK3 and multithreading, replacing deprecated functions -

i replace deprecated functions gdk_threads_enter()/leave() in application uses threads. application now, works perfect ( although not sure if right way it ). my main loop, runs gtk_main , signal handlers. when receive start button, start thread, runs in background along main. how can update gui thread. know per documentation of gtk3 , gdk3, avoid using gdk_threads_add_idle() or gdk_threads_add_timeout() but how do if want updating done when click start? there example. not asking how use gdk_threads_add_idle() , asking how run worker function in main without thread after clicking start. button clicked --> start worker function "in thread previously" --> update large amount of gui elements in gui window. you have 3 ways it: make computation in button callback , use gtk_event_pending() / gtk_main_iteration() use g_idle_add() or others, , gtk_event_pending() / gtk_main_iteration() use thread, mutex, , g_idle_add() or others. nor...

html - CSS: Format Based on Number of Children Elements (bonus: eliminate extra white space) -

this question has answer here: can css detect number of children element has? 7 answers for project i'm working on, had wrap head around way format children of element based on how many exist within given element. example: <nav> <ul> <!-- items here may vary //--> <li>option</li> <li>option</li> <li>option</li> </ul> </nav> based on script i'm running, ul tag can have anywhere between 3 , 5 li elements within of varying size. however, in layout, these need have same width, , fit within block has fixed width. running issues in formatting rendered white space between li tags, if gave them proper width. amount-based formatting the solution came may not advanced other methods i've seen, including perform arithmetic calculations during rende...

javascript - Is there any easier or shorter way to write this repeat code? -

i wondering if there shorter/ easier way write repeating code. if name entered prompt box doesn't have send error message , reput it. just dont have explain alot, heres code: function error() { alert('you must enter name.'); } var name = prompt('what name?', 'name'); function repeat() { var name = prompt('what name?', 'name'); if(name === '') { error(); repeat(); } } if(name === '') { error(); repeat(); } like this: var name; while(!(name=prompt('what name?', 'name'))) { alert('you must enter name.'); } how works the while loop repeats until condition met. in case, condition is: !(name=prompt('what name?', 'name')) this part of expression assigns prompt value name (as you're aware): name=prompt('what name?', 'name') in javascript, assignment variable returns value. (that...

multithreading - Sharing a mvar between threads -

i'm trying make program print arrows until user press enter (see code bellow). the problem when press enter, see "stop" string in console, doesn't change value of m in outputarrows function. how can share state? import control.concurrent import control.concurrent.async import control.monad waitforinput m = getline putstrln "stop" putmvar m true outputarrows m = stop <- readmvar m unless stop $ threaddelay 1000000 putstr ">" outputarrows m main = m <- newmvar false th1 <- async (waitforinput m) th2 <- async (outputarrows m) wait th1 wait th2 your putmvar doesn't put new value in mvar blocks indefinitely. mvars boxes can hold single value. if want replace value, need take out old value first. if don't need blocking behavior of mvar, should use regular ioref or possibly tvar if need ensure more complex operations run atomically.

Azure Table Storage: Storing Relationships -

when storing 1 many relationship in azure table storage (such storing id of owner of record) store both partitionkey , rowkey 2 separate fields? or somehow concatenate 2 fields 1 field purpose of simpler storage? edit - more clarity on i'm asking i know table storage not relational. , i'm not looking foreign key integrity or cascading deletes or that. but without being "relational" there still common need store pointer record in table. has thousands of uses. example of storing user created record 1 example. storing sort of list or array example (such list of "work experience" records in resume, or list of contact addresses person record.) because "primary key" of azure table storage table 2 fields, i'm wondering if there common convention on how store information. "best practice?" the options see are: concatenate partitionkey , rowkey 1 field , store "foreign key" (i know there no real foreign keys). stor...

php - opencart 2.x: How to identify which submit button was pressed? -

on front page in opencart i've got panel login (which says user logged or if not asks login , password) , has if condition inside controller: if (($this->request->server['request_method'] == 'post') && $this->validate()) { the contact page has same if condition. when press submit button on contact page, front page reloads , both controllers call validate() function after error in login panel. i'm thinking adding if condition check of submit button pressed? how manage this, login panel use same data when reloading when submit button contact page pressed? if have these buttons: <input type="submit" name="button1" /> <input type="submit" name="button2" /> then can test 1 clicked follows: if (isset($_post['button1'])) { } else if (isset($_post['button2'])) { }

python - How to recursively generate a list of parent-child strings from an Adjacency List? -

summary: i'm trying make recursive function takes data adjacency list , converts dot notation. details: i have data list of tuples (python). data sorted id , limitation. there no restriction parents must listed before children: example, item #3 have parent item #7. there no (planned) limit number of generations. id name parent | data = [ 1 0 | (1, 'a', 0), 2 b 1 | (2, 'b', 1), 3 c 1 | ... 4 d 2 | 5 e 2 | 6 f 3 | 7 g 2 | 8 h 6 | ... 9 4 | (9, 'i', 4)] i want return list of strings in parent-child dot notation: a a.b a.b.d a.b.d.i a.b.e a.b.g a.c a.c.f a.c.f.h notice every name displayed - other algorithms i've found return items have no children. things i've tried: python code: here's i've got far, based us...

c++ - Power function in a loop -

i need writing power function. so, need write porogramm, output table 1 10 in power in loop. not using pow or exp example of output: 0^0 == 1 1^1 == 1 2^2 == 4 3^3 == 27 4^4 == 256 (and on, to) 10^10 == 10000000000 not using cmath (no pow or exp) for example: e.g. power( 3.0, 5 ) return 243 because 3*3*3*3*3 243 e.g. power( 173, 0 ) return 1 because number raised power of 0 1. i did simple loop, have no idea how insert power formula in it. thinking while loop #include <iostream> #include <string> using namespace std; int main(){ int number = 0, tot; (int table = 0; table < 10; table++) { tot = number * table; cout << tot << endl; number++; } } this recursive function can calculate value raised integer power double power(double base, unsigned int exp) { if (exp == 0) { return 1.0; } else { return base * power(base, exp - 1); } } an iterative...

MySQL before update trigger an insert syntax error using PhpMyAdmin -

create trigger question_preserver before update on bank each row begin if trim(new.question) != trim(old.question) insert bank_question_history (id,old_question) values (old.id,old.question)$$ end if$$ end$$ i inserting query mysql using phpmyadmin's sql window, using delim of $$. error you have error in sql syntax; check manual corresponds mysql server version right syntax use near '' @ line 5 i'm sure it's obvious , i'm missing it, no matter try can't work. error not helpful @ all, , have researched doing 4-5 examples found. any appreciated, thank you! go figure figured out right after asking. create trigger question_preserver before update on bank each row begin if trim(new.question) != trim(old.question) insert bank_question_history (id,old_question) values (old.`id`,old.`question`); end if; end$$ you have use ; break each statement/command , delim $$ end entire trigger.

sql - Hibernate query cache based on current time -

i have dao method executes following query fetch results: select new com.person() person person (person.start <= now()) , (person.expires > now()) order person.start asc the above postgresql query. can enable query caching on above? if query.setquerycache(true) , wouldn't work because now() different each time above executed. there best practice implement such functionality? basically should use discrete values instead of using directly value of now(), new 1 , incompatible caching strategy i've heard of :). so you're looking cache data each 15 minutes. you'd have floor value of now() closest quarter of hour , use floored value in sql query instead. you can check out article on stack implementing such thing how round time nearest quarter hour in java?

image - How to match the resulting "map" with the given "color_map"? -

i have rgb image called imrgb, size of 320*512*3 double.and have color_map = 64*3 double. use following code: [x, map] = rgb2ind(imrgb, 256) the resulting x= 320*512 uint8, , resulting map = 65*3 double. resulting "map" totally different given "color_map". how fix problem? the first few rows of "map" looks this: 0 0 0 0 0.125 1 0.56 1 0.439 1 0.125 0 0.188 1 0.812 1 0.749 0 0 0.7490 1 0.5019 0 0 0.7490 1 0.25098 the first few rows of given "color_map" looks this: 0 0 0.5625 0 0 0.6250 0 0 0.6875 0 0 0.7500 0 0 0.8125 0 0 0.8750 0 0 0.9375 0 0 1 0 0.0625 1 using rgb2ind performs colour quantization (the default uniform quantization directly in rgb space , apply dithering image) of image number of colours (in case, 256) if don't specify input colour map. map output prov...

javascript - Set cookie and redirect, without express -

i want able set cookie , redirect client node.js , without using express or third party library. online can find examples using express . when try set cookie , redirect client, cookie not set. when comment out redirect, res.writehead(301, {location: serveraddress}); , cookie gets set, there no redirect. so how set cookie , redirect client using straight node.js ? var fs = require("fs"); var http = require('http'); var home = fs.readfilesync('random.html'); var serveraddress = "http://youripaddress"; http.createserver(function(req, res) { if(req.url === '/favicon.ico') { res.writehead(200, {'content-type': 'image/x-icon'}); res.end(); } else if(req.headers.cookie) { console.log("got cookie"); res.writehead(200, "ok", {'content-type': 'text/html'}); res.write(home); res.end(); } else { console.log('creating cookie'); var cookie ...

How to use variable in php array read from file -

i trying figure out how use variable in array has been read file. have far , returning variable name instead of value. example intentionally not have space between $var.doe , saint.$var , places $var in front of "doe" , behind "saint" because actual data dealing with. thank help. read.txt $var.doe saint.$var php file <? $var = "john"; $aarray = file('read.txt'); echo $aarray[0]; echo '<br>'; echo $aarray[1]; ?> you need substitute variables: php > $s = ' $var.doe saint.$var '; php > echo $s; $var.doe saint.$var php > $var = 'jone'; php > echo str_replace('$var', $var, $s); john.doe saint.john

When using gradle with maven-publish, I get Cannot find wagon which supports the requested protocol: scp -

the error - "" property uploadurl defined scp://user@host/data/apps/repo/m2 here relevant sections configurations { deployerjars } // apply java plugin add support java apply plugin: 'java' //---------------------- buildscript { repositories { jcenter() } dependencies { classpath 'net.researchgate:gradle-release:2.0.2' } } //---------------------- apply plugin: 'maven' uploadarchives { repositories { mavendeployer { //uploadurl defined in properties file. recognied //by gradle repository(url:uploadurl) uniqueversion = false } } } //---------------------- apply plugin: 'net.researchgate.release' //---------------------- // in section declare find dependencies of project repositories { // use 'maven central' resolving dependencies. // can declare maven/ivy/file repository here. mavencentral() } // in section...

sql - mysql count performance -

select count(*) mytable; select count(table_id) mytable; //table_id primary_key both query running slow on table 10 million rows. wondering why since wouldn't easy mysql keep counter gets updated on insert,update , delete? , there way improve query? used explain didn't much. as cherouvim pointed out in comments, depends on storage engine. myisam keep count of table rows, , can keep accurate since locks myisam supports table lock. innodb supports transactions, , needs table scan count rows. http://www.mysqlperformanceblog.com/2006/12/01/count-for-innodb-tables/

ssh - Vagrant java 1.6 to 1.8 -

i installed vagrant on machine hashicorp-precise32 virtual machine. installed java 1.6 whereas want java 1.8 . have install virtual machine? how java 1.8? add below lines in vagrantfile , install java 8 (accepting licenses) , set environmental variables in guest vm: sudo apt-get install -y software-properties-common python-software-properties echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections sudo add-apt-repository ppa:webupd8team/java -y sudo apt-get update sudo apt-get install oracle-java8-installer echo "setting environment variables java 8.." sudo apt-get install -y oracle-java8-set-default moreover, can refer creating , provisioning vm using vagrant

Bigcommerce API - In Orders, what does the id represent? -

in orders( https://developer.bigcommerce.com/api/stores/v2/orders ), id represent? order_id? id explained in documentation "the id of order, read-only value. not pass in put or post." however, if @ id property under order product( https://developer.bigcommerce.com/api/objects/v2/order_product ), there id, order_id, , product_id. i confused id represent in orders , order product. both values represent individual auto assigned unique numbers. when upload or add new products each product assigned product_id , when order placed or in abandon cart saver feature gets assigned order_id. if go bigcommerce product page , view-source see product_id example <input type="hidden" name="product_id" value="94" /> hope helps

vim - how to use environment variable in autocommand -

win7x32 gvim 7.4 i want call batch file in response vimleave event. if autocommand looks this: au vimleave * !c:\users\sauron\vimfiles\cleansession.cmd it works expected. want replace 'c:\users\sauron' '~' or '$home' or similar, have not gotten work. have tried: au vimleave * !$home\vimfiles\cleansession.cmd au vimleave * !%home%\vimfiles\cleansession.cmd au vimleave * !~\vimfiles\cleansession.cmd the '%' expanded containing file's name. $home doesn't expanded. have tried quoting path, , not. overlooking? -- exec 'au vimleave * !' . fnameescape($home . '/vimfiles/cleansession.cmd') welcome wonderful world of vim command mode syntax. :)

Forwarding Calls From The Browser With Twilio -

i have been following tutorial on twilio.com walks through setting browser phone. here link https://www.twilio.com/docs/quickstart/php/client/incoming-calls i know can use twiml handle flow of call, curious know if there way take call in progress on browser , forward call number. know how or know if possible? in advance! twilio developer evangelist here. you can affect calls in progress using rest api. making post request call's endpoint can redirect or hangup call. you're looking redirect, if post url parameter endpoint call redirected url. should url serves twiml , can forward call onto number <dial> . you can call sid connection object in browser calling parameters , or original call twiml incoming call. let me know if helps @ all.

multithreading - Java Multi-Thread Pausing -

my goal i brand new multi-threading in java , attempting create pong. include bit of code here relevant question. problem i want able pause game pressing space bar, , resume again pressing space bar later. following code works pause game, cannot resume. future key presses not recognized. seems if main thread being paused. code main class public class mainmanager { private ticker ticker; private thread tickerthread; private boolean active; public mainmanager() { ticker = new ticker(this,10); tickerthread = new thread(ticker); tickerthread.start(); } public synchronized void tick() { // necesary things each game tick } public void togglestate() { if (this.active) { ticker.pause(); } else { this.setactive(true); notify(); } } public void setactive(boolean b) { this.active = b; } public static void main(...

ios - Open a WKWebview target="_blank" link in Safari -

i trying hybrid ios app uses swift , wkwebviews open link has target="_blank" or if url contains http:// , https:// , or mailto: in mobile safari. from this answer code. func webview(webview: wkwebview!, createwebviewwithconfiguration configuration: wkwebviewconfiguration!, fornavigationaction navigationaction: wknavigationaction!, windowfeatures: wkwindowfeatures!) -> wkwebview! { if navigationaction.targetframe == nil { webview.loadrequest(navigationaction.request) } return nil } first, doesn't me. second, want open in new window. , found code supposed that... if let requesturl = nsurl(string: "http://www.isecurityplus.com") { uiapplication.sharedapplication().openurl(requesturl) } how put these 2 , them work? need add viewcontroller declaration make work? in ( from here ) override func loadview() { super.loadview() self.webview.navigationdelegate = self self.webview.uidelegate = sel...

ruby - Rails routes "get 'frog'" vs "get :frog" (probably really easy) -

this question has answer here: understanding usage of symbols in routes.rb files 1 answer this works: resources :students member 'frog' end end here's understand doing: resources method(?) sending code block member method(?) , telling create action verb 'frog' (which entry in controller, has view, etc.) this works: resources :students member :frog end end pretty same, kind of data :frog in version? i'm trying understand every line of scaffolded app rather take on faith. tutorials claim restful part difficult piece understand, think that's pretty clear. it's rails conventions tripping me up. any explanations/expansions on above welcome. in example, :frog ruby symbol . it's converted string call to_s on (try :frog.to_s in irb or console). similarly, can covert string symbol cal...

android - Builders - creates a new instance each time? -

i'm using couple of builders make bunch of objects. i'm doing this: list<productofbuilder> list; builder b = new builder(); for(some iterable in i) { b.setsomeparam(i); list.add(b.build()); } is okay do? in other words, builder create new instance of productofbuilder each build() ? is okay do? in other words, builder create new instance of productofbuilder each no not. accordingly code posted changing same reference. in end list contains n builder, content of last call setsomeparam . it different if have collection of objects builder supposed build, , calling @ every iteration build() . list<typetobuild> list; typetobuild.bilder builder; (type t : parmas) { builder.setparamns(t); list.add(builder.build()); }

angularjs - Call an Angular route with out using $location -

i have module can run in 2 modes. 1 standard can browse routes normal, second self contained version lives in sidebar of page. self contained version should behave same not affect url bar. can bring route ngview element without changing url or manually fetch template ngview element , instantiate it's associated controller? i have used ui-router success. $state.go('state-name' ,queryparams,false); the final false here tells ui-router not change location. i'm liking ui-router lot!

python - How to add new columns to django userprofile model -

i have added 1 custom field phone django user authentication. till worked properly. later added 1 more custom field called permissions . after facing error message when try access admin page. here model.py code from django.contrib.auth.models import user django.db import models class userprofile(models.model): # line required. links userprofile user model instance. user = models.onetoonefield(user) class meta: permissions = ( ("ssc_1","can access ssc locked questions"), ) # additional attributes wish include. phone = models.charfield(max_length =20) permission = models.integerfield() # override __unicode__() method return out meaningful! def __unicode__(self): return self.user.username i have followed this stackoverflow answer , when issue python manage.py migrate command, getting error message return database.cursor.execute(self, query, params) django.db.u...

ios - PHFetchResult get all photos and sort by date inconsistent -

i'm trying build photo picker has 2 options now: recents , favorites. i'm doing trying photos creationdate giving images in wrong order in data source. there's photos years ago @ beginning of data source, , photos less few minutes old scattered throughout. think issue need tell main fetchresult sort order first, don't think it's possible: unsupported sort descriptor in fetch options: (creationdate, ascending, compare: i'd appreciate offered. code: @property (nonatomic, strong) nsmutableorderedset *recentsdatasource; @property (nonatomic, strong) nsmutableorderedset *favoritesdatasource; - (void)setup { phfetchresult *fetchresult = [phassetcollection fetchassetcollectionswithtype:phassetcollectiontypesmartalbum | phassetcollectiontypealbum subtype:phassetcollectionsubtypeany options:nil]; (phassetcollection *sub in fetchresult) { phfetchoptions *fetchoptions = [[phfetchoptions alloc]init]; fetchoptions.sortdescriptors = @[[...

scala - Getting zero results in search using elastic4s -

this small code using simple search: import com.sksamuel.elastic4s.{elasticsearchclienturi, elasticclient} import com.sksamuel.elastic4s.elasticdsl._ import org.elasticsearch.common.settings.immutablesettings object main3 extends app { val uri = elasticsearchclienturi("elasticsearch://localhost:9300") val settings = immutablesettings.settingsbuilder().put("cluster.name", "elasticsearch").build() val client = elasticclient.remote(settings, uri) if (client.exists("bands").await.isexists()) { println("index exists!") val num = readline("want delete index? ") if (num == "y") { client.execute {deleteindex("bands")}.await } else { println("leaving here ...") } } else { println("creating index!") client.execute(create index "bands").await client.execute(index "bands/artists" fields "name"->"coldpl...

php - array for multiple categories -

i want make portfolio multiple categories. 1 of 5 similar category pages… <?php $pagelabel = 'cat1'; include 'cats-config.php'; ?> the cats-config.php… <?php include 'cats-arrays.php'; ($i = 0; $i < count($allprojects); $i++) { if (isset($allprojects[$i][$pagelabel])) { include ('thumbs/thumb-' . $allprojects[$i] . '.png'); } } ?> and lastly cats-arrays.php define project belongs in category… <?php //for example $allprojects = array( 'project1' => array('cat1', 'cat3', 'cat5'), 'project2' => array('cat2'), 'project3' => array('cat3', 'cat4'), 'project4' => array('cat1', 'cat2', 'cat5'), 'project5' => array('cat2', 'cat3', 'cat4', 'cat5'), 'project6' => array('cat5'), 'project7' => array('...

vba - Bind TextBox to ComboBox in Access -

Image
i have access table looks this: +------------+--------+--------+--------+-------+ | partnumber | thing1 | thing2 | thing3 | item1 | +------------+--------+--------+--------+-------+ | 123 | abc | xyz | asd | poi | | 456 | qwe | sdf | ert | lkj | | 789 | jkl | iop | yui | mnb | +------------+--------+--------+--------+-------+ i wish create ms access form combobox , textbox such: basically, want able add/edit fields in table selecting field in combobox , setting value of field in textbox. only, however, want edit thing# fields in table. how create macro, or vba system, accomplish this? here's example started, though should want add additional things validation checks , whatnot. firstly form should bound table supplied makes easier update data in table. called table "tblthings" in example, whatever call should in record source property form: next, create combobox , text field unbound controls (i....

How to download an older branch of Chromium from Git using gclient? -

i need build older version still supports npapi run java plugin can't seem find correct syntax pull it, here's .glient pulls latest revision: solutions = [ { "managed": false, "name": "src", "url": "https://chromium.googlesource.com/chromium/src.git", "custom_deps": {}, "deps_file": ".deps.git", "safesync_url": "", }, ] and sync use: gclient sync there's specific page on chromium.org explains how check out source of specific release. should follow instructions there.

if statement - Python - For loop isn't kicking in (blackjack game) -

i'm starting learn python , first project text based blackjack game. phand being players hand , ptotal being total of players cards. the loop seems exiting after first iteration. when print ptotal , phand out after loop, shows first card's value every time. code: import random f = open('documents/python/cards.txt', 'r') deck = f.read().splitlines() f.close ptotal = 0 ctotal = 0 random.shuffle(deck) phand = [deck[0], deck[1]] chand = [deck[2]] x in phand: if deck[x][0] == '1' or deck[x][0] == 'j' or deck[x][0] == 'q' or deck[x][0] == 'k': ptotal += 10 elif deck[x][0] == 'a': ptotal += 11 else: ptotal += int(deck[x][0]) any appreciated! i think want #using x list item x in phand: if x[0] == '1' or x[0] == 'j' or x[0] == 'q' or x[0] == 'k': ptotal += 10 elif x[0] == 'a': ptotal += 11 else: ...

php - How to extend regex to find multiple matches? -

this current regex (used in parsing ical file): /(.*?)(?:;(?=(?:[^"]*"[^"]*")*[^"]*$))([\w\w]*)/ the current output using preg_match() this: //output 1 - `preg_match()` array ( [0] => tzid="greenwich mean time:dublin; edinburgh; lisbon; london" [1] => value=date;rsvp=false;language=en-gb ) i extend regex output (i.e. find multiple matches): //output 2 array ( [0] => tzid="greenwich mean time:dublin; edinburgh; lisbon; london" [1] => value=date [2] => rsvp=false [3] => language=en-gb ) the regex should search each semicolon not contained within quoted substring , provide match. cannot swap preg_match_all() gives unwanted output //output 3 - `preg_match_all()` array ( [0] => array ( [0] => tzid="greenwich mean time:dublin; edinburgh; lisbon; london";value=date;rsvp=false;language=en-gb ) [1] => array ( ...

excel - Would like to limit the number of elements in a Pivot Chart filter -

i creating pivot table corresponding pivot chart in vba. i have filtered data in table show top 5 values , chart displays top 5 values. however, if click field filter button on chart, every value there , checked default (even though 5 visible). the problem comes when want remove 1 of top 5 chart (due fact large suppressing visibility of other data). if unselect item, every other item becomes visible instead of other 4 items like. realize because items checked in filter. what know why checked default though 5 visible , if there workaround issue (can filter show top 5 or @ least have top 5 checked)?

qt - Zooming a view in PyQt? -

i have simple tree application displays qtreeview inside of qmainwindow. want give user ability change magnification level of content (using spinbox likely), without changing underlying font size of text. is there way without changing whole app qgraphicsscene ? app showing good-old fashioned tree text, no graphics or fancy other wanting change magnification of view; hence, thinking switching graphics scene overkill. or, wrong, , switching graphics scene simple way it? note trimmed down version of app @ code review. contains sscce, bit long post here. in site discussing how put widgets on scene , trolltech wrote (emphasis added): i myself , several other trolls’ve spent time researching topic [how embed widget in qgraphicsscene]. it’s not trivial; solutions embedding widgets scene end several serious drawbacks. that’s why qt doesn’t have off-the-shelf solution this. widgets cannot scaled or rotated, graphics items can. this suggests cannot perform, i...

android - No connection between devices? -

i've developed android application. voice chating streaming audio between 2 android device works wifi on local network. but when press start button nothing happends.it should ring , make connection server code: package com.example.voicechatserver; import android.support.v7.app.actionbaractivity; import android.os.bundle; import android.app.activity; import java.io.ioexception; import java.net.datagrampacket; import java.net.datagramsocket; import java.net.socketexception; import android.content.context; import android.media.audioformat; import android.media.audiomanager; import android.media.audiorecord; import android.media.audiotrack; import android.media.mediarecorder; import android.util.base64; import android.util.log; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.edittext; import android.widget.textview; public class mainactivity extends activity { private button receivebutton,stopbutt...