Posts

Showing posts from January, 2012

arrays - PHP function like array_replace() but does not add unknown keys -

i have associative array holds settings of object. have function allows user override these setting passing associative array of replacement settings. can use array_replace() don't want values unknown associative array keys added settings. e.g. $settings = array( 'colour' => 'red', 'size' => 'big' ); $settings = array_replace( $settings, array( 'size' => 'small', 'weight' => 'heavy' ) ); i want settings produce: array ( [colour] => red [size] => small ) instead this: array ( [colour] => red [size] => small [weight] => heavy ) first need filter out unwanted items array_intersect_key . $settings = array( 'colour' => 'red', 'size' => 'big' ); $new_settings = array( 'size' => 'small', 'weight' => 'heavy' ); $settings = array_merge($set

ios - Pop to root view in an unwind segue -

my view controller sequence follows: a -> (push) -> b -> (modal) -> c i return c b using unwind segue , works. i return directly c a. in unwind segue located in b, try pop root view: -(ibaction)unwindtobfromc:(uistoryboardsegue *)segue { [self.navigationcontroller poptorootviewcontrolleranimated:yes]; } and error: tried pop view controller doesn't exist. when execute: [self.navigationcontroller poptorootviewcontrolleranimated:yes]; in b in button action return no problem. what's wrong? since c in modal, there nothing pop to. dismiss instead. [self dismissviewcontrolleranimated:yes completion:nil];

c# - Find prime using square root -

