Posts

Showing posts from September, 2013

ios - How to make sprite move in a sinusoidal in cocos2d? -

Image
i have sprite (paper plane, example). i'd make move in picture below. can use lots of moveto , rotateby actions define path points, seems bad idea me. how can implemented ? i thought might post answer showed basics of how update work if had explicit control on sprite. i not sure if using cocos2d or cocos2d-x, technique applies in either case. code in c++ using cocos2d-x. the idea that, based on time, (manually) update position of sprite. position of sprite @ time determined number of seconds since animation begun. line nominally follows straight path (x0,y0) (x1,y0). can project line onto line drawn @ angle using trigonometry. gives ability have sinusoidal path along direction. here basic code (the main work done in updateanimation()): // assumes frame rate relatively constant // @ 60 fps. const double seconds_per_tick = 1.0/60; const double duration = 8.0; // seconds total animation. const double x_start = 100; // pixels const double y_star

python - download images with google customsearch api -

my question trivial. tried configure customsearch engine download first 10 results of google image. here python script. works except result far 1 of google image same parameter. can tell me miss? # -*- coding: utf-8 -*- import os import sys urllib import fancyurlopener import urllib2 import simplejson apiclient.discovery import build class myopener(fancyurlopener): version = 'mozilla/5.0 (windows; u; windows nt 5.1; it; rv:1.8.1.11) gecko/20071127 firefox/2.0.0.11' myopener = myopener() service = build("customsearch", "v1", developerkey="** key **") res = service.cse().list( q='searchterm', cx='** cx**', searchtype='image', num=10, imgtype='photo', filetype='jpg', imgsize="xxlarge" ).execute() count=0 item in res['items']: myopener.retrieve(item['link'],str(count)) count=count+1

java - @RequestMapping annotation not working if <context:component-scan /> is in application context instead of dispatcher context -

