Wednesday, 15 September 2010

long polling - Liferay Unsychnonized message listener, Send message to page after complete backend operation -



long polling - Liferay Unsychnonized message listener, Send message to page after complete backend operation -

i have implemented liferay asynchronous messagelistener 1 task, takes 20 minutes, reason why using message listener.

but requirement that, after finish back-end process i have show success message user "your info loaded...". don't want utilize ajax polling

please suggest me:

how can stuffs in liferay? there long polling procedure in liferay?

ps: using liferay 6.1.2-ce-ga3

as reference, used doc: https://www.liferay.com/documentation/liferay-portal/6.1/development/-/ai/lp-6-1-dgen09-using-message-bus-0

if don't want utilize ajax, i'd recommend implement "current status". whenever portlet displayed can display if operation still executing or if has completed. how figure out? well, that's part of backend implementation, not portlet level, that's ui.

with this, extend ui status list updated through ajax, incidently not hard, 1 time you're ready go ajax.

on frontend, don't want long polling http requests open through application server - if you're looking this.

there's mechanism liferay's chat portlet , notification portlet use, called poller. however, ajax, don't know if qualifies requirements. check this forum post, note, it's quite old , mentioned bug seems fixed. don't know if developer guide has chapter on well, name i'm confident can find more info

liferay long-polling message-listener

java - How is this below code identifying prime numbers -



java - How is this below code identifying prime numbers -

this code identifies prime numbers given number. if input, 7, returned arraylist have first 7 prime numbers in it.