here question, find sum of primes below 2 million. my code lists many non-primes such 9,15..., wrong? using system; using system.collections.generic; using system.diagnostics; using system.linq; using system.text; using system.threading.tasks; namespace p10 { // sum of primes below 10 2 + 3 + 5 + 7 = 17. find sum of primes below 2 million. class program { static list<long> list = new list<long>(); static void main(string[] args) { stopwatch sw = stopwatch.startnew(); list.add(2); list.add(3); long x = list.last(); while (x < 2000000) { x += 2; findprime(x); } long y = list.sum() - list.last(); console.writeline(y); console.writeline("time used (float): {0} ms", sw.elapsed.totalmilliseconds); console.writeline("time used (rounded): {0} ms",

javascript - Jquery callback function not working to redirect page -

how callback function on 2nd line redirect user after animation runs? want redirect link in href of 'nav li a'. if leave callback "" animation works fine nothing (as expected). if put think work fails , of time breaks first line working @ all. i'm trying page slide in it's starting offscreen position on load (1st line). slide out first reload page (2nd line). $('section').animate({"left":"0px"}, 450); $('nav li a').click(function () { $('section').animate({ "left": "1000px"}, 1000, ""); return false; }); prevent anchors default action, store reference anchor callback animate() creates new scope, redirect : $('section').animate({"left":"0px"}, 450); $('nav li a').on('click', function(e) { e.preventdefault(); var self = this; $('section').animate({ "left": "1000px"},

javascript - Swapping Array elements with Keys -

im trying swap 2 array elements in array looks this [18785:object, 22260:object, 22261:object, 22262:object, 22263:object] i used following code: that.movemediumdown = function(mediumid){ var arrkeys = new array(); (key in that.data.medium) { arrkeys.push(parseint(key)); } (var = 0; < arrkeys.length; i++){ if (arrkeys[i] === parseint(mediumid)) { //swap medium var tmpmedium = that.data.medium[arrkeys[i]]; that.data.medium[arrkeys[i]] = that.data.medium[arrkeys[i + 1]]; that.data.medium[arrkeys[i + 1]] = tmpmedium; break; } } //build new array correct ids var tmpmediumarray = new array(); (var j = 0; j < arrkeys.length; j++){ tmpmediumarray[arrkeys[j]] = that.data.medium[arrkeys[j]]; } } the problem when swap content of 2 array elements, key stays same. nee

Facebook iOS SDK invite with multiline message -

i'm trying figure out how send invite using facebook sdk ios, message needs multiline. to more specific, i'm trying change this: message send invite into this: message send invite is there way this? i'm using fbwebdialog. in particular i'm using function: + (void)presentrequestsdialogmodallywithsession:(fbsession *)session message:(nsstring *)message title:(nsstring *)title parameters:(nsdictionary *)parameters handler:(fbwebdialoghandler)handler { [fbwebdialogs presentrequestsdialogmodallywithsession:session message:message title:title parameters:parameters handler:handler friendcache:nil]; }

ruby on rails - Handling multiple filters (params) cleanly in controller -

i have class called post, , need able accommodate following scenarios: if user selects category, show posts category if user selects type, show posts type if user selects category , type, show posts category type if user selects nothing, show posts i'm wondering if it's inevitable controller going gross ton of conditionals... here's flawed approach @ tackling – know how can accomplish this? class postscontroller < applicationcontroller def index @user = current_user # if user has not specified type or category, # show them @posts = post.all # if user has selected category, no type, # show posts category. if params[:category] && !params[:type] category = category.find(params[:category]) @posts = @category.posts end # if user has selected category , type, show # posts category type if params[:category] && params[:type] category = category.find(params[:category]) type

sql server - t-sql complex query to get only maximum status with 'R' -

i want maximum claim status version status type 'r' , if there other status same claim id want filter those. below query doesn't give me required results. select p.prov_clm_id,p.prov_clm_stat_type,max(p.clm_stat_version) provider_clm_stat p p.provider_clm_stat_type='r' group p.prov_clm_id,p.provider_claim_status_type 194 r 1 231 r 1 469 r 1 649 r 1 if there other claim status don't want show in results. select * provider_clm_stat prov_clm_id=194 194 5 b 194 2 k 194 3 g 194 4 q 194 7 h 194 8 p 194 1 r 194 6 x required results: 740 r 1 if want claim status have 'r' , no other statuses: select p.prov_clm_id, p.prov_clm_stat_type, max(p.clm_stat_version) provider_clm_stat p group p.prov_clm_id, p.provider_claim_status_type having max(p.provider_clm_stat_type) = 'r' , min(p.provider_clm_stat_type) = 'r'; the filtering here in having clause after aggregation. if min() , ma

durandal typescript bootloader -

i create wrapper around durandal using typescript make easy create new spa apps easy development team. let me shortly describe way structure wrapper; there initial bootstrap class , configuration developer needs configure set new application. here achieve now. appcore.d.ts declare module 'system/app' { var appcore: spaapp; export = appcore; } interface spaapp { isindebugmode: boolean; initroute: initialroute; apptitle: knockoutobservable<string>; init: () => void; } interface initialroute { viewmodel: string; animationmode: string; } app.ts import app = require('durandal/app'); import viewlocator = require('durandal/viewlocator'); import system = require('durandal/system'); class bootloader implements spaapp { isindebugmode: boolean; initroute: initialroute; apptitle: knockoutobservable<string>; init: () => void; constructor(title: string) { this.apptitle

How to find all odd occurring elements in an array in JAVA -

i trying find elements occur odd number of times in array. worked out little bit, code returning correct answer if there 1 number occurs odd number of times. if there 2 or more odd occurring numbers not able process it. understand if bit-wise xor of elements 1 odd occurring element. how can improve multiple numbers? below code: public class oddoccur { public int oddoccurence(int[] arr, int size) { int res = 0; int[] fin = new int[size]; (int = 0; < size; i++) { res = res ^ arr[i]; } return res; } public static void main(string args[]) { int[] arr = { 2, 5, 5, 2, 2, 3, 3, 3 }; int n = arr.length; oddoccur obj = new oddoccur(); system.out.println("odd occuring element is:" + obj.oddoccurence(arr, n)); } } need solve issue! public int oddoccurence(int[] arr, int size); first, there can multiple numbers occur odd number of times. there&#

ios - UIPageViewController: how to have "negative" spacing between view controllers (with scroll-transition style) -

i have implement view controller (on iphone, portrait only, full screen view) upper part of view must have horinzontal, paged scrolling behavior, potentially infinite. i used similar purposes uipageviewcontrollers , take advantage of datasource , delegate protocols, helpul manage memory , other stuff (keeping 3 view controllers in memory, providing delegates handle actions when transition done , on): think in case component best choice. but here comes problem. in view i'm realizing, have let user understand can swipe left , right move view: page control not choice, since scroll potentially infinite, let small portion of views of left , right view controllers visible. that: link image (sorry cannot include images in posts yet) up have not been able figure out how realize this. in options during initialization, uipageviewcontrolleroptionspinelocationkey can specified set (from documentation) "space between pages, in points": seems work positive value, space i

memory - merging really not that large data.tables immediately results in R being killed -

i have 32gb of ram on machine, can r killed faster ;) example the goal here achieve rbind() of 2 data.tables using functions make use of data.table's efficiency. input: rm(list=ls()) gc() output: used (mb) gc trigger (mb) max used (mb) ncells 1604987 85.8 2403845 128.4 2251281 120.3 vcells 3019405 23.1 537019062 4097.2 468553954 3574.8 input: tmp.table <- data.table(x1=sample(1:7,4096000,replace=true), x2=as.factor(sample(1:2,4096000,replace=true)), x3=sample(1:1000,4096000,replace=true), x4=sample(1:256,4096000,replace=true), x5=sample(1:16,4096000,replace=true), x6=rnorm(4096000)) setkey(tmp.table,x1,x2,x3,x4,x5,x6) join.table <- data.table(x1 = integer(), x2 = factor(), x3 = integer(), x4=integer(), x5 = integer(), x6 = numeric()) setkey(join

sql - Syntax errors when migrating a .bak created in SQLServer 2000 to SQLServer 2008 then to SQLServer 2012 -

sqlserver 2012 sends me syntax error while executing stored procedure: doc.id_doc = @pi_id_doc , doc.id_doc = det.id_doc , det.recibo_concep = rec.recibo_concep , doc.cuenta = cto.cuenta , doc.cta_consec = cto.cta_consec , cta.cuenta = cto.cuenta , doc.cuenta *= lec.cuenta , doc.cta_consec *= lec.cta_consec , doc.bimestre *= lec.bimestre especially while using expresion "*=". i executed same stored procedure no changes in sqlserver 2008 no problems. does '*=' have meaning different '='? there changes in syntax between sql server 2008 , sql server 2012? *= (and =* ) outer join using old-style syntax (syntax popular still in oracle, has been deprecated since sql server 2008 , officially discontinued in sql server 2012 ). syntax no longer supported , has many problems. info here: bad habits kick : using old-style joins you need re-write these queries modern left /

c# - VLC authentication using HttpWebRequest -

i'm trying use vlc's http interface read current playlist ( get /requests/playlist.xml ). this working fine in older version of vlc, in recent versions added password option , made mandatory. (there no username.) i first tried using this: request.credentials = new networkcredential("", password); request.preauthenticate = true; however resulted in webexception reporting 401 error. snooping traffic revealed sent 1 request did not have authorization header, , reported error without attempting authenticate. (vlc did correctly respond www-authenticate challenge.) if specify non-blank username, sends same request before follows second request specify authorization header -- fails because vlc rejects username. i managed work setting header explicitly: var credential = convert.tobase64string(encoding.default.getbytes(":" + password)); request.headers[httprequestheader.authorization] = "basic " + credential; this seems should have wo

eloquent - Using Laravel's ORM - what's the difference between the longhand and the shorthand? -

for instance: return product::first()->baseproduct->products works, whereas return product::first()->baseproduct()->products() does not, , badmethodcallexception . i understand there's notable difference, then, between 2 lines, difference, , how work? i'm assuming baseproduct() , products() both relationships in models? calling products() won't return eloquent objects, it'll return hasmany or belongstomany (children of relation) object. calling products instead of products() triggers magic method. magic calls getresults() method on relation object. way collection of product models. typically way should work relationships. in other words: baseproduct::first()->products == baseproduct::first()->products()->getresults() i suggest have @ source code

database - How to correctly handle select statements in SQLlite for android? -

please me in issue. developing application works big database in android. problem need big procedures specific info, application takes long respond , screen goes black until solve problem. put asynctask while finds response, nothing seems work. this example method. public arraylist<sgn_promociones> searchpromos(int p_cabped_id, int p_agrup_id, int cli_id) { int li_aplica = 0; int li_nro_agrup; // le asignamos por el momento el id del cliente que seleccionamos informacionproceso inp = new informacionproceso(); int ld_clie_id = 0; int ld_promo_id; int ld_promo_id1; string lv_descripcion_corta; char lv_aplica_a; string lv_aplica_as; string lv_indicador_evaluar; string lv_indicador_articulo_evaluar; string lv_otorga_puntos; string lv_indicador_obsequio; int ld_maximo_obsequio; string ld_indicador_aleatorio_id; string lv_estado; string lv_actividad; string lv_canal; string lv_subcanal;

java - The constructor Polygon(int[], int[], int) is undefined -

i trying figure out why program telling me constructor undefined polygon. this exception get: exception in thread "main" java.lang.error: unresolved compilation problem: constructor polygon(int[], int[], int) undefined @ test.main(test.java:9) class import java.awt.*; import java.applet.*; import java.util.*; import java.awt.geom.*; public class polygon extends applet { private int[] xpoints = { 0,-10, -7, 7, 10 }; private int[] ypoints = {-10, -2, 10, 10, -2 }; private polygon poly; public void init(){ poly = new polygon(xpoints, ypoints, xpoints.length); } } it says polygon class must have constructor suitable new polygon(xpoints, ypoints, xpoints.length); see http://docs.oracle.com/javase/tutorial/java/javaoo/constructors.html

ruby on rails - Undefined method when rendering form partial -

on questions index page have list of questions. want able answer each question right on page rendering answers form. getting error when try , that: undefined method `answers' #<question:0x00000103dc0100> it highlights second line of answers controller: def create @question = question.find(params[:question_id]) @answer = @question.answers.new(answer_params) @answer.save end here view: <% @questions.each |question| %> <%= question.body %> <%= render :partial => "answers/form", locals: {question:question} %> <% end %> and form looks this: <%= simple_form_for [question, answer.new] |f| %> <%= f.input :body %> <% end %> lastly, questions controller: def index @questions = @comment.questions.order @answer = answer.new end since have belongs_to has_one relationship, correct association this: question.find(params[:question_id]).answer note answer singular . because each

java - boolean function that contains "bab" -

how have recursive boolean method check if contains bab. have i'd recursively. public static boolean hasbab(string str) { if (str.length() < 3) return false; if (str.substring(0,3).equals("bab")) return true; else return false; } recursion should thought of 2 parts. 1) base case. trivial case can easly determined. have far start base case. 1) string less 3? return false. 2) string start "bab" return true. 2) recursive case. splits problem tinier problems, , if split them enough have base case. @logiraptro has example of simple recursion. public static boolean hasbab(string str) { if (str.length() < 3) return false; if (str.substring(0,3).equals("bab")) return true; else return hasbab(str.substring(1)); } this uses base cases, , recursive case checks string index 1 on. reduces our string 1 charter, enough solve problem. this means end stack level of length of string.

eclipse - Regex, match a word that starts with one of a range of letters -

i want match word starts letter h t , ends ing or ed word learning . tried \\s[h-t]\\w+[ing[ed]]\\s this should work ^[h-t].*(ing|ed)$

c - strtok overwrites my variables -

i'm trying use strtok () store info struct. code looks this char *temptype = null, name[100], filestring[100]; int *tempitems = null, *tempcost = null; file *infile = null; itemtype myvector; infile = fopen ("grocery_list.txt", "r"); while (!feof (infile)) { fscanf (infile, "%s", &filestring); temptype = strtok (filestring, ":"); tempcost = (int *) strtok (null, ":"); tempitems = (int *) strtok (null,":"); myvector.type[num_items] = temptype; myvector.cost[num_items] = tempcost; myvector.items[num_items] = tempitems; num_items++; } everytime run it, values in myvector.type becomes "cherries" , i'm not sure why. infile: apples:5:1 milk:3:2 bread:3:1 candy:10:1 cheese:5:6 oranges:4:2 cherries:3:2 the function strtok returns pointer , pointer gets overwritten each execution of while loop. in end array entries point same memory address. need copy string st

win32serviceutil - Grant python permissions to run windows services -

i'm having quite hard time trying start windows service python using: win32serviceutil.startservice("service-name") it returns: file "c:\python27\lib\site-packages\win32\lib\win32serviceutil.py", line 412, in startservice hscm = win32service.openscmanager(machine,none,win32service.sc_manager_all_access) error: (5, 'openscmanager', 'access denied.') i've read start windows service user must have administration rights. username not hidden administrator account can perform administration tasks on computer. question is, best way allow python start given service? know disabling user account control can start service reduce lot security of machine. isn't there way change permissions of service or grant administration rights python start services (or better...just service)? many thanks

What happens after the Certificate in SQL Server gets expired? -

i have certificate sql server database. happen after certificate gets expired? will record insertion, selection, deletion work after certificate gets expired? if certificate gets expired there no effect. certificate expiration not enforced when certificate used encryption. check this post more information.

mysql - PHP foreach value in array -

i making staff online section members see weather staff member in-game them or not. began tackling idea array of staff members account id's. looks this: $this->view->staffadmins = array(64, 80, 96); then used foreach statement following details each account: are logged in? if so, use id array , more information users table my foreach statement looks this: foreach ($this->view->staffadmins $query) { //are logged in? $sql = "select * point uid = :id , zoneid > -1"; $arr = array(":id" => $query); $this->view->result = $this->database->dbctr($sql, $arr); //get details! $sql = "select * users id = :id"; $arr = array(":id" => $query); $this->view->staffmem = $this->database->dbqry($sql, $arr); $this->view->name = $this->view->staffmem[0]['name']; $this->view->truename = $this->view->staffmem[0]['truename

c# - Read XML by its tag name -

i have xml services respond , here's sample : <?xml version="1.0"?> <s:envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:body> <ns4:loginresponse xmlns="http://www.website.com/inctypes" xmlns:ns2="http://yyy.website.com/security" xmlns:ns3="http://yyy.incognito.com/service" xmlns:ns4="http:/yyy.website.com/wsdl/security"> <ns2:errorcode> <haserror>true</haserror> <status>status_error</status> <problemcode>-1</problemcode> <problemmessage>service provider not known</problemmessage> <extendedinformation>service provider not known</extendedinformation> </ns2:errorcode> </ns4:loginresponse> </s:body> </s:envelope> i want value of tag

php - SplFileObject error failed to open stream: No such file or directory -

Image
i trying implement passbook web service in symfony2 , following passbook bundle , controller looks this if ($form->isvalid()) { // create event ticket $pass = new eventticket("1234567890", "the beat goes on"); $pass->setbackgroundcolor('rgb(60, 65, 76)'); $pass->setlogotext('apple inc.'); // create pass structure $structure = new structure(); // add primary field $primary = new field('event', 'the beat goes on'); $primary->setlabel('event'); $structure->addprimaryfield($primary); // add secondary field $secondary = new field('location', 'moscone west'); $secondary->setlabel('location'); $structure->addsecondaryfield($secondary); // add auxiliary field $auxiliary = new field('datetime', '2013-04-15 @10:25'); $auxiliary->

MySQL select between dates leaving blank -

i'm trying search. and there input startdate , 1 finaldate. but person might not type start or final date or neither... im trying use: (data between ".$startdate." , ".$finaldate.") leaving blank it's not working, unless put start , final dates. i wanted if person doesn't type dates, keeps searching rest. is possible? ==edited per request== put before sql query: if(empty($finaldate)) $where = "(data >= ".$startdate.")"; else if(empty($startdate)) $where = "(data <= ".$finaltdate.")"; else $where = "(data between ".$startdate." , ".$finaldate.")"; and change (data between ".$startdate." , ".$finaldate.") with ".$where."

git - Checkout, Fetch and Pull in BitBucket SourceTree -

i using bitbucket web based hosting of our projects. along using sourcetree committing , such purpose. bit confused checkout , fetch , pull option available in sourcetree interface , usage. can familiar tool explains usage of these options available in sourcetree? using atlassian's git tutorial (link updated) reference. git checkout : the git checkout command lets navigate between branches created git branch. checking out branch updates files in working directory match version stored in branch, , tells git record new commits on branch. think of way select line of development you’re working on. source: https://www.atlassian.com/git/tutorials/using-branches#git-checkout git pull : you can think of git pull git's version of svn update. it’s easy way synchronize local repository upstream changes. following diagram explains each step of pulling process. source: https://www.atlassian.com/git/tutorials/syncing#git-pull git fe

java - Column does not exist in sql -

java.sql.sqlexception: column 'movie_borr' not found. i column exists in database created. resultset rs = stmt.executequery("select movie_id, movie_name, movie_dateborrowed movie_tbl movie_borr = '"+useruserid+"'"); if(rs.next()){ string moviebo = rs.getstring("movie_borr"); joptionpane.showmessagedialog(null, moviebo); } when name column in getstring , column must listed in select clause. add movie_borr list of columns after select . edit sorry, @wxyz - didn't see got there first. if post answer, i'll delete mine!

what does the colon mean in the Twitter API Resource URL format? -

the twitter api retweeting shows resource url following: http://api.twitter.com/1/statuses/retweet/:id.format and says "id" required parameter. so based on thought following aifnetworking call work. set: postpath:@"1.1/statuses/retweet.json" and parameters: nsmutabledictionary *params = [nsmutabledictionary dictionarywithdictionary:@{@"id": tweetid}]; and entire call looks like: - (void)postaretweet:(nsstring*)tweetid success:(void (^)(afhttprequestoperation *operation, id response))success failure:(void (^)(afhttprequestoperation *operation, nserror *error))failure { nsmutabledictionary *params = [nsmutabledictionary dictionarywithdictionary:@{@"id": tweetid}]; self postpath:@"1.1/statuses/retweet.json" parameters:params success:success failure:failure];} but got 404 error telling me page didn't exist. after trial , error, forced postpath postpath:@"1.1/statuses/retweet/@"some_tweet_number".json

gruntjs - Sending specs in grunt using grunt-protractor-runner -

i using grunt-protractor-runner plugin , in protractor target want send specs param containing test run. in grunt file target looks follows: testintegration: { options: { args: { specs: ['test1.js'], browser: 'firefox' } } the protractor parent task option contains setting of protractor config file. when running target error: $ grunt protractor:testintegration running "protractor:testintegration" (protractor) task starting selenium standalone server... selenium standalone server started @ ... warning: pattern t did not match files. warning: pattern e did not match files. warning: pattern s did not match files. warning: pattern t did not match files. warning: pattern 1 did not match files. warning: pattern j did not match files. warning: pattern s did not match files. and more errors. same line works in protractor config file. tried few other variation no success. what missing? ideas? try configuration: module.e

Perl Export Suggestions -

i working new program needs interface perl. the example code suggests of methods exported global namespace below: use bgpmon::fetch; $ret = init_bgpdata(); $ret = connect_bgpdata(); $xml_msg = read_xml_message(); ... however using of methods causes " undefined subroutine &fetch::init_bgpdata ." know module works doesn't seem exporting correctly because can still use long names: bgpmon::fetch::init_bgpdata(); . any reason why module isn't exporting correctly? note: love share method code know not problem module. part of codeset can't share , know works because tests manage pass. exporter section require exporter; our $autoload; our @isa = qw(exporter); our %export_tags = ( 'all' => [ qw(connect_bgpdata read_xml_message close_connection is_connected messages_read uptime connection_endtime get_error_code get_error_message get_error_msg) ] ); our @export_ok = ( @{ $export_tags{'all'} } ); public source code (mine dev)

php - cURL is not working properly except when i put exit() -

curl work fine if put exit() after code: $url = "http://wpmsqa01.xyz.net/stwpmsp/update.php?cmd=changeplan&siteid=876&splan=174"; $curl = curl_init(); curl_setopt($curl, curlopt_returntransfer, 1); curl_setopt ($curl, curlopt_url,$url); $response=curl_exec ($curl); curl_close ($curl); $get_resp=htmlentities($response); but, if remove exit() , won't work.

.net - Masked TextBox doesn't recognize 10 as ten -

Image
for integer = 0 mtpig.text messagebox.show(i) next i used maskedtextbox 2-digit mask. if put 10, shows 0 , 1. if put 9, shows 0-9. why doesn't read 0 next one? (10) how can make 10 read as ten? update: alright, problem prompchar:0, 0s treated prompt character , discarded value. to solve it, either change promptchar _ (underscore) or set maskedtextbox property named textmaskformat includeprompt goog luck!!

ios - How to add string and array -

nsstring *butterfly = [nsstring stringwithformat:@"brush_%d.png", i] i want string in separate brush_ %d.png because have lot of animation function there in project(0 39). if(counter == 0) { nsmutablearray *dashboy = [nsmutablearray array]; (i = 1; i<= 13; i++) { butterfly = [nsstring stringwithformat:@"brush_%d.png", i]; if ((image = [uiimage imagenamed:butterfly])) [dashboy addobject:image]; } [stgimageview setanimationimages:dashboy]; [stgimageview setanimationduration:2.0f]; [stgimageview startanimating]; } . . if(counter == 39) { nsmutablearray *dashboy1 = [nsmutablearray array]; (i = 1; <= 30; i++) { butterfly = [nsstring stringwithformat:@"catch_%d.png", i]; if ((image = [uiimage imagenamed:butterfly])) [dashboy1 addobject:image]; } [stgimageview setanimationimages:dashboy1]; [stgimageview setanimationduration:7.20f]; [stg

excel - Matrix multiply two lists with a formula -

if have 2 lists in excel: x : x1 x2 x3 y : y1 y2 y3 how can make 2-dimensional matrix this?: x1*y1 x1*y2 x1*y3 x2*y1 x2*y2 x2*y3 x3*y1 x3*y2 x3*y3 assuming x1-x3 cells a1:a3 , y1-y3 in b1:b3 , select 3x3 range , enter formula: =a1:a3*transpose(b1:b3) enter array formula, i.e. instead of pressing enter , press ctrl - shift - enter !

android - Animators may only be run on Looper threads error on ObjectAnimator -

i having problem with { animatorset animset = new animatorset(); animset.start(); } getting crash after animset.start getting msg android.util.androidruntimeexception: animators may run on looper threads... please me overcome issue.. try adding new handler().postdelayed(new runnable() { @override public void run() { runonuithread(new runnable() { @override public void run() { animset.start(); } }); } }, 100);

node.js - Fast repeated row counting in vast data - what format? -

my node.js app needs index several gigabytes of timestamped csv data, in such way can row count combination of values, either each minute in day (1440 queries) or each hour in couple of months (also 1440). let's in half second. the column values not read, row counts per interval given permutation. reducing time whole minutes ok. there rather few possible values per column, between 2 , 10, , depend on other columns. it's fine preprocessing , store counts in whatever format suitable single task - but format be? storing actual values bad idea, millions of rows , little variation. it might feasible generate short code each combination , match regex, since these codes have duplicated each minute, i'm not sure it's approach. or can use embedded database sqlite, nedb or tingodb, not entirely convinced since don't have native enum-like types , might or might not made kind of counting. maybe work fine? this must common problem idiomatic solution, haven't fi

SQL - How to find currently running job steps through TSQL -

i writing query find running job in sql (i know can view in job active monitor, i've need in tsql). though can query sysjobactivity table find running job, it's telling job step running (because job might have more 1 step). query used: select s.name [job_name], '' [step_id], '' step_name, 'processing' status, sja.run_requested_date start_time, null end_date, convert(varchar, (getdate() - sja.run_requested_date), 8) duration sysjobactivity sja, sysjobs s sja.job_id = s.job_id , sja.run_requested_date > getdate() - 1 , sja.stop_execution_date null please me finding step id & step name in job progressing. i think below script sql jobs current execution step, try this msdb.dbo.sp_help_job @execution_status = 1

php - Ajax delete product from cart in magento -

i have been working magento cart pro extension. ajax add cart functionality, have followed following link excellance magento blog its working fine.but have searched lot regarding ajax delete item cart, google returns me 3rd party extension. can't find tutorial delete product cart. thought, take referrance 1 of free 3rd party extension have both add cart , delete cart functionality. found following extension have above both function , working rock. ajax cart pro . i have checked extension coding part. i'm confused, can't find code doing delete functionality. have overwrite deleteaction in controller file only, think.i can't understand i'm doing.i need guidance add ajax delete functionality. if have idea or found tutorial of this, please share me thoughts friends. diving ajaxcart extension, in controller's action, find (yeah, right!), following line removing item: $this->_getcart()->removeitem($id)->save(); public function deleteac

xmpp - Getting bad request 400 error using asmack in android -

i trying register new user using xmpp client using asmack library in android on ejabberd server. problem getting following error & user not being created on server: bad-request(400) @ org.jivesoftware.smack.accountmanager.createaccount(accountmanager.java:243) @ in.ui.mainactivity$1$1$1.run(mainactivity.java:316) @ java.lang.thread.run(thread.java:841) following code: _xmppusername = xmppconfig.getstringuserinfovalue (xmppconfig.xmpp_client_id); _xmpppassword = xmppconfig.getstringuserinfovalue (xmppconfig.xmpp_client_password); _xmpphost = xmppconfig.getstringuserinfovalue (xmppconfig.xmpp_host); try { _xmppportno = integer.parseint (xmppconfig.getstringuserinfovalue (xmppconfig.xmpp_port)); } catch (exception e) { e.printstacktrace (); log.e (tag, e.getmessage ()); } _xmppservicename = xmppconfig.getstringuserinfovalue (xmppconfig.xmpp_service_name); connectionconfiguration conconfig = new connectionconfiguration (_xmpphost, _xmppportno, _xmppservicename);

Fedex Tracking Number -

i need integrate fedex api in site. how can new tracking number first time regarding shipping. couldnt find method tracking number? please help, if knows. thanks i guessing meant " create fedex shipment " when refered " new tracking number. " fedex has developer program in can sign , integrate website fedex. once sign up, can: create shipments cancel shipments track packages schedule pickup create call tags etc. the link fedex developer program is: http://www.fedex.com/us/developer . best!

jQuery / Javascript replace multiple occurences not working -

i'm trying replace multiple occurrences of string , nothing seems working me. in browser or when testing online. going wrong? str = '[{name}] happy today data-name="[{name}]" won match today. [{name}] made 100 runs.'; str = str.replace('/[{name}]/gi','john'); console.log(str); http://jsfiddle.net/sxtd4/ i got example here , , wont work. you must not quote regexes, correct notation be: str = str.replace(/\[{name}\]/gi,'john'); also, have escape [] , because otherwise content inside treated character class. updating fiddle accordingly makes work . there 2 ways declaring regexes: // literal notation - preferred option var re = /regex here/; // via constructor var re = new regexp('regex here');

linux - search in output and cat from specific line to specific line and search again -

i wrote like: out=$( nmap -p "$port" --script=http-headers.nse "$ip" for example output is: |http-headers: | server: apache | vary: accept-encoding | content-type: text/html; charset=utf-8 | date: thu, 06 feb 2014 07:31:33 gmt | age: 25 | connection: close but length of output changeable. want search between lines in output (better use sed or awk ) , check condition. example if sees apache line 3 till line 8 echo right edit: my script: #!/bin/bash echo "reading data - headers - both" if [ $# -ne 3 ]; echo "usage: ./nmap <port-range> <ip-list> <d || h || b>" exit 1 fi if [ $3 == h ]; while read -r -u3 port; while read -r -u4 ip; echo -n "$ip $port: " out=$( nmap -p "$port" --script=http-headers.nse "$ip" | tail -n 13 | awk -f: '{print $2; exit}') in other lines [[ $out == *apache* ]] &&

Ruby on Rails Website API Addon -

i know website "what have done first" platform asking general question. im still learning ruby while im creating future business website. im creating ror website , want companies, selling things, plug website using api method. can point me in direction of book read on api development ror websites? i have searched web im not sure if "api" other languages , not ruby. start http://www.railstutorial.org , work through ryan bates' http://www.railscasts.com can tell question. sounds it's going long road ahead of you.

java - Localize time in Android -

i working on android application. user can send post , can see each other's post, pretty twitter. here's issue time. when server serialized timestamp db , send response, responses string this: 2011-09-01 13:20:30+00:00" think +00:00 part utc offset . i wondering what's approach parse string time object in local time zone? can show correctly on ui? thanks! simpledateformat has capability of capturing offset independently in meaningful way. want translate offset zone without explicitly specifying parser instance. using simpledateformat simpledateformat sdf = new simpledateformat("yyyy-mm-dd hh:mm:ssxxx"); try { system.out.println(sdf.parse(date)); } catch (parseexception e) { e.printstacktrace(); } gives, thu sep 01 18:50:30 ist 2011 joda time library provides alternative resolution. datetimeformatter capable of parsing format z added pattern , parsed date in users default timezone . datetimeformatter parser = dat

c++ - Error : no instance of overloaded function -

i'm trying insert lines in database (sql server 2008) code : cdb.cpp #include "cdb.h" void cdb::ajouteralerte(){ sqlconnection ^ mysqlconnection; sqldataadapter ^ mydataadapter; dataset ^ mydataset; datarow ^ myrow; sqlparameter ^ myparameter; try { mysqlconnection = gcnew sqlconnection("data source=nectarys-pc;initial catalog=monitoringn;integrated security=true;"); mydataadapter = gcnew sqldataadapter(); mydataset = gcnew dataset(); // open connection mysqlconnection->open(); mydataadapter->selectcommand = gcnew sqlcommand("select * alerte", mysqlconnection); mydataadapter->insertcommand = gcnew sqlcommand("insert alerte (motif,datealerte," + "fixee,nomposte,nomapplication,nomfichier,fichiermodel_id) values (@motif,@datealerte," + "@fixee,@nomposte,@nomapplicatio

symfony - Symfony2 translations without domain -

i want able use twig translator without having set domain . keep translations organized put them inside resources/translation folder of bundles. don't want them in 1 file. translation in twig need following: {{ 'mystringtotranslate'|trans({}, 'mybundle') }} is there way load bundle translations following: {{ 'mystringtotranslate'|trans }}