i'm using spring of version 2.5.6 <context:component-scan /> , @autowired. while i'd been using simpleurlhandlermapping in dispatcher context ok - autowiring working fine, routes picking controllers in right way etc. <bean id="urlmapping" class="org.springframework.web.servlet.handler.simpleurlhandlermapping"> <property name="urlmap"> <map> <entry key="/login/login.html" value-ref="logincontroller" /> <entry key="/secured/index/index.html" value-ref="indexcontroller" /> </map> </property> </bean> then decided use @requestmapping insted of configuring routes in xml file. @controller("logincontroller") public class logincontroller { @requestmapping("/login/login.html") public modelandview login() { modelandview model = new modelandview("login/login");

django - Gunicorn is unable to find my wsgi file, not able to load python? -

so trying run gunicorn script, following tutorial found in internet. here folder structure: (today_project)[littlem@server1 today_project]$ tree . -l 2 . ├── bin │   ├── activate │   ├── activate.csh │   ├── activate.fish │   ├── activate_this.py │   ├── django-admin.py │   ├── django-admin.pyc │   ├── easy_install │   ├── easy_install-2.7 │   ├── gunicorn │   ├── gunicorn_django │   ├── gunicorn_paster │   ├── gunicorn_start │   ├── pip │   ├── pip2 │   ├── pip2.7 │   ├── python -> python2.7 │   ├── python2 -> python2.7 │   └── python2.7 ├── include │   ├── python2.6 -> /usr/include/python2.6 │   └── python2.7 -> /usr/local/include/python2.7 ├── lib │   ├── python2.6 │   └── python2.7 ├── manage.py ├── run │   └── gunicorn.sock ├── today │   ├── #app files ├── today_project │   ├── __init__.py │   ├── __init__.pyc │   ├── __pycache__ │   ├── settings.py │   ├── settings.pyc │   ├── urls.py │   ├── urls.pyc │   ├── wsgi.py │   └── wsgi.pyc └── todo.md when run g

Convert Excel Columns into Rows -

Image
please take @ attached snapshot. how convert original table required table, in easiest manner ? here, have shared small sample, real table quite big having more 100 rows / symbols , 100 columns / dates. therefor not possible manually copy paste data change table format. final output table have 3 columns "symbol, date , value" arranged according dates in ascending order. please suggest how this. thanks here is. put original table in 1 sheet, sheet1 . top left cell being a1 = symbol go sheet, sheet2 . in cell a1 put: symbol in cell b1 put: date in cell c1 put: value go cell a2 , put formula: =indirect("sheet1!a" & 2+mod(row()-2; x);true) go cell b2 , put formula: =indirect("sheet1!r1c" & 2+rounddown((row()-2)/x;0);false) go cell c2 , put formula: =indirect("sheet1!r" &2+mod(row()-2; x)&"c" & 2+rounddown((row()-2)/x;0);false) in formulas above, replace x number of symbols go

error during producing random integer in python -

i using python producing random in integer between 2 value user, code follows. getting error: from random import * i1 = input('enter n1 :') i2 = input('enter n2 :') r = randint({0},{1}.format(i1,i2)) print r here taking i1 , i2 user , want produce random integer between i1 , i2. i getting error: file "index.py", line 6 r = randint({0},{1}.format(i1,i2)) ^ syntaxerror: invalid syntax you need add quotation marks/apostrophes make {0},{1} string: r = randint('{0},{1}'.format(i1,i2)) this pass string random integer function though. function expects 2 integers. need is: r = randint(i1, i2)

scala - How do I break out of a play framework template loop? -

given loop in template this: @for(item <- items) { @if(item.id == 42) { break } } how can make break? break/continue construct available use in play framework template? assuming items scala collection, idiomatic approach not break, filter out elements don't want process before start iterating. i'm guessing collection ordered id, , intention stop once item 42. if indeed case, i'd go this: @for(item <- items.filter(_.id < 42)) { // stuff }

Limit of a sum with parameters : Maple -

i pretty novice maple, working compute limit of sum maple 2 parameters. i have sum(1/sqrt(k*n-sqrt(2)*n^2), k = sqrt(2)*n+1 .. (sqrt(2)+1)*n); so do, limit(1/sqrt(k*n-sqrt(2)*n^2), k = sqrt(2)*n+1 .. (sqrt(2)+1)*n, n = infinity); and maple returned: error, invalid input: limit expects 2nd argument, p, of type or(name = algebraic, set(name = algebraic)), received k = 2^(1/2)*n+1 .. (2^(1/2)+1)*n how can comput limit ? thank in advance time. you forgot include sum in limit command. limit(sum(1/sqrt(k*n-sqrt(2)*n^2), k= sqrt(2)*n+1 .. (sqrt(2)+1)*n), n= infinity); maple responds: 2

shell - Gnu Assembler - using Fork() -

i want spawn shell e.g. /bin/sh. so looked here: http://docs.cs.up.ac.za/programming/asm/derick_tut/syscalls.html fork syscall number 2. so code like: .globl _start .text _start: movl **wtf-here?!?!** (how use pt_regs?), %ebx movl $2, %eax int $0x80 movl $0, %ebx movl $1, %eax int $0x80 .data anybody idea? afaik table state of registers on entry in kernel, not how call it simply put syscall preserve ebx , ecx, , process syscall result follows: pushl ebx # registers preserve pushl ecx movl $2, %eax # system call number fork. int $0x80 # call int popl ecx # restore preserved regs. popl ebx cmpl $-4095,%eax # int returning values between-4095..-1 -> error. jb .lsyscok negl %eax # error. negate value. call seterrno # call procedure sets errno in pic safe way. movl $-1,%eax # set return value in case of error (exa

php - ZEND2 - lastInsertValue returns NULL -

my table looks this: create table data.brand_list ( id bigserial not null, brand_name text, created_at timestamp time zone default now(), ghost boolean, constraint brand_list_id_pkey primary key (id) ) it has sequence: create sequence data.brand_list_id_seq increment 1 minvalue 1 maxvalue 9223372036854775807 start 649 cache 1; alter table data.brand_list_id_seq my code in zend model: public function addrow(brandlist $brandlist) { $data = array( 'id' => $brandlist->id, 'brand_name' => $brandlist->brand_name, 'created_at' => $brandlist->created_at, 'ghost' => $brandlist->ghost, ); $id = (int)$brandlist->id; if ($id == 0) { unset($data['id']); $row = $this->tablegateway->insert($data); var_dump($this->tablegateway->getlastinsertvalue());die; return $id; } else { if ($this->findone($id))

msbuild - Conditionally exclude project from Visual Studio build -

i have visual studio 2012 library project (vc++) includes classes if sdk available. implemented via msbuild condition s in property sheet: <choose> <when condition="exists('c:\ofed_sdk\')"> <propertygroup> <ofedsdkdir>c:\ofed_sdk\</ofedsdkdir> </propertygroup> </when> </choose> [...] <itemdefinitiongroup condition="$(ofedsdkdir) != ''"> <clcompile> <additionalincludedirectories>$(ofedsdkdir)inc\; %(additionalincludedirectories)</additionalincludedirectories> <preprocessordefinitions>have_ofed_sdk; %(preprocessordefinitions)</preprocessordefinitions> </clcompile> [...] certain functionality available if have_ofed_sdk defined. works perfectly. the solution furthermore contains several projects testing library project. test classes compiled conditionally in separate project. my quest

php - Get all text inside html tag with regex? -

for example, have html: <strong>this one</strong> <span>test one</span> <strong>this two</strong> <span>test two</span> <strong>this three</strong> <span>test three</span> how text inside strong , span regex? use dom , never use regular expressions parsing html. $dom = new domdocument; $dom->loadhtml($html); foreach ($dom->getelementsbytagname('strong') $tag) { echo $tag->nodevalue."<br>"; } foreach ($dom->getelementsbytagname('span') $tag) { echo $tag->nodevalue."<br>"; } output : this 1 2 3 test 1 test 2 test 3 demo why shoudn't use regular expressions parse html content ? html not regular language , hence cannot parsed regular expressions. regex queries not equipped break down html meaningful parts. many times not getting me. enhanced irregular regular expressions used perl not task of parsing

html - How To Create a Resolution Scalable Arrow For Website -

i have seen in yahoo , other sites including sites mobile have little arrows pointing , down , these seem scale when 1 zooms viewport. seem crisp on every resolution level , looking create similar. here arrow talking about: arrow image > this arrow yahoo "download all" button. done svg, utf-8 symbol? can done in css? you use font awesome. http://fortawesome.github.io/font-awesome/ font awesome use bootstrap there many similar fonts ets out there regular use too. here's article detailing some: http://thenextweb.com/dd/2012/10/12/7-gorgeous-icon-fonts-to-speed-up-your-site-and-your-design-process/ these icon sets scaleable vector icons meaning work @ different resolutions.

math - matlab PID controller, SISO tools gives a "pid" with s^2 in the denominator -

when try use sisotool in matlab, gives me equation pid controller 0.056301 * (1+1000s) s(1+4.2s) this means equation comes out s^2 in denominator. not equation pid. i don't understand that. mean pid not exist system? does mean pid not exist system? no, doesn't. textbooks introduce transfer function of pid controller using expressions like c(s) = kp + ki/s + kd*s for simplicity , emphasise conceptual aspects. however, pure differentiation useful term. can see both in time , frequency domain. s increases, last term above increases without bound. in time domain, last term differentiate not useful signals, noise in input of pid controller. recall happens when differentiate sin or cos : frequency @ front coefficient. anyway, these 2 aspects of same phenomenon. so, next step start designing more practical pid replace term kd*s filter of form kd*a*s/(s+a) if sum terms in c(s) filter substituted kd*s s^2 in denominator. the control

javascript - ProcessingJS: Draw doesn't appear to be looping? -

processingjs: draw doesn't appear looping. i'm trying make simple game have box @ bottom, , blocks fall top , need catch them. draw doesn't seem looping should temporary solution i'm using redraw upon key pressed. i've tested other programs written others on web server , work. there problem in code? edit: changed code conform suggestions - still not working example at: http://jordantheriault.com/processing/test.html edit2: i've narrowed down nested loops in draw. //size of each cell box int cellwidth = 25; //width , height of playable space in cells int w = 8, h = 15; //player position int playerx = 0, playery = h-1; //score int score = 0; int lives = 10; int[][] map = new int[w][h]; // 1 = player // 2 = object catch void setup() { size(cellwidth*w+1, cellwidth*h+1); background(51); fill(255); framerate(30); //starting position player map[playerx][playery] = 1; } void draw(){ if(lives > 0) { background(51);

python - If statement in Django not working in properly -

i have small project , have been unable following statement work. great. user inputs can either self.sale_head $ value,if $ value not add self.estimated_weight_hd used total weight, code below should return estimated_weight_total can used total sale price. works when add estimated_weight_total manually. lost why. def calc_estimated_weight_total(self): if self.sale_head <= 0: amount = (self.number * self.estimated_weight_hd) return amount def save(self): self.estimated_total_weight = self.calc_estimated_weight_total() super(salenote, self).save() your code doesn't want cause if self.sale_head > 0 nothing return. description, think code should somthing like: def calc_estimated_weight_total(self): if self.sale_head <= 0: amount = (self.number * self.estimated_weight_hd) return amount else: return something_only_you_know def save(self): self.estimated_total_weight = self.calc_estimated_weig

php - change property of button under certain condition -

i'm trying php only. i have html buttons connected php array. the array's arranged this: $board=array( array("w","",""), array("","","w"), array("w","","") ); i use loop assign position of array variables. this: $i=0; ($row=0;$row<3;$row++){ fop($column=0;$column<3;$column++){ $("b".$i)=$board[$row][$column]; $i++}} this creates, example, $b0=$board[0][0]. on html side, have buttons named "b0". print if these buttons pressed, , has "w" assigned corresponding position in array: for($e=0;$e<9;$e++){ if(isset($_post["b$e"])){ /*this button on html*/ if($("b".$e")=="w"){ /*this represents array positions*/ print "assigned"} }} it prints "assigned" if "w" exists in array position(tested,it works) what trying point, either change button valu

Java Compressing an Image using Arrays 2D to 1D? -

i having trouble assignment of mine. have class reads in pgm image files. need create few classes, main 1 being compression class. need compress pgm (represented 2d arrays) 1d array. here instructions: public static short[] compress(short[][]) is passed 2d array of shorts represents image. returns compressed image 1d array of shorts. that method main concern . compression idea: look horizontal or vertical runs of pixel values , record number of times pixel value repeated itself. note spektre: called rle run length encoding used pcx example algorithm: 1.compute compressed image array using horizontal runs 2.compute compressed image array using vertical runs 3.choose compress image uses best technique particular image. 4.set header of image set first , second values of short [ ] result array width , height values. set third value in short[ ] result array 1 horizontal or 2 vertical compression. 5.set image body the rest of short [ ] result arr

Yet another Facebook OAuth error 500 -

today moved facebook application nodejitsu , couldn't figure out wrong in oauth/dialog request. i validated had: added new application domains application settings the redirect uri good, example, app.nodejitsu.com i played around these properties , didn't figure out why still giving me 500 error. checked of posts on stackoverflow , although seemed valid errors, didn't seem reflect issue. this how found problem. after migrating app nodejitsu localhost app still worked. decided remove localhost accepted app domains in facebook settings. when tested again got error: "given url not allowed application configuration.: 1 or more of given urls not allowed app's settings. must match website url or canvas url, or domain must subdomain of 1 of app's domains." ok, made think. if problem incorrect domain still message nodejitsu, had error request reckoned. i manually edited request , figured out redirect_uri did not start http. i c

Replace text in a tag using javascript? -

how may target links in list items using javascript remove characters? example have following code: <dd class="xments"> <ul> <li><a href="#">"blah blah",</a></li> <li><a href="#">"lo lo",</a></li> <li><a href="#">"hhe he"</a></li> </ul> </dd> i wish remove " , , each list item. please 1 help? $("a").text(function(_, text) { return text.replace('"', ''); return text.replace(',', ''); }); doesn't seem me. how target items in list , not tags in doc? $('a').each(function (i, e) { $(e).text($(e).text().replace(/[",]/g, '')) }); yours regexp (and additional conditions): $("dd.xments ul li a").text(function(idx, text) { return text.replace(/[",]/g, ''); });

Difference between Kafka and ActiveMQ -

i have been working on active mq quite time , familiar active mq architecture. have been hearing lot kafka messaging system. advantages have on active mq , other messaging system? big data buzz word? kafka suitable 0 loss messaging system? this broad discuss in opinion important factor kafka on activemq throughput . wiki page kafka provides extremely high throughput distributed publish/subscribe messaging system. additionally, supports relatively long term persistence of messages support wide variety of consumers, partitioning of message stream across servers , consumers, , functionality loading data apache hadoop offline, batch processing. also kafka suitable 0 loss messaging system? in brief kafka guarantees these following : 1) messages sent producer particular topic partition appended in order sent. 2) topic replication factor n, tolerate n-1 server failures without losing messages committed log.

javascript - Slideshow with timer -

i wondering if there anyway make slideshow of images countdown timer on slideshow. i making exercise app, , need course option. on course option going show exercise 20 seconds, rest 10 seconds etc. until end of course. i have exercises ready, in images. need code show image slideshow, countdown timer it. thanks! slideshow timer using setinterval() method. try this: <img src="some_source/to/file.png" alt="text" /> then can run function change src attribute as setinterval(changeattr, 20000); function changeattr() { $('img').attr('src', 'next_image.png'); } you can use if else block change image like: if($('img').attr('src') == 'some_image_file.png') { $('img').attr('src', 'new_image_file.png'); } now timer execute each 20 seconds , change image's source attribute. use if else block determine image set slideshow image.

clojure - Hiccup template function -

i'm trying add following hiccup template function file (defn d3-page [title js body & {:keys [extra-js] :or {extra-js []}}] (html5 [:head [:title title] (include-css "/css/nv.d3.css")) (include-css "/css/style.css")] [:body (concat [body] [(include-js "http://d3js.org/d3.v3.min.js") (include-js (str "https://raw.github.com" "/novus/nvd3" "/master/nv.d3.min.js")] (map include-js extra-js) [(include-js "/js/script.js") (javascript-tag js)])])) but keep getting unmatched delimiter when run lein ring server . comes clojure data cookbook , surprised find error , suspect error on end. below rest of code in file: (ns web-viz.web (:require [compojure.route :as route] [compojure.handler :as handl

Is there support for the HSV color model in cairo / gdk / gtk? -

well, question quite simple think. specify colors using hsv color model ( https://en.wikipedia.org/wiki/hsl_and_hsv ). however, cairo code seems work exclusively rgb / rgba specifications. not find ways convert colors in gtk / gdk either. missing or there simple, portable way convert colors (without additional libraries)? convertion hsv rgb couple of lines of code, see example here (no code) or so question . but answer original question: afaik cairo entirly based on rgba model, see cairo_format_t in manual .

UML Uses case Actor choice -

i'm working on dashboard project. i'm using uml modeling. first task use case diagram. the clasic actor has 1 action requesting data wants. work done application. how model in uml use case ? an actor can have 1 or many use cases connected him. number not limited. yes, every use case =behaviour realized application, or uml standard names it, subject (of project). in use case diagram subject defined behaviours. simplest form of use case diagram has no actors, ovals of use cases , nothing else. should name behaviours/actions of system. list, in graphic form. further steps not necessary. you define different kinds of users system , say, users can use actions. starter better stop here. or, @ least, create more thorough use case diagrams other ones. some actions connected including or extending dependencies. the next step joining use cases in groups , name them subsystems. not mix them real sw or hw components! become such, you'll decide later. the next ste

algorithm - Rewriting sentences while retaining semantic meaning -

is possible use wordnet rewrite sentence semantic meaning of sentence still ways same (or same)? let's have sentence: obama met putin last week. is possible use wordnet rephrase sentence alternatives like: obama , putin met previous week. obama , putin met each other week ago. if changing sentence structure not possible, can wordnet used replace relevant synonyms? for example: obama met putin previous week. if question possibility use wordnet sentence paraphrases. possible grammatical/syntax components. need system that: first individual semantics of tokens , parse sentence syntax. then understand overall semantics of composite sentence (especially if it's metaphorical) then rehash sentence grammatical generator. up till know of ace parser/generator can takes lot of hacking system make work paraphrase generator. http://sweaglesw.org/linguistics/ace/ so answer questions, is possible use wordnet rephrase sentence alternatives? sadly, wor

knockout.js - knockout js observable array removing all items -

i new knockout js. trying remove item knockout observable array. remove function removing items in array. can me on this? the following how viewmodel looks like function reservationsviewmodel() { var self = this; self.availablemeals = ko.observablearray([ { mealname: "standard (sandwich)", price: 0 }, { mealname: "premium (lobster)", price: 34.95 }, { mealname: "ultimate (whole zebra)", price: 290 } ]); self.seats = ko.observablearray([]); self.addseat = function() { self.seats.push(self.availablemeals()); } self.removeseat = function(seat) { self.seats.remove(seat) } } ko.applybindings(new reservationsviewmodel()); here js fiddle http://jsfiddle.net/pqn32/ thanks, praveen. every time call self.availablemeals() , the same array object back. not an object same properties , values , the same object . means self.seats contains multiple copies of same object. knockout's remove function removes items =

ios - AFNetworking 2.0 parsed data not displaying in table view -

my issue: no data displaying in table. below code being used retrieve json object array , parse using afnetworking 2.0. have uiviewcontroller placed tableview prototype cell has reuse identifier eventcell. want display title , image in every cell. no errors @ runtime. nsdictionary+events.h #import <foundation/foundation.h> @interface nsdictionary (events) - (nsstring *)eventimage; - (nsstring *)eventtitle; - (nsdate *)eventdate; - (nsnumber *)eventprice; - (nsnumber *)eventticketstotal; @end nsdictionary+events.m #import "nsdictionary+events.h" @implementation nsdictionary (events) - (nsstring *)eventimage { return self[@"event_image"]; } - (nsstring *)eventtitle { return self[@"event_title"]; } - (nsdate *)eventdate { // nsstring *datestr = self[@"date"]; // date = "2013-01-15"; return [nsdate date]; } - (nsnumber *)eventprice { nsstring *cc = self[@"event_price"]; ns

Linq - Get last entry from different customers -

i try create linq query unfortunately have no ideas resolve problem. highest entry of customers , form result 5 entries sort date. id date id_costumer 1 - 01.01.2014 - 1 2 - 02.01.2014 - 2 3 - 02.01.2014 - 1 4 - 03.01.2014 - 1 --> value 5 - 04.01.2014 - 3 6 - 05.01.2014 - 3 --> value 7 - 05.01.2014 - 4 8 - 06.01.2014 - 4 --> value 9 - 08.01.2014 - 5 --> value 10 - 09.01.2014 - 6 --> value i try query var query = g in context.geraete g.online && g.altgeraet == false select g; query.groupby(g => g.id_anbieter).select(g => g.last()); query.take(5); but doesn't work. you should assign results of selecting last item group query variable: query = query.groupby(g => g.id_anbieter).select(g => g.last()); var result = query.take(5); keep in mind - operator last() not supported linq entitie

c# - XML enum deserialization -

i have c# enum generated following xsd. <xsd:schema xmlns:xsd="http://www.w3.org/2001/xmlschema"> <xsd:element name="mails" type="mailstype" /> <xsd:complextype name="mailstype"> <xsd:sequence minoccurs="0" maxoccurs="unbounded"> <xsd:element name="mail" type="mailtype" /> </xsd:sequence> </xsd:complextype> <xsd:complextype name="mailtype"> <xsd:sequence> <xsd:element name="envelope" type="envelopetype" /> <xsd:element name="body" type="bodytype" /> <xsd:element name="attachment" type="attachmenttype" minoccurs="0" maxoccurs="unbounded" /> </xsd:sequence> <xsd:attribute use="required" name="id" type="xsd:integer" /> </xsd:complextype> <xsd:element name=

elasticsearch - Filter facet returns count of all documents and not range -

i'm using elasticsearch , nest create query documents within specific time range doing filter facets. query looks this: { "facets": { "notfound": { "query": { "term": { "statuscode": { "value": 404 } } } } }, "filter": { "bool": { "must": [ { "range": { "time": { "from": "2014-04-05t05:25:37", "to": "2014-04-07t05:25:37" } } } ] } } } in specific case, total hits of search 21 documents, fits documents within time range in elasticsearch. "notfound" facet returns 38, fits total number of errordocuments statuscode value of 404. as understand documentation, facets collects data withing search. in case, "notfound" facet should ne

android - How to display EditText in a TextView after changing it to BigDecimal? -

i want precise number edittext change in bigdecimal , show in textview. here's part of code: bigdecimal rate_string = new bigdecimal(0); edittext rate = (edittext) findviewbyid(r.id.rate_edittext); rate_string = (bigdecimal) rate.gettext(); textview test = (textview) findviewbyid(r.id.textview1); test.settext(rate_string.tostring()); but doesn't work! should do? thanks bigdecimal rate_string = new bigdecimal(0); edittext rate = (edittext) findviewbyid(r.id.rate_edittext); rate_string = (bigdecimal) rate.gettext(); textview test = (textview) findviewbyid(r.id.textview1); test.settext(rate_string.tostring()); to bigdecimal rate_string; // p.s here useless creation edittext rate = (edittext) findviewbyid(r.id.rate_edittext); rate_string = new bigdecimal( rate.gettext().tostring() ); textview test = (textview) findviewbyid(r.id.textview1); test.settext(rate_string.tostring()); you cannot convert string bigdeciaml using cast bigdecimal have constructor takes

sql server - Efficient way to generate fixed length fields flat file - T-SQL or SSIS package with flat-file as destination -

do think efficient method generate record fixed length fields using t-sql sql server 2012? insert #record select right('0000000000' + rtrim(field01), 10) +right(' ' + rtrim(field02), 10) +right('00000' + rtrim(field03),6) + etc ... +right('0000000000' + rtrim(fieldnn, 10) sourcetable or should use ssis package sourcetable , flat-fileasdestination , mapped , derived fields. if dataset not big performance perspective doesn't matter if export data t-sql, siss package or whatever. if one-time task you'd better use management studion it. right click database go tasks->export data... . in wizard choose source database , table. choose flat file destination. there can choose format. among options 1 need fixed length . on configure flat file destination step can edit mappings set columns export , length should be. if dataset large and/or want automate process should consider using bcp utility supports fixed width

spring - Injected bean reset to NULL in the Aspect -

i new spring aop , aspectj . have seen various posts related injected bean in aspect being null , have run similar problem. still not clear how should proceed past problem encountering. issue: using spring 3.2.3 , injection through annotation. in case, dependent bean injected spring @ point of execution injected bean null. btw, doesn't happen time can stack trace when fails , when succeeds different. when injected bean not null (i can use injected bean service), call before advice (in aspect) happens before target method called should.when injected bean null, call aspect first statement of target method. @ point, think aspect instantiated , has no reference injected bean. here aspect have created: @component @aspect public class enable{ private nameservice nameservice; @autowired public void setnameservice(nameserice service){ // service injected this.nameserice = service; } @before("* *.*(..)&quo

android - ValueAnimator duplicate Values when starting -

im using valueanimator (from nineoldandroids ) animate view in viewgroup. valueanimator anim = valueanimator.ofint(mhandlerect.left, mdisplayrect.right - mhandlewidth); anim.setduration(delta); anim.addupdatelistener(onanimationupdatelistener); anim.addlistener(onanimationlistener); anim.start(); in case 0 402, have tried other values. then i'm using values in animation update listener: @override public void onanimationupdate(valueanimator animation) { int val = (integer) animation.getanimatedvalue(); log.d("animation animating", " current value " + val); } now, here comes problem: the first values 0, multiple times 04-06 22:24:40.128: d/animation animating(22500): current value 0 04-06 22:24:40.128: d/animation animating(22500): current value 0 04-06 22:24:40.313: d/animation animating(22500): current value 0 04-06 22:24:40.313: d/animation animating(22500): current value 0 04-06 22:24:40.

Java When outputting String and method return, why does method return output first? -

in code below, if string "mult" comes before test1(4) method call, why method output before string? , why bounce form outputting first part of method, leaves method output string, returns method output method's return value? code: public class scratch{ public static void main(string[] args){ system.out.println("mult:" + test1(4)); } public static int test1(int n){ system.out.println("n:" + n); return n*2; } } output: n:4 mult:8 the first thing note when use + 2 operands 1 of 2 operands string , result of expression string . therefore, in following method invocation expression system.out.println("mult:" + test1(4)); you invoking printstream#println(string) since out variable of type printstream . note how method accepts single string argument. therefore, string has resolved string concatenation of "mult:" + test1(4) for happen, test1(4) method has executed. public static

Google Analytics and Internet explorer 6 not working -

hello have chat windows application using embedded web view using internet explorer 6 borowser google analytics not showing traffic page embedded in app i want google analytics read traffic here code <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setaccount', 'ua-xxxxxxx-x']); _gaq.push(['_setdomainname', 'mydomain.com']); _gaq.push(['_setallowlinker', true]); _gaq.push(['_trackpageview']); (function() { var ga = document.createelement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getelementsbytagname('script')[0]; s.parentnode.insertbefore(ga, s); })(); </script>

assembly - How to convert ascii number to binary in MC68k -

i have write program requires 20 user inputted numbers 0-100 find average of numbers , categorize them failing or passing saves input ascii in memory , have change ascii binary. know ascii numbers 30-39 in hex unsure how implement in mc68k if input 93 number saved 3933 how convert binary? clear number loop: highest digit character not dealt yet compare digit character '0' ; that's character 0, not value 0 blo done compare digit character '9' bhi done multiply number 0x0a ; 10 in decimal subtract 0x30 character add number jmp loop cone: ...

android - purchaseTime in subscription with in app billing -

i using subscription inapp billing , wondering purchase time in this purchase mypurchase = inventory.getpurchase(my_sky); mypurchase.getpurchasetime(); what purchase time when subscription used? first date user subscribed product or date of renewal of recent payment? please thank you my experience purchase time date first time user made purchase. not updated when subscription renewed. in my app tell user when next renewal date coming up. add months since purchasetime date , present user.

ios - How to transition from UICollectionView to UIViewController like Pinterest/Evernote -

Image
i have uicollectionview , when item selected, i'd animate full screen. transition size of cell full screen , become uiviewcontroller. pinterest , evernote both have behavior tapping on cell transitions cell full screen view controller. are there example of how done? i've searched several projects, haven't found illustrating on transitioning cell full screen view controller. pinterest discusses here: http://engineering.pinterest.com/post/67769846580/behind-the-pins-building-pinterest-3-0-for-ios it's not difficult implement transition. article said, custom transition implement uiviewcontrolleranimatedtransitioning protocol, nothing besides. need calculate new size position imageview tapped animate. that's it. this our 2 apps, implement similar transition effect method above. https://itunes.apple.com/app/hua-ban-quan-qiu-you-mei-tu/id494813494?mt=8 and one: https://itunes.apple.com/app/mei-tu-sou-sou-wan-zhuan-wei/id781146829?mt=8 i'

recursion - Integer to Binary in scala -

just kicks decided write snippet takes integer , converts binary. seems performing conversion wondering if there's might missing this. great feedback. thanks def converttobinary(n: int, bin: list[int]): string = { if(n/2 == 1) { (1::(n%2)::bin).mkstring(" ") } else { val r = n%2;val q = n/2;converttobinary(q,r::bin) } } 1) formatting :-) def converttobinary(n:int, bin:list[int]):string = { if(n/2 == 1) (1:: (n % 2) :: bin).mkstring(" ") else { val r = n % 2; val q = n / 2; converttobinary(q, r::bin) } } 2) signature: i omit convert part, made accumulator optional parameter (function user doesn't have supply arguments used internal implementation, right?) def tobinary(n:int, bin: list[int] = list.empty[int]): string = { if(n/2 == 1) (1:: (n % 2) :: bin).mkstring(" ") else { val r = n % 2 val q = n / 2 tobinary(q, r::bin) } } now can used as: val str = tobinary(42) som

ios - Efficient use of Core Image with AV Foundation -

i'm writing ios app applies filters existing video files , outputs results new ones. initially, tried using brad larson's nice framework, gpuimage . although able output filtered video files without effort, output wasn't perfect: videos proper length, frames missing, , others duplicated (see issue 1501 more info). plan learn more opengl es can better investigate dropped/skipped frames issue. however, in meantime, i'm exploring other options rendering video files. i'm familiar core image, decided leverage in alternative video-filtering solution. within block passed avassetwriterinput requestmediadatawhenreadyonqueue:usingblock: , filter , output each frame of input video file so: cmsamplebufferref samplebuffer = [self.assetreadervideooutput copynextsamplebuffer]; if (samplebuffer != null) { cmtime presentationtimestamp = cmsamplebuffergetoutputpresentationtimestamp(samplebuffer); cvpixelbufferref inputpixelbuffer = cmsamplebuffergetimagebuffer(sampl

scanf - sscanf() in C to skip over an integer and read string -

i have file contains data in form: 1 jake 234 ruby 98. i want use sscanf read strings arrays, tried this: male[i] = malloc(100); female[i] = malloc(100); sscanf(str, "%*d%s%*d%s%*d", &male[i], &female[i]); the problem when i = 0 , function skips first string along first integer. when try print &male[0] , blank space. i have initialised i 0 . please point out might going wrong? thanks lot! use male[i] rather &male[i] . limit string input 99 (1 less size of buffer space) check return value of sscanf() the last "%*d" not anything. - char *male[n]; // assumed sample declaration char *female[n]; male[i] = malloc(100); female[i] = malloc(100); int cnt = sscanf(str, "%*d%99s%*d%99s", male[i], female[i]); if (cnt == 2) success(); if want insure data parsed , no non-white-space @ end.... int n = 0; int cnt = sscanf(str, "%*d%99s%*d%99s%*d %n", male[i], female[i], &n); if (cnt == 2 &&a

angularjs - How can I save additional fields upon user signup when using MEAN stack and Passport? -

i'm trying save more email , password when user signs on site. passport examples show email , password being stored. if have "gender", , "name" fields need stored when user signs up? i've spend day trying figure out no luck. here i'm using: passport.js: passport.use('local-signup', new localstrategy({ usernamefield : 'email', passwordfield : 'password', passreqtocallback : true }, function(req, email, password, done) { process.nexttick(function() { user.findone({ 'email' : email }, function(err, user) { if (err) return done(err); if (user) { return done(null, false, req.flash('signupmessage', 'email taken.')); } else { var newuser = new user(); newuser.email = email; newuser.password = newuser.generatehash(password); newuser.save(function(err

java - Automatic downloading of files from website -

i have website has lot of direct download links. hyperlink titled "download". in order download file, need right click on , press "save link as" , asks location. how make process automatic. mean, fetch links named "download" , right click , save operation. using idm (internet download manager), simplifies click on "download" hyperlink. but, have click on each link. there around 750 such links. there way make process automatic? based on u r description understood that, u need download files site u own. if own site. u can login hosting panel. website developer might have placed folder files. use ftp client link filezilla or thing else , using u r ftp credentials login , download files in folder. if want clone every thing in u r hosting or site use cuteftp ftp client software. after login u site. go menu , clone u r directory. if don't own site or if donot have ur credentials. here other options. there many ways u can sol

r - editing the legend on geom_text() -

Image
i never have trouble editing legend ggplot, geom_text seem having trouble. <- ggplot(threedusg, aes(x=dxrapm, y=x3par, label=threedusg$player)) + geom_text(aes(size=threedusg$cs3,hjust=0,vjust=0)) + scale_x_continuous(limits=c(0,6)) here legend looks http://imgur.com/h6vzn2b the size of text comes data percentages. prefer have text in legend read actual percentages. instance says .30 instead of 30%. appreciated! using scales library (which need explicitly load), can use percent labeller. (note shouldn't referencing columns of data set using $ within ggplot call. library(scales) ggplot(threedusg, aes(x = dxrapm, y = x3par, label = player)) + geom_text(aes(size = cs3), hjust = 0, vjust = 0) + scale_x_continuous(limits = c(0,6)) + scale_size(label = percent) on reproducible example foo <- data.frame(x=1:5,y=1:5,player=letters[1:5],rate = c(0.2,0.5,0.7,0.1,0.8)) ggplot(foo, aes(x=x,y=y,label=player)) + geom_text(aes(size=rate)) + sca