public static arraylist<integer> calcprime(int inp) { arraylist<integer> arr = new arraylist<integer>(); arr.add(2); arr.add(3); int counter = 4; while(arr.size() < inp) { // 23 , 25 if(counter % 2 != 0 && counter%3 != 0) { int temp = 4; while(temp*temp <= counter) { if(counter % temp == 0) break; temp ++; } if(temp*temp > counter) { arr.add(counter); } } counter++; } homecoming arr; }

my question this. understand code filtering numbers divisible 2 , 3. other numbers, 23 or 25, relying on squares of numbers 4.

i want know how achieving goal. please help me understanding this.

the bit that's doing checking this:

if(counter % temp == 0) break;

it's not relying on squares of numbers @ all. that's telling when stop checking numbers.

first initial set up. knows 2 , 3 primes, adds them list.

then, starting @ 4, checks see if number prime. if is, adds array, if it's not skips out , checks next number.

so "checks see if number prime" done by: first checking if it's divisible 2 or divisible 3:

if(counter % 2 != 0 && counter%3 != 0)

then, starting @ 4 again, doing same check: potential prime (counter) divisible number (temp) ?

if(counter % temp == 0)

if that's case, it's not prime number break command , checks next counter see if that's prime.

if counter not divisible temp increments temp , checks again. when temp big it's not worth checking if it's factor more, algorithm knows counter prime, , adds list.

the temp*temp bit because when it's checking see if number prime, doesn't have check of numbers counter. if temp*temp greater our target, temp factor, other factor has less temp, , has been checked.

java primes

php - Dynamically referencing object ID with javascript in Yii -



php - Dynamically referencing object ID with javascript in Yii -

i'm creating tabular input yii, works fine , can save values fields. want add together field next input field, shows value of input field multiplied/divided value. want value updated whenever value in input field changed. input fields created with:

echo $form->textfield($productorder, "[$index]unitsshipped", array( 'onchange' => 'javascript:$("#pallets0").val(this.value/7)' ));

the field next with:

echo $form->textfield($productorder, "unitsshipped", array( 'id' => "pallets".$index, ));

where of above fitted within loop.

the above works, first field, because im statically referencing same field input fields. dont know how can assign dynamically? id pallet field assigned dynamically , if instance set "onchange" reference "pallet1" work, ofc next pallet field.

i've tried concenate strings in javascript, far without luck.

this should work reference current pallets, assuming both fields in same loop index

echo $form->textfield($productorder, "[$index]unitsshipped", array( 'onchange' => 'javascript:$("#pallets'.$index.'").val(this.value/7)' ));

javascript php yii tabular

clojure - Documenting functions defined using point-free style -



clojure - Documenting functions defined using point-free style -

when creating library in clojure, it's practice include docstrings , other metadata on each function, e.g.:

(defn ^boolean foo "returns whether x bar." {:added "1.5"} [x] (bar? x))

sometimes (when working higher-order functions) ends beingness easier define function using def (something-that-returns-a-fn), this:

(defn wrapper [f] "some hof, let's prints 'wharrgarbl' , returns fn." (println "wharrgarbl") f) (def foo "prints 'wharrgarbl' , returns whether x bar." (wrapper (fn [x] (bar? x))))

if i'm not mistaken, defining functions in way nullifies advantages of using defn -- namely, docstring beingness printed in nice way includes arities function supports, , ability concisely include attribute map within function definition. right, or there other concise way document functions created via hofs? this:

(defn foo "prints 'wharrgarbl' , returns whether x bar." {:added "1.5"} [x] ((wrapper (fn [y] (bar? y))) x))

but seems little redundant , unnecessarily complicated, i'm defining function of x function of y, applied x. there improve way?

you can add together whatever metadata wish def.

(def ^{:doc "does something." :added "1.5" :arglists '([x]) } foo (wrapper (fn [x] (bar? x))))

clojure metadata docstring

MAC OSX About Logout the terminal remote "not sure" -



MAC OSX About Logout the terminal remote "not sure" -

it's first post , i'm not quite in english. if explained not clear please allow me know.

for simple when logged in terminal.app (on mac osx) prompt should

<hostname>:<path> <username>$

my local hostname "macintosh" hostname "foobar.com"(don't need publish name example)

i had enable remote function , logged in "foobar.com" self, confused? mean of on local.

first, local hostname macintosh, enabled scheme `preferences>network>remote login` obtained foobar.com log in. then, logged <username>@foobar.com. hostname foobar.com , grouping staff. so, need logout myself <username>:admin , hostname "macintosh"

how can done that?

osx terminal remote-access remote-desktop

ruby - What's the equivalent to $SAFE=4? -



ruby - What's the equivalent to $SAFE=4? -

i playing threads , eval when ran issue. code is:

thread = thread.start { $safe = 4; eval("`touch ~/test`") } thread.join

but results in error:

argumenterror: $safe=4 obsolete (irb):2:in `block in irb_binding'

i found $safe=4 became obsolete in ruby 2.1:

$safe=4 obsolete. if $safe set 4 or larger, argumenterror raised.

but not mentioned should used instead. there equivalent $safe=4? want run eval safest way.

the way see exploit binding safe evals

http://rdoc.info/stdlib/core/2.1.0/binding

class demo def initialize(n) @secret = n end def get_binding homecoming binding() end end k1 = demo.new(99) b1 = k1.get_binding k2 = demo.new(-3) b2 = k2.get_binding eval("@secret", b1) #=> 99 eval("@secret", b2) #=> -3 eval("@secret") #=> nil

ruby eval

unit testing - Compare image in dalekjs -



unit testing - Compare image in dalekjs -

i wanted automate image comparing through dalekjs. aim have improve image comparisons through external libraries starters basic image comparing tell if image on page equal local image. help highly appreciated.

still experimental , yet merged dalekjs core, seek using gskachkov's pull request here adds screenshot comparing functionality dalekjs.

otherwise, recommend utilize phantomcss visual regression framework time being. phantomcss built on top of casperjs , uses resemble.js image comparison.

image unit-testing automation dalekjs

c++ - Detect zero after std::remainder() call on doubles -



c++ - Detect zero after std::remainder() call on doubles -

i have code:

double = remainder(92.66, 0.01); double b = remainder(92.87, 0.01);

and turns out a = -5.33948e-15and b = -2.61423e-15

the reply here zero, , if multiplied both numbers 100 , did integer modulus be. i'd able using doubles. problem remainder returning number bigger dbl_epsilon - correct(best approximation) way determine whether a or b ~zero?

dbl_epsilon smallest quantity can added 1.0. if number larger 1.0, epsilon number proportionately larger well. multiply dbl_epsilon number threshold.

double = remainder(92.66, 0.01); if (a <= dbl_epsilon * 92.66) = 0.0;

c++ modulus

gcc - "Clean" linking with dynamic libraries (no LD_LIBRARY_PATH)? -



gcc - "Clean" linking with dynamic libraries (no LD_LIBRARY_PATH)? -

the title pretty much sums up. i'm trying link dynamic library when compiling another. here (short , humble) makefile:

all: src/ gcc -fpic -shared src/argsort.c -o libsort.so -lm gcc -fpic -shared src/kdtree.c -o libkdtree.so -l./ -lsort -lm

so i'm first building libsort.so. works great. i'm building libkdtree.so uses libsort.so. compilation goes great too, libkdtree.so unusable: here output of ldd libkdtree.so:

ldd libkdtree.so linux-vdso.so.1 => (0x00007fffcc54e000) libsort.so => not found libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f6b3c532000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f6b3c172000) /lib64/ld-linux-x86-64.so.2 (0x00007f6b3ca57000)

if add together directory ld_library_path, works, link there , can utilize library. ld_library_path meant changed ? have no other selection ? mean share code others, , i'd not inquire people go add together .bashrc can run code. think don't understand -l does, since thought manually link library.

can either give me magic method overlooked, or crunch dreams of clean linking ?

thank !

gcc dynamic-linking ldd

c - SIMD SSE2 instructions in assembly -



c - SIMD SSE2 instructions in assembly -

i'm rewriting programme used 64 bit words utilize 128 bit words. trying utilize simd sse2 intrinsics intel. new program, uses simd intrinsics, 60% percent slower original when had expected to around twice fast. when looked @ assembly code each of them, similar , same length. however, object code (compiled file) 60% longer.

i ran callgrind on 2 programs, told me how many instruction reads there per line. found simd version of programme had fewer instructions reads same action in original version. ideally, should happen, doesn't create sense because simd version takes longer run.

my question: sse2 intrinsics convert more assembly instructions? sse2 instructions take longer run? or there other reason new programme slow?

additional notes: programming in c, on linux mint, , compiling gcc -o3 -march=native.

c assembly simd sse2

how do you count unique factors and insert them into the same data frame in R -



how do you count unique factors and insert them into the same data frame in R -

dput(x) structure(list(state = structure(c(1l, 1l, 2l, 3l, 2l, 4l, 2l, 5l, 5l, 2l), .label = c("illinois", "texas", "california", "louisiana", "michigan"), class = "factor"), lat = structure(1:10, .label = c("41.627", "41.85", "32.9588", "33.767", "33.0856", "30.4298", "29.7633", "42.4687", "43.0841", "29.6919"), class = "factor"), long = structure(1:10, .label = c("-88.204", "-87.65", "-96.9812", "-118.1892", "-96.6115", "-90.8999", "-95.3633", "-83.5235", "-82.4905", "-95.6512"), class = "factor")), .names = c("state", "lat", "long"), row.names = c(na, 10l), class = "data.frame")

i need have column says total total count of each state. can creating column total:

x$total<-1

then

library(data.table x<-data.table(x) x<-x[,total:=sum(total),by=state]

is there better/shorter/efficient way of counting factors in info frame?

you can utilize dplyr (without having create total column):

(edit: @beginner enlightening me existence of n(), can more concise)

library('dplyr') mutate(group_by(x, state), total = n())

@beginner's solution of group_by(x, state) %>% mutate(total = n()) if need go on other manipulations of data. similarly,

x %>% group_by(state) %>% mutate(total = n())

will work, too.

r

How to encrypt php variable in javascript? -



How to encrypt php variable in javascript? -

when creat php variable in javascript, utilize method:

var jarray = <?php echo json_encode($myarray); ?>;

it's if view source code, ther total array in script area.

my problem that, php array contains secret data, , want utilize info in javascritp.

how can hide sourc code, or can do?

i tride javascript obfuscation can't work <?php ?> tag.

thanks!

javascript php variables encryption

VBA calling an access query to fill Excel File -



VBA calling an access query to fill Excel File -

run-time error '3190' many fields defined

i recieve error when click on button calls queries in docmd.transferspreadsheet:

'------------------------------------------------------------ ' creates excel file in path passed ' returns path of file including file name , extension '------------------------------------------------------------ function createexcelfile(path string) string dim outputfilename string outputfilename = path & "summarytemplate.xlsx" dim queries(1 4) string queries(1) = "qryprocessauditscores" 'audit scores queries(2) = "qryprocessauditstations" 'audit stations queries(3) = "qryprocessncs" 'number of nc's queries(4) = "qryprocessauditcount" 'number of audits year dim qry each qry in queries docmd.transferspreadsheet _ acexport, _ acspreadsheettypeexcel12, _ qry, _ outputfilename, _ true next createexcelfile = outputfilename 'return total path end function

when run queries hand in access recieve no such error. have tried compact , repair database no luck. other ideas?

thanks

i ended running sql commands set queries tables, ran transferspreadsheet tables, , ran sql commands drop tables.

vba access-vba ms-access-2010

version control - What can be a reason for getting empty svn repository after loading dump file? -



version control - What can be a reason for getting empty svn repository after loading dump file? -

i trying split existing svn repository since has multiple projects in it. want have separate repositories each. lastly step of splitting loading filtered dump file new repository have problem loaded somehow not see them. thought why happens?

thanks beforehand

i see transactions getting committed. how accessing new repository? starting svnserve on directory? using file:///?

do have svnlook on system? can utilize query particular directory. since we're in directory, it's pretty simple:

$ svnlook youngest .

this should print out lastly revision of repository. should agree svnadmin load.

$ svnlook tree .

this should print out entire directory tree of repository.

if doesn't work. seek these:

$ svnlook log .

that print out lastly log message.

$ svnlook changed

prints out changed.

if svnlook tree . doesn't print out anything, it's possible dump filled empty revisions. true if used svndumpfilter filter out transactions didn't like.

if repo have transactions according svnlook, utilize svnserve run local re-create of repo:

$ svnserve -r .

then open window, , seek this:

$ svn log -v svn://localhost

and see if prints out log of transactions.

addendum

i see have, , can see dropped tags, branches, , trunk.

it looks problem didn't specify thought. when specify include a, you're specifying files @ root of repo.

you have:

$ svndumpfilter include < repo.dump > a.dump

what want this:

$ svndumpfilter include trunk/a tags/a branches/a < repos.dump > a.dump

note how have give full path name of directory tree want include. might able this:

$ svndumpfilter include --pattern "*/a" < repo.dump > a.dump

your dump shows of directories excluded svndumpfilter. can utilize verify you're keeping think keeping.

svn version-control split repository tortoisesvn

ios - Waiting for upload -



ios - Waiting for upload -

i have 100 apps in itunes app store need update. main problem when add together new version in end need go 1 1 , and click ready download, andwer form questions , click submit. there command line way in xcode or whatever? can give hint?

as far know, there no way fill out on itunes connect via command line/scrip.

maybe can right me if i'm wrong.

also, i'm curious. 100 apps in store? seems lot of apps. can give me link?

ios app-store itunesconnect

mysql - Extract Values from records with max/min values -



mysql - Extract Values from records with max/min values -

i posted question before , got great reply realize went logic wrong way. given table this:

name|valuea|valueb1|valueb2 bob | 1| 200| 205 bob | 2| 500| 625 bob | 7| 450| 850 bob | 3| 644| 125 ann | 4| 120| 120 ann | 8| 451| 191 ann | 9| 145| 982

i trying max/min values each unique names , ended with

create tablea (select name,max(valuea),min(valuea),max(valueb1,max(valueb2) grouping name)

but gave me (naturally) high/low each of a, b1, b2 e.g.

bob|1|7|200|644|205|850

what looking b1 , b2 values each of lowest , highest values per unique name in other words in above need

bob|1|7|200|205|450|850 ann|4|9|120|120|145|982

which gives me high , low values , b1 , b2 values contained in high , low value records.

(this not duplicate question. lastly question asked , answered how pull high , low values 3 different fields given unique name new table. turns out not needed although first question answered (and marked such). need values 2 fields high , low values of field given name. if @ question see , solutions in fact different)

select tmin.name, tmin.valuea, tmax.valuea, tmin.valueb1, tmin.valueb2, tmax.valueb1, tmax.valueb2 ( select name, max(valuea) valueamax, min(valuea) valueamin `foo` grouping name ) t bring together `foo` tmin on t.name = tmin.name , t.valueamin = tmin.valuea bring together `foo` tmax on t.name = tmax.name , t.valueamax = tmax.valuea;

mysql max greatest-n-per-group min create-table

ios - How to add new Key to nested plist -



ios - How to add new Key to nested plist -

i have custom plist in app, want add together new key @ nested level.

how can add together ? programatically ?

here construction of plist file: : how accomplish ?

please help , in advance.

you can not edit files in app-bundle. have read in nsmutabledictionary, alter , save documents folder.

/*--- bundle file ---*/ nsstring *path = [[nsbundle mainbundle] pathforresource:@"products" oftype:@"plist"]; nsmutabledictionary *rootdict = [[nsmutabledictionary alloc] initwithcontentsoffile:path]; /*--- set value key ---*/ [rootdict setvalue:@"newkeycontent" forkeypath:@"mobiles.brands.thenewkey"]; /*--- documents path ---*/ nsstring *documentsdirectory = [nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes) lastobject]; nsstring *writablepath = [documentsdirectory stringbyappendingpathcomponent:@"products.plist"]; /*--- save file ---*/ [rootdict writetofile:writablepath atomically: yes];

after have open documents directory otherwise start clean slate.

/*--- documents file ---*/ nsstring *docpath = [nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes) lastobject]; nsstring *path = [docpath stringbyappendingpathcomponent:@"products.plist"]; nsmutabledictionary *rootdict = [[nsmutabledictionary alloc] initwithcontentsoffile:path]; /*--- set value key ---*/ [rootdict setvalue:@"newkeycontent" forkeypath:@"mobiles.brands.thenewkey"]; /*--- bundle file ---*/ [rootdict writetofile:writablepath atomically: yes];

ios objective-c plist

Cant get fonts to work in firefox with heroku + cloudfront + rails 4 -



Cant get fonts to work in firefox with heroku + cloudfront + rails 4 -

recently switched asset_sync , s3 cloudfront on heroku. having issue getting fonts work in firefox. have looked @ font_assets gem - no luck, tried rack-cors. ideas/suggestions?

heroku +rails 4.1 + cloudfront

thanks!

this post might helpful http://thelazylog.com/posts/resolve-cors-fonts-issue-on-firefox-and-now-chrome-too-with-rails-assets-pipeline

i have create fonts.css file , include main layout normal <link> tag

ruby-on-rails heroku amazon-cloudfront

django - Send out base64 string to html5 player "media resource could not be decoded" -



django - Send out base64 string to html5 player "media resource could not be decoded" -

i have uploaded video base64 string stored in gridfs , have django view can set chunks together.

def servevideo(request, *args, **kwargs): info = '' m = multimedia.objects.get(id = args[0]) chunks = client.db.fs.chunks.find({"files_id":objectid(m.media.grid_id)}) chunk in chunks: info = info + chunk['data'] response = httpresponse("data:video/webm;base64,"+data.split(",")[1], content_type='video/webm') homecoming response

so on client side have this:

<video width="500" height="500" controls> <source src="/videos/{{ post.video }}/" type="video/webm"> browser not back upwards video tag. </video>

but doesn't seem work, i'm getting error in web console "media resource not decoded".

note: when straight feed base64 string src attribute works fine.( there no problem base64 info of video ).

django html5 video-streaming base64 gridfs

listview - Create custom list using json data in Blackberry 10 using QML -



listview - Create custom list using json data in Blackberry 10 using QML -

i getting json info web service below:

"list1": [ { "id": "1", "title": "title1", "picture":"myurl" }, { "id": "2", "title": "title2", "picture":"myurl" } ]

now, want create custom listview using json data, title , image.

i have tried many examples this. of links given below:

http://qt-project.org/wiki/jsonlistmodel http://developer.blackberry.com/native/documentation/cascades/device_platform/data_access/using_data_source.html

but, still cannot find solutions. can please help me solve issue?

creating list simple plenty task. it's bit harder because want show image internet, have utilize custom class this. download webimageview.cpp , webimageview.h , add together them within /src directory (if want take @ whole project or follow steps).

add next within applicationui.cpp include new class

#include "webimageview.h"

and within applicationui(bb::cascades::application *app) add

qmlregistertype<webimageview>("org.labsquare", 1, 0, "webimageview");

so qml can access class.

this finish working sample of qml:

import bb.cascades 1.2 import bb.data 1.0 import org.labsquare 1.0 navigationpane { id: nav page { container { listview { datamodel: datamodel listitemcomponents: [ listitemcomponent { type: "item" content: container { label { text: listitemdata.title } webimageview { url: "http://adev.si/files/"+listitemdata.picture } } } ] attachedobjects: [ groupdatamodel { id: datamodel grouping: itemgrouping.none }, datasource { id: datasource source: "http://adev.si/files/somedata.json" remote: true ondataloaded: { datamodel.insertlist(data.list1) } } ] } } } oncreationcompleted: { datasource.load(); } }

i hope helped. need within .pro file

libs += -lbbdata qt += network

if want can import project , utilize it.

json listview qml blackberry-10 momentics

Link in Symfony buildForm label -



Link in Symfony buildForm label -

in form symfony2, how can that:

->add('contract','checkbox',array( 'label' => 'link <a href="#">my link</a>', 'required' => true ))

with valid link, , not html formated ?..

thank help

you need utilize form customization feature. please check article more info -http://symfony.com/doc/current/cookbook/form/form_customization.html

by default label content escaped. don't valid html there.

example of overwrite:

form_theme.twig.html

{% block form_label %} {% spaceless %} <label {% attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>{{ label| trans({}, translation_domain) | raw }}</label> {% endspaceless %} {% endblock form_label %}

template.twig.html

{% form_theme form 'mybundle:form:form_theme.html.twig' %} {{ form_row(form.contract) }}

symfony-2.3

c - realloc() an incremented pointer -



c - realloc() an incremented pointer -

platform: linux 3.2.0 x86 (debian wheezy) compiler: gcc 4.7.2 (debian 4.7.2-5)

i wondering happen if effort realloc() pointer has been incremented. illustration

char *ptr = null; size_t siz = 256; ptr = malloc(siz); ptr = realloc(ptr + 5, siz * 2);

what homecoming value of realloc() phone call be? know realloc()'s documentation states pointer passed must have been returned malloc(), calloc(), or realloc(). assuming means cannot realloc() incremented pointer have been unable verify assumption.

that wouldn't work predictable way, results undefined. 1st argument pass realloc or free must returned malloc, realloc or calloc, or must null.

in case not true ptr[5], because ptr[5] uninitialized. compile error or warning, because ptr[5] not pointer. if pointer (e.g. char **ptr;), still uninitialized, status false, , results undefined, , process crash.

in case not true ptr + 5 either, because ptr + 5 not returned malloc, realloc or calloc (but ptr was), , it's not null. behavior undefined in case, process crash.

c malloc

Yodlee API Account/Summary/all returning body with empty errors array -



Yodlee API Account/Summary/all returning body with empty errors array -

thanks looking @ question,

hitting https://rest.developer.yodlee.com/services/srest/restserver/v1.0/account/summary/all​

with cobsessiontoken , usersessiontoken returns body response empty error array. ie

$response = array("body"=>array("error"=>array(0=>"")));

the business relationship still in testing mode, wondering if api resource worked while in sandbox mode?

i trying obtain list of business relationship user has added.

thanks in advance.

edit

when trying forcefulness json response, need quite fussy headers...

in php: curl_setopt($ch, curlopt_httpheader, array( "content-type: application/json", "accept: application/json" ));

works, whereas:

curl_setopt($ch, curlopt_httpheader, array( "content-type : application/json", "accept : application/json" ));

does not.

this api work in sandbox mode, testing purpose can append cobsessiontoken & usersessiontoken in url itself. i.e. like

https://rest.developer.yodlee.com/services/srest/restserver/v1.0/account/summary/all​?cobsessiontoken ="value"&usersessiontoken="value".

note api using method while rest of apis using post method of http. while, if using site based aggregation should utilize getallsiteaccounts api.

yodlee

javascript - Drag Range Slider - How to add step and an element (comma) to the output -



javascript - Drag Range Slider - How to add step and an element (comma) to the output -

i'm using dragdealer.js , have got far:

fiddle

while dragging through slide, gives output,

question: 1) how can add together "," (comma) output after hundreds unit while dragging?

-> right now:-$ 4023 -> required output:- $ 4,023

2) how implement step shows output in multiple of 100?

-> required output:- $ 4.100 (multiple of 100)

here code:

js:

$(function() { new dragdealer('just-a-slider', { animationcallback: function(x, y) { $('#dragvalue').text(math.round(x * 15000)); } }); var availheight = $('.content-body').outerheight() - $('.content-mask').outerheight(); new dragdealer('content-scroller', { horizontal: false, vertical: true, yprecision: availheight, animationcallback: function(x, y) { $('.content-body').css('margin-top', -y * availheight); } }); });

you can utilize .replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") add together in comma, , if split base of operations 100, ( = 150 ), step through in 100's , can append additional 0's onto text output required.

see fiddle here : http://jsfiddle.net/535pd/4/

javascript jquery

android - How do I add an clicklistener to a row in table Layout -



android - How do I add an clicklistener to a row in table Layout -

i want create table layout in there 2 rows.

in both rows there 1 label , text field when press 1st row or 2nd row prompt dialog open , u come in value set on text field of selected row.

please guide me how create click listener on row illustration , how phone call dialog when row selected.

simply give each tablerow element unique id , define onclick

method:

<tablerow android:id="@+id/one" android:onclick="rowclick">

find row id layout , add together next in java class

tablerow= (tablerow) findviewbyid(r.id.one); tablerow.setclickable(true); tablerow.setonclicklistener(onclicklistener); private onclicklistener onclicklistener= new onclicklistener() { public void onclick(view v) { show_dialog(); } };

then phone call next method

public void show_dialog() { final dialog dialog = new dialog(getapplicationcontext()); dialog.requestwindowfeature(window.feature_no_title); dialog.getwindow(); dialog.setcontentview(r.layout.yourlayout); dialog.settitle("yor title"); dialog.setcancelable(false); final button btnokdialog = (button) dialog.findviewbyid(r.id.resetokbtn); btnokdialog.setonclicklistener(new view.onclicklistener() { public void onclick(view arg0) { } }); seek { dialog.show(); } grab (exception e) { e.printstacktrace(); } }

android onclicklistener android-tablelayout tablerow

learn ruby on rails - RailsLayout gem doesn't create expected files -



learn ruby on rails - RailsLayout gem doesn't create expected files -

following illustration in book learn ruby on rails, ran rails generate layout:install foundation5 --force , checked framework_and_overrides.css.scss file in app/assets/stylesheets/ folder. did not remove simple.css file , suspect did not modify other files mentioned. setting zurb foundation layout stuff.

any thoughts? in advance.

learn-ruby-on-rails

sqlite3 - unicode() for all characters of a query -



sqlite3 - unicode() for all characters of a query -

the unicode() function in sqlite accepts 1 parameter; if execute query:

select unicode(text) table

and suppose table has 1 row abc; result be: 97 numeric unicode code a character; if want numeric unicode code characters in result of query? such thing possible within sqlite?

(i know can numerical codes out of sqlite within environment of programming language; i'm curious if such thing possible sql command within sqlite or not.)

sqlite not have looping constructs; doing in programming language much easier.

in sqlite 3.8.3 or later, utilize recursive common table expression:

with recursive all_chars(id, u, rest) ( select id, unicode(text), substr(text, 2) mytable union select id, unicode(rest), substr(rest, 2) all_chars rest <> ''), unicodes(id, list) ( select id, group_concat(u) all_chars grouping id) select * unicodes

the id required merge values of single source row together; doing single, specific row in mytable easier.

unicode sqlite3

Monitor google search in Java -



Monitor google search in Java -

for master thesis need maintain track of google searches users perform. should web project. @ first want setup server (that acts proxy) monitor actions (search queries) performed user. server should deliver google search page. need maintain track of input users create , corresponding results returned google well.

my questen now.. how should start?

i not sure webserver use. should utilize tomcat / jetty / or else? java server faces or servlets? worked jsf long time ago not sure whether decision utilize it. the server should deliver google search page. here idea: user connects server. server "reads" google page , returns (the source code) user. think of using listener on default search field monitor search queries of users. how possible monitor results returned google? google site uses javascript guess. when user makes input straight sent google , results straight shown on webpage webserver not see connection between client , google services.

the main thought monitor search query , corresponding search results.

i need help , ideas started. little part of thesis. not want start 0 during editing time want create sure create right choices before start.

thank in advance... best regards.

you utilize netty proxy , filter , log search queries. 1 time again why utilize java? describe wan't play man-in-the-middle , manipulate/log http traffic.

a quick google search came python: https://code.google.com/p/proxpy/

edit: , similar in java https://github.com/adamfisk/littleproxy

java search web proxy monitor

Error in Android Studio Build -



Error in Android Studio Build -

my system: windows 7, android studio v0.5.2, jdk v1.7.0_25

i've seen discussed several different places none of solutions seem work me (or haven't tried right combination).

the problem when build project android studio , seek run error: **"error:gradle: execution failed task ':app:packagedebug'.

class org.bouncycastle.asn1.asn1primitive overrides final method equals.(ljava/lang/object;)z"**

this seems have bouncy casstle dll's. i'm leary of changing things in jdk prepare - if need be.

does have definitive solution (and, addressed android studio team? poking around , deleting dlls scheme can't end solution).

here's list of of bc* files on system:

c:\program files\java\jdk1.7.0_25\jre\lib\ext\bcprov-ext-jdk15on-1.46.jar c:\program files\java\jdk1.7.0_25\bin\bcprov-ext-jdk15on-1.46.jar c:\users\scott.coleman\desktop\bcprov-ext-jdk15on-1.46.jar c:\program files\java\jre7\lib\ext\bcprov-ext-jdk15on-1.46.jar c:\eclipse\configuration\org.eclipse.osgi\bundles\270\1\.cp\lib\bcprov-ext-jdk15on-148.jar c:\program files\charles\lib\bcprov-jdk14-143.jar c:\users\scott.coleman\appdata\local\temp\rar$exa0.979\gradle-1.10\lib\plugins\bcprov-jdk15-1.46.jar c:\users\scott.coleman\.gradle\wrapper\dists\gradle-1.10-all\1t6fjo8i1s1ddu1afn3ioaglko\gradle-1.10\lib\plugins\bcprov-jdk15-1.46.jar c:\users\scott.coleman\desktop\bcprov-jdk15on-1.48.jar c:\android\android-sdk\tools\lib\bcprov-jdk15on-1.48.jar c:\eclipse\configuration\org.eclipse.osgi\bundles\247\1\.cp\libs\bcprov-jdk15on-1.48.jar c:\program files (x86)\android\android-studio\plugins\android\lib\bcprov-jdk15on-1.48.jar c:\users\scott.coleman\.gradle\caches\modules-2\files-2.1\org.bouncycastle\bcprov-jdk15on\1.48\960dea7c9181ba0b17e8bab0c06a43f0a5f04e65\bcprov-jdk15on-1.48.jar

somehow, broken library beingness loaded in jre. can print out jar beingness loaded bouncycastle library , seek deleting or replacing it.

add next snippet @ origin of build.gradle file

class klass = org.bouncycastle.asn1.bc.bcobjectidentifiers.class; url location = klass.getresource('/'+klass.getname().replace('.', '/')+".class"); println location.touri().tostring();

android build android-studio

postgresql - how to query using postgres json field where a key is not set? -



postgresql - how to query using postgres json field where a key is not set? -

i can select records match json value where properties->>'foo' = 'bar', if key 'foo' has not yet been set? i've tried where properties->>'foo' null error

no operator matches given name , argument type(s). might need add together explicit type casts. : select "merchants".* "merchants" (properties->>'foo' null)

it's operator precedence issue. is null binds more tightly ->>, code beingness read properties ->> ('foo' null). add together parentheses - (properties ->> 'foo') null.

regress=> select '{"a":1}' ->> 'a'; ?column? ---------- 1 (1 row) regress=> select '{"a":1}' ->> 'b'; ?column? ---------- (1 row) regress=> select '{"a":1}' ->> 'b' null; error: operator not exist: unknown ->> boolean line 1: select '{"a":1}' ->> 'b' null; ^ hint: no operator matches given name , argument type(s). might need add together explicit type casts. regress=> select ('{"a":1}' ->> 'b') null; ?column? ---------- t (1 row)

json postgresql

reporting services - SSRS 2012 Failure sending mail: The report server has encountered a configuration error -



reporting services - SSRS 2012 Failure sending mail: The report server has encountered a configuration error -

i'm junior dba, i'm more of sysadmin dba. i'm struggling reccuring problem in 1 of sql 2012 dev reporting server. we've reports snapshot generated dynamics crm 2013 on dev reporting server. i've been inquire send reports specific email address on attached generated study in pdf. i'm able scheddule subscription run illustration every day @ time , plan did execute well. problem action supposed trigger (sending email) not giving me result i'm expecting. found in study server logfiles intriging entries that, despite googling them around, haven't been able resolved. log entries this:

schedule!windowsservice_203!1764!06/20/2014-14:35:01:: info: handling event timedsubscription info cf25ffaa-99c8-404f-bbf8-00c10ecbbe9b. library!windowsservice_203!1764!06/20/2014-14:35:01:: info: schedule f81461ea-5067- 4d14-b2ad-6930ce8ad3d8 executed @ 06/20/2014 14:35:01. schedule!windowsservice_203!1764!06/20/2014-14:35:01:: info: creating time based subscription notification subscription: cf25ffaa-99c8-404f-bbf8-00c10ecbbe9b library!windowsservice_203!1764!06/20/2014-14:35:01:: info: schedule f81461ea-5067- 4d14-b2ad-6930ce8ad3d8 execution completed @ 06/20/2014 14:35:01. library!windowsservice_203!1764!06/20/2014-14:35:01:: info: initializing enableexecutionlogging 'true' specified in server scheme properties. notification!windowsservice_203!1764!06/20/2014-14:35:01:: info: handling subscription cf25ffaa-99c8-404f-bbf8-00c10ecbbe9b study {f48fd9a9-4df8-e311-a000- 00155d060421}, owner: domain\username, delivery extension: study server email. library!windowsservice_203!1764!06/20/2014-14:35:01:: info: renderfornewsession('/dev_mscrm/customreports/{f48fd9a9-4df8-e311-a000-00155d060421}') library!windowsservice_203!1764!06/20/2014-14:35:01:: e error: throwing microsoft.reportingservices.diagnostics.utilities.serverconfigurationerrorexception: authzinitializecontextfromsid: win32 error: 5; possible reason - service business relationship doesn't have rights check domain user sids., microsoft.reportingservices.diagnostics.utilities.serverconfigurationerrorexception: study server has encountered configuration error. ; library!windowsservice_203!1764!06/20/2014-14:35:01:: info: initializing enableexecutionlogging 'true' specified in server scheme properties. emailextension!windowsservice_203!1764!06/20/2014-14:35:01:: e error: error sending email. exception: microsoft.reportingservices.diagnostics.utilities.rsexception: study server has encountered configuration error. ---> microsoft.reportingservices.diagnostics.utilities.serverconfigurationerrorexception: study server has encountered configuration error. notification!windowsservice_203!1764!06/20/2014-14:35:01:: info: notification 4718cbfe-0fef-481b-b0dd-60fae64c4271 completed. success: true, status: failure sending mail: study server has encountered configuration error. mail service not resent., deliveryextension: study server email, report: {f48fd9a9-4df8-e311-a000-00155d060421}, effort 0

can 1 of guys, faced such problem? mind pointing me out direction follow email sending working?

thanks 1 time again time.

reporting-services dynamics-crm-2013

stdin - Does Python's raw_input interfere with socat? -



stdin - Does Python's raw_input interfere with socat? -

i trying utilize programme plus socat emulate serial device.

#echo.py n=0 while true: s = raw_input() if 'query' in s: print n n+=1

when seek link programme false serial port with

sudo socat -ddd -ddd pty,raw,link=/dev/ttys32,echo=0 exec:"python echo.py"

i don't when reading or writing port. if utilize readline instead of exec, serial info transferred , socat terminal no problem. raw_input doing behind scenes preventing socat providing normal stdin?

python stdin socat

c# - Dispatcher Task /Action Completion -



c# - Dispatcher Task /Action Completion -

i have application fetches info form server , gives result user . info beingness fetched quite big blocks ui sometime. using dispatcher create asynchronous.

here code snippet :-

private void getdata(object sender, routedeventargs e) { list<result> data=new list<result>; dispatcherobject obj= dispatcher.begininvoke(dispatcherpriority.background,(threadstart)delegate { info =data.fetch_data(id, name, url); }); if(obj.completed){ messagebox.show("done!"); } }

but code gives error saying

"cannot implicitly convert type 'system.windows.threading.dispatcheroperation' 'system.windows.threading.dispatcherobject' ".

is there anyway user can notified when background task gets completed?

edit :-

here async/await code

private async void getdata(object sender, routedeventargs e) { task<list<result>> t =task<list<resultsummary>>.factory.startnew(() => data==data.fetch_data(id, name, url)); await t; }

but gives error "" calling thread cannot access object because different thread owns it."

calling dispatcher.begininvoke not enable perform asynchronous actions on background thread unless initialised dispatcher object on background thread. so, instead of using dispatcher want, in order fetch info on background thread , pass info background thread ui thread, can utilize task class.

task.factory.startnew((func<yourdatatype>)delegate() { // fetch info on background thread here (return yourdatatype, whatever is) homecoming dataaccessclass.getdata(); }).continuewith((task<yourdatatype> task) => { // update controls result on ui thread here youruiproperty = task.result; }, taskscheduler.fromcurrentsynchronizationcontext());

obviously, you'll need replace yourdatatype type whatever info type is.

c# wpf dispatcher

asp.net mvc - Client or server validation doesn't work with Data Annotations -



asp.net mvc - Client or server validation doesn't work with Data Annotations -

i'm developing mvc 4 application entity framework 6 , encountered problem info annotations. no matter annotation use, isn't validate. i'm using next view model render form:

public class userviewmodel { [required(errormessage = "first name required")] [display(name = "first name")] [stringlength(100, minimumlength = 2)] public string firstname { get; set; } ... }

in view:

@html.labelfor(m => m.firstname) @html.editorfor(m => m.firstname) @html.validationmessagefor(m => m.firstname)

and gets rendered:

<label for="firstname">first name</label> <input class="text-box single-line" id="firstname" name="firstname" type="text" value="" /> <span class="field-validation-valid" data-valmsg-for="firstname" data-valmsg-replace="true"></span>

when click submit button client validation doesn't triggered , in controller modelstate.isvalid true.

update:

controller:

[httpget] public actionresult edit(int? id) { var model = _userservice.getuserbyid(id); homecoming view(model); } [httppost] public actionresult edit(userviewmodel model) { if (modelstate.isvalid == true) { _userservice.save(model); homecoming view(model); } homecoming view(model); }

the problem post controller, map user object, not userviewmodel. 1 of reasons server-side validation not triggered.

as client-side validation, i'm not sure, same error - view based on user type, rather on userviewmodel.

so controller should this:

[httpget] public actionresult edit(int? id) { var model = _userservice.getuserbyid(id); var viewmodel = new userviewmodel() { firstname = model.firstname, lastname = model.lastname, // other properties }; homecoming view(viewmodel); } [httppost] public actionresult edit(userviewmodel viewmodel) { if (modelstate.isvalid == true) { var model = new user() { firstname = viewmodel.firstname, lastname = viewmodel.lastname, // other properties }; _userservice.save(model); homecoming view(model); } homecoming view(model); }

and top of edit.cshtml should have @model userviewmodel.

hope helps

asp.net-mvc validation

forward - Curl over interface for port forwarding -



forward - Curl over interface for port forwarding -

i'm trying set openvpn , deluge seed torrents via vpn.

i running other services on server, want torrent info go on vpn. way i've accomplished far bind traffic torrent interface via client.

the issue comes port forwarding. procedure described here: https://www.privateinternetaccess.com/forum/index.php?p=/discussion/180/port-forwarding-without-the-application-advanced-users/p1

to forwarded port request needs go via vpn. cannot seem curl via tun0 interface - either no connection, or routing messed up.

any tips on solving problem, or improve approach together?

curl forward openvpn pia torrent

Which is more widely used and acceptable about C operators? -



Which is more widely used and acceptable about C operators? -

though 4 * (num / 6)is more easy understand, num / 6 * 4 right because operator * , / in same priority, , associativity left right.

but, better, , more used / acceptable?

although both correct, parenthesis friend. stick it. paranthesization makes look easier understand fellow programmers reduces chances of logical errors specially when not sure precedence of operators.

c operators priority associative

ios - Web Service call returning SIGABRT -



ios - Web Service call returning SIGABRT -

i'm calling web service returns info of cheapest cost of object searched for. now, i'm hardcoding url search "logitech" brand items. reason, whenever effort utilize single response key phrase "title" or "id", i'm getting sigabrt error this:

terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[__nscfstring objectforkeyedsubscript:]: unrecognized selector sent instance 0x8dbc2e0'

my web service phone call in viewdidload method, , looks this:

nsstring *urlstring =@"http://us.api.invisiblehand.co.uk/v1/products?query=logitech&app_id=dad00cb7&app_key=ab386c3e1b99b58b876f237d77b4211a"; nsurl *url = [nsurl urlwithstring:urlstring]; nsdata *data = [nsdata datawithcontentsofurl:url]; nsmutablearray *itemcallarray = [nsjsonserialization jsonobjectwithdata:data options:kniloptions error:nil]; (nsdictionary *theitem in itemcallarray) { nsstring *titlestring = theitem[@"brands"]; nslog(@"%@", titlestring); }

i'm pulling hair out on one. help appreciated, , give thanks in advance :)

edit:

when log itemcallarray, (a lot of stuff):

errors = ( ); info = { start = 0; "total_results" = 4775; }; results = ( { asins = ( ); "best_page" = { currency = usd; deeplink = "http://www.electronicexpress.com/catalog/20352/logitech"; description = "<null>"; "image_url" = "http://shopping.getinvisiblehand.com/images/no_image_available.png"; "in_stock" = 1; "live_price_url" = "http://api.invisiblehand.co.uk/v1/pages/live_price?url=http%3a%2f%2fwww.electronicexpress.com%2fcatalog%2f20352%2flogitech"; "original_url" = "http://www.electronicexpress.com/catalog/20352/logitech"; pnp = 0; cost = "<null>"; "price_confidence" = low; part = us; "retailer_name" = "electronicexpress.com"; title = "logitech classic keyboard 920003199"; }; brands = ( logitech ); categories = ( ); eans = ( ); id = cc2565b3d498073b74d6fc2baa9155d3; "image_url" = "http://shopping.getinvisiblehand.com/images/no_image_available.png"; isbns = ( ); models = ( ); mpns = ( ); "number_of_pages" = 1; resource = "/products/cc2565b3d498073b74d6fc2baa9155d3"; title = "logitech classic keyboard 920003199"; upcs = ( ); }, { asins = ( ); "best_page" = { currency = usd; deeplink = "http://www.electronicexpress.com/catalog/17951/logitech"; description = "<null>"; "image_url" = "http://shopping.getinvisiblehand.com/images/no_image_available.png"; "in_stock" = 1; "live_price_url" = "http://api.invisiblehand.co.uk/v1/pages/live_price?url=http%3a%2f%2fwww.electronicexpress.com%2fcatalog%2f17951%2flogitech"; "original_url" = "http://www.electronicexpress.com/catalog/17951/logitech"; pnp = 0; cost = "<null>"; "price_confidence" = low; part = us; "retailer_name" = "electronicexpress.com"; title = "logitech k120 usb keyboard 920002478"; }; brands = ( logitech ); categories = ( ); eans = ( ); id = d46e49d5b7a0f85f5b7e4eaaeded480e; "image_url" = "http://shopping.getinvisiblehand.com/images/no_image_available.png"; isbns = ( ); models = ( ); mpns = ( ); "number_of_pages" = 1; resource = "/products/d46e49d5b7a0f85f5b7e4eaaeded480e"; title = "logitech k120 usb keyboard 920002478"; upcs = ( ); }, { asins = ( ); "best_page" = { currency = usd; deeplink = "http://www.electronicexpress.com/catalog/18226/logitech"; description = "<null>"; "image_url" = "http://shopping.getinvisiblehand.com/images/no_image_available.png"; "in_stock" = 1; "live_price_url" = "http://api.invisiblehand.co.uk/v1/pages/live_price?url=http%3a%2f%2fwww.electronicexpress.com%2fcatalog%2f18226%2flogitech"; "original_url" = "http://www.electronicexpress.com/catalog/18226/logitech"; pnp = 0; cost = "<null>"; "price_confidence" = low; part = us; "retailer_name" = "electronicexpress.com"; title = "logitech z506 5.1 speakers 980000430"; }; brands = ( logitech ); categories = ( ); eans = ( ); id = 7f1b492e40e2a8956475f24f74c0e152; "image_url" = "http://shopping.getinvisiblehand.com/images/no_image_available.png"; isbns = ( ); models = ( ); mpns = ( ); "number_of_pages" = 1; resource = "/products/7f1b492e40e2a8956475f24f74c0e152"; title = "logitech z506 5.1 speakers 980000430"; upcs = ( ); }, { asins = ( ); "best_page" = { currency = usd; deeplink = "http://www.electronicexpress.com/catalog/23904/logitech"; description = "<null>"; "image_url" = "http://shopping.getinvisiblehand.com/images/no_image_available.png"; "in_stock" = 1; "live_price_url" = "http://api.invisiblehand.co.uk/v1/pages/live_price?url=http%3a%2f%2fwww.electronicexpress.com%2fcatalog%2f23904%2flogitech"; "original_url" = "http://www.electronicexpress.com/catalog/23904/logitech"; pnp = 0; cost = "<null>"; "price_confidence" = low; part = us; "retailer_name" = "electronicexpress.com"; title = "logitech m235 wireless mouse lite silver 910002332"; }; brands = ( logitech ); categories = ( ); eans = ( ); id = 58fc508d545168dccf81f93bb6070ac3; "image_url" = "http://shopping.getinvisiblehand.com/images/no_image_available.png"; isbns = ( ); models = ( ); mpns = ( ); "number_of_pages" = 1; resource = "/products/58fc508d545168dccf81f93bb6070ac3"; title = "logitech m235 wireless mouse lite silver 910002332"; upcs = ( ); }, { asins = ( ); "best_page" = { currency = usd; deeplink = "http://www.electronicexpress.com/catalog/23916/logitech"; description = "<null>"; "image_url" = "http://shopping.getinvisiblehand.com/images/no_image_available.png"; "in_stock" = 1; "live_price_url" = "http://api.invisiblehand.co.uk/v1/pages/live_price?url=http%3a%2f%2fwww.electronicexpress.com%2fcatalog%2f23916%2flogitech"; "original_url" = "http://www.electronicexpress.com/catalog/23916/logitech"; pnp = 0; cost = "<null>"; "price_confidence" = low; part = us; "retailer_name" = "electronicexpress.com"; title = "logitech wireless combo mk520 keyboard , laser mouse 920002553"; }; brands = ( logitech ); categories = ( ); eans = ( ); id = ae530f45af7ac34207bd9a44406afa98; "image_url" = "http://shopping.getinvisiblehand.com/images/no_image_available.png"; isbns = ( ); models = ( ); mpns = ( ); "number_of_pages" = 1; resource = "/products/ae530f45af7ac34207bd9a44406afa98"; title = "logitech wireless combo mk520 keyboard , laser mouse 920002553"; upcs = ( ); }, { asins = ( ); "best_page" = { currency = usd; deeplink = "http://www.electronicexpress.com/catalog/16215/logitech"; description = "<null>"; "image_url" = "http://shopping.getinvisiblehand.com/images/no_image_available.png"; "in_stock" = 1; "live_price_url" = "http://api.invisiblehand.co.uk/v1/pages/live_price?url=http%3a%2f%2fwww.electronicexpress.com%2fcatalog%2f16215%2flogitech"; "original_url" = "http://www.electronicexpress.com/catalog/16215/logitech"; pnp = 0; cost = "<null>"; "price_confidence" = low; part = us; "retailer_name" = "electronicexpress.com"; title = "logitech ls21 2.1 stereo speaker scheme 980000058"; }; brands = ( logitech ); categories = ( ); eans = ( ); id = ad59cd583a1b88c782f8af77e6d71494; "image_url" = "http://shopping.getinvisiblehand.com/images/no_image_available.png"; isbns = ( ); models = ( ); mpns = ( ); "number_of_pages" = 1; resource = "/products/ad59cd583a1b88c782f8af77e6d71494"; title = "logitech ls21 2.1 stereo speaker scheme 980000058"; upcs = ( ); }, { asins = ( ); "best_page" = { currency = usd; deeplink = "http://www.electronicexpress.com/catalog/16216/logitech"; description = "<null>"; "image_url" = "http://shopping.getinvisiblehand.com/images/no_image_available.png"; "in_stock" = 1; "live_price_url" = "http://api.invisiblehand.co.uk/v1/pages/live_price?url=http%3a%2f%2fwww.electronicexpress.com%2fcatalog%2f16216%2flogitech"; "original_url" = "http://www.electronicexpress.com/catalog/16216/logitech"; pnp = 0; cost = "<null>"; "price_confidence" = low; part = us; "retailer_name" = "electronicexpress.com"; title = "logitech compact 25watt 2.1 speaker scheme 980000382"; }; brands = ( logitech ); categories = ( ); eans = ( ); id = 54c5479754c659a2fac08018a4bce795; "image_url" = "http://shopping.getinvisiblehand.com/images/no_image_available.png"; isbns = ( ); models = ( ); mpns = ( ); "number_of_pages" = 1; resource = "/products/54c5479754c659a2fac08018a4bce795"; title = "logitech compact 25watt 2.1 speaker scheme 980000382"; upcs = ( ); }, { asins = ( ); "best_page" = { currency = usd; deeplink = "http://www.electronicexpress.com/catalog/22841/logitech"; description = "<null>"; "image_url" = "http://shopping.getinvisiblehand.com/images/no_image_available.png"; "in_stock" = 1; "live_price_url" = "http://api.invisiblehand.co.uk/v1/pages/live_price?url=http%3a%2f%2fwww.electronicexpress.com%2fcatalog%2f22841%2flogitech"; "original_url" = "http://www.electronicexpress.com/catalog/22841/logitech"; pnp = 0; cost = "<null>"; "price_confidence" = low; part = us; "retailer_name" = "electronicexpress.com"; title = "logitech z130 compact laptop speakers 980000417"; }; brands = ( logitech ); categories = ( ); eans = ( ); id = 7218f2482c0b4f40cf89d57feabb8c58; "image_url" = "http://shopping.getinvisiblehand.com/images/no_image_available.png"; isbns = ( ); models = ( ); mpns = ( ); "number_of_pages" = 1; resource = "/products/7218f2482c0b4f40cf89d57feabb8c58"; title = "logitech z130 compact laptop speakers 980000417"; upcs = ( ); }, { asins = ( ); "best_page" = { currency = usd; deeplink = "http://www.newegg.com/product/product.aspx?item=n82e16826104828"; description = "<null>"; "image_url" = "http://shopping.getinvisiblehand.com/images/no_image_available.png"; "in_stock" = 1; "live_price_url" = "http://api.invisiblehand.co.uk/v1/pages/live_price?url=http%3a%2f%2fwww.newegg.com%2fproduct%2fproduct.aspx%3fitem%3dn82e16826104828"; "original_url" = "http://www.newegg.com/product/product.aspx?item=n82e16826104828"; pnp = 0; cost = "<null>"; "price_confidence" = low; part = us; "retailer_name" = "newegg.com"; title = "logitech corded mouse m318e"; }; brands = ( logitech ); categories = ( ); eans = ( ); id = b5ccd2875b684f2209b2972ad85ab529; "image_url" = "http://shopping.getinvisiblehand.com/images/no_image_available.png"; isbns = ( ); models = ( ); mpns = ( ); "number_of_pages" = 1; resource = "/products/b5ccd2875b684f2209b2972ad85ab529"; title = "logitech corded mouse m318e"; upcs = ( ); }, { asins = ( ); brands = ( ); categories = ( ); eans = ( ); id = 65e25398341ecdca6c54787cf1f3e5d6; isbns = ( ); models = ( ); mpns = ( ); "number_of_pages" = 0; resource = "/products/65e25398341ecdca6c54787cf1f3e5d6"; title = "<null>"; upcs = ( ); } );

}

it looks info source isn't think is. root object appears dictionary, containing results array 1 of keys. seek instead.

nsdictionary *datadictionary = [nsjsonserialization jsonobjectwithdata:data options:kniloptions error:nil]; nsarray *itemcallarray = [nsarray arraywitharray:datadictionary[@"results"]];

ios objective-c xcode web-services

sql - Update new column with result set from stored procedure -



sql - Update new column with result set from stored procedure -

i have table existing data. have requirement add together new column table populated value retrieved using stored procedure. fine new info adding table.

how can run stored procedure each existing row, passing in parameters 2 existing columns, , updating new column result. want run following:

update tablewithnewcolumn set newcolumn = exec newprocedure(tablewithnewcolumn.id, tablewithnewcolumn.code);

see fiddle here: http://www.sqlfiddle.com/#!3/b0625/1

i know scalar function ideal task unfortunately sp has been provided 3rd party , it's way can provide data.

below cursor example, assuming id column unique. if can alter stored proc homecoming output parameter, utilize output parameter in update statement straight instead of inserting proc result set table variable , subquery in update.

declare @id int, @code varchar(16); declare @result table ( resultvalue varchar(16) ); declare tablerows cursor local select id ,code dbo.tablewithnewcolumn; open tablerows; while 1 = 1 begin fetch next tablerows @id, @code; if @@fetch_status = -1 break; delete @result; insert @result exec dbo.newprocedure @id, @code; update tablewithnewcolumn set newcolumn = (select resultvalue @result) id = @id; end; close tablerows; deallocate tablerows;

sql sql-server

php - Full Outer Join with multiple tables in mysql -



php - Full Outer Join with multiple tables in mysql -

i stuck in 1 query.. want show products of client sms received scheme in 1 grid/row. can accomplish thing display client products need 3 4 other tables bring together , show info product model, client name etc. other things comes other tables.. need 2 table outer join, , show info 4 5 tables. have tried failed.

select tcp.* , concat(tc.firstname,' ',tc.lastname) cust_id , tc.mobile , tb.brand_name brand , tgt.gadget_type gadget_type , tm.model_name model , ttt.ticket_type ticket_type , trs.registration_source registration_source tbl_cust_products tcp left bring together `tbl_received_sms` trsm on tcp.id = trsm.cust_prod_id left bring together tbl_customer tc on tcp.cust_id=tc.id left bring together tbl_brand tb on tcp.brand = tb.id left bring together tbl_gadget_type tgt on tcp.gadget_type=tgt.id left bring together tbl_model tm on tcp.model = tm.id left bring together tbl_ticket_type ttt on tcp.ticket_type=ttt.id left bring together tbl_registration_source trs on trs.id=tcp.registration_source tcp.del_date null union select tcp.* , concat(tc.firstname,' ',tc.lastname) cust_id , tc.mobile , tb.brand_name brand , tgt.gadget_type gadget_type , tm.model_name model , ttt.ticket_type ticket_type , trs.registration_source registration_source tbl_cust_products tcp right bring together `tbl_received_sms` trsm on tcp.id=trsm.cust_prod_id left bring together tbl_customer tc on tcp.cust_id=tc.id left bring together tbl_brand tb on tcp.brand=tb.id left bring together tbl_gadget_type tgt on tcp.gadget_type=tgt.id left bring together tbl_model tm on tcp.model = tm.id left bring together tbl_ticket_type ttt on tcp.ticket_type=ttt.id left bring together tbl_registration_source trs on trs.id=tcp.registration_source tcp.del_date null

in above want outer bring together on tbl_cust_products , tbl_received_sms tables. have tried union outer join here. searched , find out mysql not back upwards direct outer join other big database handlers.

if making error utilize union or logic plz help me accomplish this..

edited problem: in tbl_received_sms has 7,734 records , in tbl_cust_products has 3 records.. need total 7737 records in result. if utilize union 3 records, if utilize union all 7737 records fields of records null.

the problem queries returns columns tables tcp (tbl_cust_products), tc (tbl_customer), tb (tbl_brand), tgt (tbl_gadget_type), tm (tbl_model), ttt (tbl_ticket_type) , trs (tbl_registration_source).

all these columns rely on record existing on tcp (tbl_cust_products) table, either come table or tables left outer joined record on table.

any row has matching record on tcp (tbl_cust_products) returned first query. 2nd query homecoming of these has matching record on trsm (tbl_received_sms). returned both have 1 occurrence eliminated union.

the farther issue row returned 2nd query there no matching record on tcp (tbl_cust_products) have null in fields part of query returns (as fields depend on match on tcp (tbl_cust_products)). union eliminate 1 of rows, eliminates duplicates , rows identical (ie, nulls).

if want output add together column trsm (tbl_received_sms) columns returned. trsm.cust_prod_id 1 try.

edit bit more details explain unions.

take illustration heavily simplified version of query:-

select tcp.id, tc.name tbl_cust_products tcp left bring together tbl_received_sms trsm on tcp.id = trsm.cust_prod_id left bring together tbl_customer tc on tcp.cust_id=tc.id union select tcp.id, concat(tc.firstname,' ',tc.lastname) cust_id tbl_cust_products tcp right bring together tbl_received_sms trsm on tcp.id = trsm.cust_prod_id left bring together tbl_customer tc on tcp.cust_id=tc.id

say tables contain following

tbl_cust_products id name cust_id 1 5 2 b 6 tbl_received_sms id cust_prod_id info 3 2 c 4 3 d 5 4 e tbl_customer id name 5 fred 6 burt

the first query homecoming both records tbl_cust_products, 1 of matched against tbl_received_sms:-

id name 1 fred 2 burt

the 2nd query find 3 records tbl_received_sms, 1 of matched against tbl_cust_products. records unmatched have null in both returned fields (as there no matching record on tbl_cust_products value of field there null, , same value of field tbl_customer match non existant record tbl_cust_products). record matches populated:-

id name null null null null 2 burt

the union merge these 2 lots together,

id name 1 fred 2 burt null null null null 2 burt

but eliminating duplicates, hence:-

id name 1 fred 2 burt null null

php mysql sql join full-outer-join

numpy - Python indexing issue (converting MATLAB code) -



numpy - Python indexing issue (converting MATLAB code) -

i'm trying convert piece of matlab code python , running problem.

t = linspace(0,1,256); s = sin(2*pi*(2*t+5*t.^2)); h = conj(s(length(s):-1:1));

the above line h meant calculate impulse response, python code:

import numpy np t = np.linspace(0,1,256) s = np.sin(2*np.pi*(2*t+5*t**2)) h = np.conj(s[len(s),-1,1])

gives me error indexerror: index 256 out of bounds axis 0 size 256. know has indexing s array, how can prepare it?

remember python zero-indexed, while matlab 1-indexed. note matlab piece notation includes endpoint, whereas python piece notation excludes endpoint.

s(length(s):-1:1) mutual matlab idiom reversing vector. python has nicer syntax: s[::-1]. direct translation s[len(s)-1:-1:-1].

also note matlab start:step:stop corresponds python start:stop:step; position of step argument different.

python numpy

python - Constructing 3D Pandas DataFrame -



python - Constructing 3D Pandas DataFrame -

i'm having difficulty constructing 3d dataframe in pandas. want this

a b c start end start end start end ... 7 20 42 52 90 101 11 21 213 34 56 74 9 45 45 12

where a, b, etc top-level descriptors , start , end subdescriptors. numbers follow in pairs , there aren't same number of pairs a, b etc. observe a has 4 such pairs, b has 1, , c has 3.

i'm not sure how proceed in constructing dataframe. modifying this illustration didn't give me designed output:

import numpy np import pandas pd = np.array(['one', 'one', 'two', 'two', 'three', 'three']) b = np.array(['start', 'end']*3) c = [np.random.randint(10, 99, 6)]*6 df = pd.dataframe(zip(a, b, c), columns=['a', 'b', 'c']) df.set_index(['a', 'b'], inplace=true) df

yielded:

c b 1 start [22, 19, 16, 20, 63, 54] end [22, 19, 16, 20, 63, 54] 2 start [22, 19, 16, 20, 63, 54] end [22, 19, 16, 20, 63, 54] 3 start [22, 19, 16, 20, 63, 54] end [22, 19, 16, 20, 63, 54]

is there way of breaking lists in c own columns?

edit: construction of c important. looks following:

c = [[7,11,56,45], [20,21,74,12], [42], [52], [90,213,9], [101, 34, 45]]

and desired output 1 @ top. represents starting , ending points of subsequences within sequence (a, b. c different sequences). depending on sequence itself, there differing number of subsequences satisfy given status i'm looking for. result, there differing number of start:end pairs a, b, etc

first, think need fill c represent missing values

in [341]: max_len = max(len(sublist) sublist in c) in [344]: sublist in c: ...: sublist.extend([np.nan] * (max_len - len(sublist))) in [345]: c out[345]: [[7, 11, 56, 45], [20, 21, 74, 12], [42, nan, nan, nan], [52, nan, nan, nan], [90, 213, 9, nan], [101, 34, 45, nan]]

then, convert numpy array, transpose, , pass dataframe constructor along columns.

in [288]: c = np.array(c) in [289]: df = pd.dataframe(data=c.t, columns=pd.multiindex.from_tuples(zip(a,b))) in [349]: df out[349]: 1 2 3 start end start end start end 0 7 20 42 52 90 101 1 11 21 nan nan 213 34 2 56 74 nan nan 9 45 3 45 12 nan nan nan nan

python pandas

javascript - Can I declare a non-global variable to store asynchronous values? -



javascript - Can I declare a non-global variable to store asynchronous values? -

i have multiple javascript files. have js function runs upon load contains multiple ajax calls. each ajax phone call performs callback (as increments synchronous counter):: myarray.push('somevalue');

so can verify when ajax calls (for js file) have finished.

is there way can away not declaring myarray global variable, while allowing asynchronous callbacks force array?

if want execute code after set number of ajax requests have completed, utilize $.when.

if using myarray solely know when requests finished, can remove it. if using store result of each request, can maintain in same scope requests , access in done handler. seek this:

var myarray = []; var ajax1 = $.ajax({ url: '/foo/', success: function(data) { myarray.push(data); }); }); var ajax2 = $.ajax({ url: '/bar/', success: function(data) { myarray.push(data); }); }); $.when(ajax1, ajax2).done(function() { // both requests finish // myarray contain info of both requests @ point... (var = 0; < myarray.length; i++) { console.log(myarray[i]); } });

javascript jquery ajax scope

javascript - How to add boolean attributes to directive? -



javascript - How to add boolean attributes to directive? -

in html, there attributes selected attribute:

<option selected>this alternative selected</option>

it's either nowadays or not present, translates on/off (boolean).

i can't find way create attribute angularjs directive. there way?

an illustration be:

<modal ng-show="modal.show" with-backdrop> // "with-backdrop" boolean attribute.

it's going different depending on you're doing. in example, want know alternative selected. found checking model <select> see what's in it. example:

<select data-ng-model="user.defaultthing" data-ng-options="thing.id thing.name thing in thingcollection"> <option value="">none</option> </select>

with setup, time selection changed, thing.id stored in user.defaultthing.

nb: 'none' alternative have there, allows null selection.

now, if looking see if checkbox checked, it's similar you'd see what's in model it's tied to.

<input type="checkbox" data-ng-model="form.someoption">

when go process form, see if form.someoption true or false.

javascript angularjs attributes angularjs-directive

ios - NSPredicate error in ios6 -



ios - NSPredicate error in ios6 -

i'm experiencing error nspredicates in ios 6.1 (simulator)

i have next predicate:

nspredicate *eventswithinperiodepredicate = [nspredicate predicatewithformat:@"(startdate >= %@) , (enddate <= %@)", startdate, enddate];

if have array 2 objects next dates:

startdate = "2014-06-23t12:00:00.00000+0200"; enddate = "9999-12-31t23:59:59.00999+0100"; startdate = "2014-06-17t09:00:00.00000+0200"; enddate = "2014-06-17t11:00:00.00000+0200";

in ios 7 (simulator , device) , ios 5 (device) sec event if send 2014-06-17t00:00:00.00000 , 2014-06-17t23:59:00.00000

in ios 6.1 running in simulator both events.

i don't have ios6 specific code involved here. bug? don't have ios 6 device unable sure whether impact devices.

seems ran this problem dateformatter.

i made workaround ios 6. haven't tested if bug in ios 6 versions, took of them account.

if(system_version_greater_than_or_equal_to(@"6.0") && system_version_less_than(@"7.0")) { if([todatetimestring hasprefix:@"9999"]) { enddate = [nsdate distantfuture]; } }

ios objective-c nspredicate ios6.1

python - Stitch images together from html -



python - Stitch images together from html -

this website has big image combrised of 132 images, want find way stitch them single image. know python if has clue start.

http://www.mapytatr.net/produkty/mapy_tat/wysokie/slices/wys_ii.htm

thanks! matt

forget python - utilize imagemagic (http://www.imagemagick.org/)

+append create row

convert tpn_1.jpg tpn_2.jpg tpn_3.jpg +append row_1.jpg

-append create column

convert row_1.jpg row_2.jpg row_3.jpg -append final.jpg

you can seek montage (from imagemagic too) in 1 command

montage -mode concatenate -tile 3x3 tpn_* final.jpg

btw: on linux can download images using wget , for in bash

for in $(seq 132); echo "http://www.mapytatr.net/produkty/mapy_tat/wysokie/slices/tpn_$i.jpg"; done | wget -i -

kochane tatry :)

python image image-processing image-stitching

jquery - Align the left of Kendo UI bar charts -



jquery - Align the left of Kendo UI bar charts -

i have bar chart above. creating 3 charts json file.

i need align left of charts in same line

function showresults() { $.ajax({ type: "get", url: "/ajax/xyz.aspx?requesttype=xxxx&y=2", async: false, success: function (data) { if (json.parse(data).length > 0) { var chartdata = json.parse(data); createeatingchart(chartdata); createexercisechart(chartdata); createcopingchart(chartdata); } } }); } function createeatingchart(_chartdata) { var result = $.grep(_chartdata, function (e) { homecoming e.pattern_type == 'eating'; }); var lowresult = $.grep(result, function (e) { homecoming e.score <= 50; }); var highresult = $.grep(result, function (e) { homecoming e.score > 50; }); $("#diveating").kendochart({ seriescolors: ["green", "red"], chartarea: { background: "" }, title: { text: "eating", font: "18px arial,helvetica,sans-serif bold", color: 'black' }, legend: { visible: false, }, chartarea: { background: "" }, seriesdefaults: { type: "bar", stack: true, overlay: { gradient: "none" } }, series: [{ name: 'lowresult', data: lowresult, field: "score", categoryfield: "patternname" }, { name: 'highresult', data: highresult, field: "score", categoryfield: "patternname" }], valueaxis: { majorgridlines: { visible: true }, labels: { visible: false, } }, tooltip: { visible: true } }); }

is possible pad labels on the left side empty string have same width

it hard css, since created svg. trick can find out add together &nbsp; each chart has same category length.

http://jsfiddle.net/bochzchan/h4wy9/

categoryaxis: { categories: ["&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;jan", "feb", "mar", "apr", "may", "jun"], majorgridlines: { visible: false } },

jquery kendo-ui

jquery - Pass the route path and fence path dynamically for tracking an abject in Here API(GEO FENCING) -



jquery - Pass the route path and fence path dynamically for tracking an abject in Here API(GEO FENCING) -

i using here javascript api explorer tracking moving map object used geo fencing. want pass route path , fence path dynamically hardcoded in code far.

i have tried javascript array.push method i.e. pass value of both dynamically.but helps me append array path both route , fence not loading page loads 1 time , @ time arrays both empty.

var routearr = [52.53805, 13.4205, 52.53765, 13.42156, 52.53811, 13.42188, 52.53862, 13.42232, 52.53929, 13.42283, 52.53921, 13.42333]; var routearr2 = [52.53805, 13.4209, 52.53765, 13.42156, 52.53811, 13.42188, 52.53862, 13.42232, 52.53929, 13.42284, 52.53921, 13.42333]; var route = new nokia.maps.map.polyline( new nokia.maps.geo.strip( routearr, "values lat lng"), { color: "#7fff00", width: 2 } ), imagemarker = new nokia.maps.map.marker( route.path.get(0), { icon: "../../res/markertruck.png", $id: "marker", anchor: {x: 21, y: 41} } ), circle = new nokia.maps.map.polyline( new nokia.maps.geo.strip( routearr2, "values lat lng"), { color: "#000000", width: 2} ), scenecontainer = new nokia.maps.map.container([route, imagemarker, circle]); map.addlistener("displayready", function () { map.objects.add(scenecontainer); map.zoomto(scenecontainer.getboundingbox()); }) ;

i want pass above value of routearr , routearr2 dynamically. have provide route path , fence path before page loads or there way through can pass array both dynamically ?

the mapobject need @ minimum 1 coordinate point , 2 coordinates shape. can init objects routearr1 , routearr2 , alter afterwards routepolyline.set("path", strip); strip new strip.

jquery ajax arrays geofencing here-api

javascript - Adding and removing click/hover event handlers jQuery -



javascript - Adding and removing click/hover event handlers jQuery -

run issues mixing click , hover events.

clicking inactive li element toggles active class , binds hover event. hovering on active element displays hidden block (span.rate) clicking hovered element supposed hide it, remove hover event , toggle active class on parent no longer 'active'.

clicking hovered event not remove events , toggle active. there other logic in there regarding mutually exclusive options, works fine though.

jsfiddle of how sits together:

http://jsfiddle.net/65yy3/15/

current js:

ps = { pstoggle: 0, init: function () { $(document).ready(function () { $('.example li a)').on('click', function(e) { e.preventdefault(); var = $(this); if (that.parent().hasclass('paired')) { if (rm.pstoggle === 0) { that.toggleclass('active'); that.find('.rate').fadetoggle(50); rm.pstoggle = 1; } else { if (that.hasclass('active')) { that.toggleclass('active'); that.find('.rate').fadetoggle(50); rm.pstoggle = 0; } else { $('.paired a').toggleclass('active'); that.find('.rate').fadetoggle(50); //call message function } } rm.pcontrol(); } else { that.toggleclass('active'); that.find('.rate').fadetoggle(50); rm.pcontrol(); } }); }); }, pcontrol: function () { //unbind events command items excluding 1st item. $('.example li a').off('hover'); $('.example li .rate').off('click'); $('.example .active').each(function(i) { $(this).on('hover', function() { $(this).find('.rate').fadetoggle(50); }); }); $('.example li a.active .rate').on('click', function() { //remove hover/hide , toggle active state $(this).off('hover'); $(this).hide(); $(this).parent().toggleclass('active'); rm.pcontrol(); //rebind new active classes }); }

};

ps.init();

check below demos.

both click events getting fired ,.rate kid of a.

$('.example li a.active .rate').on('click'... ,

$('.example li a').on('click'...

so can either remove click on .rate. demo1

or add together e.stoppropagation(); kid stop event bubbling parent child. demo2

$('.example li a.active .rate').on('click', function(e) { e.stoppropagation(); //remove hover/hide , toggle active state $(this).off('hover'); $(this).hide(); $(this).parent().toggleclass('active'); ps.pcontrol(); //rebind new active classes });

javascript jquery html css event-handling

ruby on rails - create a link with parameters, but show param only if condition occurs -



ruby on rails - create a link with parameters, but show param only if condition occurs -

how can create link_to , have param in url if status occurs?

for example, want have someurl.com/1111?foo=clown

but foo should there if status true.

if not, should just: someurl.com/1111

<%= link_to 'my link', your_path(:foo => ("clown" if your_condition)) %>

in exemple, :param equals "clown" if your_condition true, else :param nil , if param nil, ruby don't consider there parameter , ignore it.

ruby-on-rails

Slim PHP Templates and passing parameters as strings within DOM attributes -



Slim PHP Templates and passing parameters as strings within DOM attributes -

i'm trying utilize addthis widget share content, want include test scores dynamic string when sharing twitter. using page partials templating.

<div addthis-toolbox class="addthis_toolbox addthis_default_style addthis_32x32_style social-width" style="width: 150 px" addthis:url="http://www.ourclient.com/quiz/score" addthis:title="i took iq quiz, got {{totalpoints}} points!" ></a>

however, totalpoints populating {{totalpoints}} instead of passing variable. ideas on how can convert string easily? i'm using slim php framework.

php dom parameters templating slim

php - Transform one class to another class -



php - Transform one class to another class -

i want scheme of class versioning allow 1 scheme talk scheme in way future changes wouldn't impact what's in place.

let's scheme , scheme b talk each other via rpc calls. business requirements alter , scheme , b need changed future development while beingness backward compatible

the next work:

class base_version { public static function getversion($version = 1) { $versionclass = 'version_'.$version; homecoming new $versionclass(); } } class version_1 { public function sayhello() { echo "hello version 1\n"; } } class version_2 { public function sayhello() { echo "hello version 2\n"; } } $obj = base_version::getversion(); $obj->sayhello(); $obj = base_version::getversion(2); $obj->sayhello();

i don't static instancing however. this, except know can't reassign $this.

class base_version { public function __construct($version) { $versionclass = 'version_'.$version; $this = new $versionclass(); } } $obj = new base_version(); $obj->sayhello(); $obj = new base_version(2); $obj->sayhello();

how can accomplish this?

i think abstract class defined constructor can close that.

let's remind abstract class need have @ to the lowest degree 1 abstract function, can have 'concrete'[sic]* functions same each inheriting class. abstract classes can't instanciated, children.

here is:

abstract class base_version {function __construct($version) {$this->version = $version; switch ($this->version) {case 1: // build class 1 break; case 2: // build class 2 etc. break; default: // careless programmers won't define constructor in future break;}} function version() {return $this->version;} abstract function sayhello();}

this base of operations abstract class. if business requirements change, can add together cases here new classes in constructor.

class greeter extends base_version {function sayhello() {return 'this old version' . $this->version(); }} class new_greeter extends base_version {function sayhello() {return 'hello version ' . $this->version(); }}

the point of abstract class here class not throw errors if extending abstract class, must implement function sayhello().

that way, whoever ever makes class extending base_version won't break programme because objects have @ to the lowest degree functions defined abstract in base of operations class.

so there iss, way define classes can alter in time without breaking way older ones work

$obj = new greeter(1); $obj ->sayhello(); $obj2 = new new_greeter(2); $obj2->sayhello(); 'concrete' in c++ has specific meaning, don't want offend using here if it's not same

php oop

java - Difficulty understanding scissorstack class in libgdx -



java - Difficulty understanding scissorstack class in libgdx -

the github page containing clipping (https://github.com/libgdx/libgdx/wiki/clipping%2c-with-the-use-of-scissorstack) short. can't seem head around using it. possible explain in more depth , detail (examples nice) on how utilize class?

i trying clip game along middle, , sepearte left , right side of screen. way if object spritebatch drawing go through middle, not render on other side.

thanks!

java libgdx

asp.net mvc - React.NET uncaught TypeError: undefined is not a function -



asp.net mvc - React.NET uncaught TypeError: undefined is not a function -

i trying larn reactjs , found react.net.

followed tutorial on author's website alter beingness mvc 5 app instead of mvc 4.

here jsx:

/** @jsx react.dom */ var commentbox = react.createclass({ render: function() { homecoming ( <div classname="commentbox"> <h1>comments</h1> <commentlist data={this.props.data} /> <commentform /> </div> ); } }); react.rendercomponent( <commentbox data={data} />, document.getelementbyid('content') ); var commentlist = react.createclass({ render: function() { var commentnodes = this.props.data.map(function (comment) { homecoming <comment author={comment.author}>{comment.text}</comment>; }); homecoming ( <div classname="commentlist"> {commentnodes} </div> ); } }); var commentform = react.createclass({ render: function() { homecoming ( <div classname="commentform"> hello, world! commentform. </div> ); } }); var info = [ { author: "daniel lo nigro", text: "hello reactjs.net world!" }, { author: "pete hunt", text: "this 1 comment" }, { author: "jordan walke", text: "this *another* comment" } ];

it gives error:

uncaught typeerror: undefined not function

any clues on one?

regards.

there 3 steps in snippet.

first, define commentbox:

var commentbox = react.createclass...

second, render commentbox , commentlist:

react.rendercomponent...

third, define commentlist:

var commentlist = react.createclass...

so, problem commentlist rendered before commentlist defined. if lastly 2 steps switched around work fine. commentlist class needs defined before can rendered.

asp.net-mvc reactjs