Tuesday, 15 June 2010

Gnuplot not plot on function domain -



Gnuplot not plot on function domain -

i have problem, believe bug on gnuplot.

i seek plot this

here code im using

set yrange [0:1] set xrange [0:10] pl sqrt(1-1/x)

but fit curve start around [1:0.1] , want create start @ [1:0] cant, know simple fit , cannot find can this. on gnuplot got problem, utilize chrome plot function plot ok, , after want manage plot function external data.

i glad if help me.

that's matter of sampling. utilize 101 sample points (or high sampling rate), includes 1 sampling point , you're fine:

set yrange [0:1] set xrange [0:10] set samples 101 pl sqrt(1-1/x)

result 4.6.5:

gnuplot

sql - Get Data From Database According Two dates -



sql - Get Data From Database According Two dates -

sql query:

select type, sum(a), sum(b) tablea store_date between '"+date1+"' , '"+date2+"'group type date1="16/06/2014" date2="18/06/2014"

by query getting sum of column , column b according dates. want info column b date1 date2 each type,but column want info date1, don't want include date2 in sum(a)

**example(expected result):** type sum(a) sum(b) ------------------------------- | fruit | 10 | 20 | | | | | | | | | | | | | | | | | -------------------------------

10 representing sum tablea column date 16/06/2014.

20 representing sum tablea column b date 16/06/2014 18/06/2014.

try this

select type, sum(case when date = date1 else 0 end) 'a', sum(case when date between date1 , date2 b else 0 end) 'b' table grouping type

sql

python - What turns following to __builtin__? -



python - What turns following to __builtin__? -

i have next snippet , output

with metaclass:

def some(*args): homecoming type(args) __metaclass__ = class foo: = 'khkjh' print foo.__module__

output: __builtin__

without metaclass:

class foo: = 'khkjh' print foo.__module__

output: __main__

so,

what __builtin__?

why or how metaclass affecting it?

__builtin__ module provides built-in functions, exceptions, etc.

you're getting returned __module__ because metaclass you're providing turning foo tuple type:

>>> def (*args): ... homecoming type(args) # returns <type 'tuple'> ... >>> class hmm(object): ... __metaclass__ = ... >>> class foo(object): ... pass ... >>> print hmm <type 'tuple'> >>> print foo <class '__main__.foo'> >>> print tuple <type 'tuple'> >>> print tuple.__module__ __builtin__

as can see hmm type tuple. tuple type provided __builtin__ module, hence output you're seeing.

python metaclass built-in

nfs - What are the implications of using NFS3 file system for multi-instance queue managers in WebSphere MQ -



nfs - What are the implications of using NFS3 file system for multi-instance queue managers in WebSphere MQ -

we stuck in hard scenario in our new mq infrastructure implementation using multi-instance queue managers using websphere mq v7.5 in linux platform. concern our network team not able configure nfs4 , hence still having nfs3 version. understand multi-instance queue managers not function nfs3. there issues if define queue managers in multi-instance fashion in nfs3 , expect work perfect single instance mode.

thanks

i not expect have issues running single-node queue managers nfs3, on regular basis. requirement nfs4 file locking mechanism required multi-instance queue managers determine when primary instance has lost command , secondary queue manager should take over.

if define queue manager multi-instance, , queue manager effort failover, may not successfully, @ worst may corrupt queue manager files.

if command failover - in, shutdown queue manager on 1 node , start 1 time again on node - should work you, there no file sharing taking place , files shutdown on primary node before beingness opened on secondary node. have create sure secondary queue manager not running in standby node -- ever.

i hope helps.

dave

websphere-mq nfs

vb.net - Free an image that is allocated in a form -



vb.net - Free an image that is allocated in a form -

i have load image , delete timer, not possible unless release image resource, code is:

pic=image.fromfile(directory.getcurrentdirectory+ "s.png")

this image replaced timer code, not able replace because showing image s.png. how can write s.png while showing , reload it? tell me method can free resource s.png other programs can modify it.

try reading image info memory , creating image that:

dim stream = new memorystream(file.readallbytes(directory.getcurrentdirectory() & "s.png")) dim pic = image.fromstream(stream)

you need maintain stream open lifetime of image, when image file replaced , re-reading it, phone call dispose on both stream , pic before recreating them.

vb.net

r - F# RProvider strange behavior in mgcv package -



r - F# RProvider strange behavior in mgcv package -

this works:

// helper evaluates r look allow evals (text:string) = r.eval(r.parse(namedparams ["text", text ])) allow evalv (text:string) = (text |> evals).value //run illustration page 8 of http://cran.r-project.org/web/packages/mgcv/mgcv.pdf evalv(""" library(mgcv) set.seed(0) dat <- gamsim(5,n=200,scale=2) """) allow am1 = evals("b<-gam(y ~ x0 + s(x1) + s(x2) + s(x3),data=dat)") allow gam_anova1 = evals("anova(b)") am1.value

the gam() output

family: gaussian link function: identity

formula: y ~ x0 + s(x1) + s(x2) + s(x3)

estimated degrees of freedom: 1.73 7.07 1.00 total = 13.8

gcv score: 4.578643

and anova() output is

family: gaussian link function: identity

formula: y ~ x0 + s(x1) + s(x2) + s(x3)

parametric terms: df f p-value x0 3 77.42 <2e-16

approximate significance of smooth terms: edf ref.df f p-value s(x1) 1.729 2.158 45.071 <2e-16 s(x2) 7.069 8.120 49.230 <2e-16 s(x3) 1.000 1.000 0.056 0.812

however, if seek phone call function using rprovider (an f# type provider) this:

open rprovider.mgcv r.set_seed(0) allow dat = r.gamsim(5,n=200,scale=2) allow b = r.gam(formula = "y~x0+s(x1)+s(x2)+s(x3)",data=dat) r.anova_gam(b)

the next error generated:

rdotnet.evaluationexception: error in terms.formula(gf, specials = c("s", "te", "ti", "t2")) : argument not valid model

this error happens on gam() line. found offending line in https://svn.r-project.org/r-packages/trunk/mgcv/r/mgcv.r, i'm not sure what's going wrong:

tf <- terms.formula(gf,specials=c("s","te","ti","t2")) # specials attribute indicates terms smooth

however, when combine elements of 2 this:

evalv(""" library(mgcv) """) open rprovider.mgcv r.set_seed(0) allow dat = r.gamsim(5,n=200,scale=2) allow b = r.gam(formula = evals("y~x0+s(x1)+s(x2)+s(x3)"),data=dat) //let b = r.gam(formula = "y~x0+s(x1)+s(x2)+s(x3)",data=dat) r.anova_gam(b)

it runs fine. note there 2 changes. first loading library, rprovider thought supposed you. sec using evals wrap formula. phone call r.lm without doing (i pass in string representing formula), i'm confused why doesn't work same way.

can explain this? bug or undocumented, correct, behavior? running in ifsharp btw (https://github.com/bayardrock/ifsharp)

i'm guessing (have not tried running code), think problem formula argument of gam function not string (which how phone call in sec case), symbolic expression.

r has quite fancy parameter passing mechanism function gets source code representation of y~x0+s(x1)+s(x2)+s(x3) can analysis based on look specify.

when pass through evals, you're calling r build symbolic expression, pass gam function - , gets expression rather string. happens in first snippet (where r engine parses whole string).

as having write library(mgcv), suspect doing imports of symbols used in symbolic look s(...).

r f# type-providers

"READ" constant in PLSQL -



"READ" constant in PLSQL -

i found next pl/sql code unable find valid constant declaration oracle documentation.

can explain me means?

create or replace bundle file_security authid current_user read constant pls_integer := 1; write constant pls_integer := 2; exec constant pls_integer := 4; procedure grant_permission( p_file_path in varchar2, p_grantee in varchar2, p_permission in pls_integer ); end file_security;

thanks.

the bundle declares 3 constants (called read, write , exec) , function, supposedly take binary mask of constants 3rd parameter.

none of words reserved in oracle, "have special meaning oracle not reserved words , can redefined"

plsql

ruby on rails - Jbuilder without the .json extension -



ruby on rails - Jbuilder without the .json extension -

doing http://localhost:3000/options/audio

and error:

missing template options/audio, application/audio {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee]}. searched in: * "/users/mmahalwy/desktop/code/quran.com/quranapi/app/views"

when http://localhost:3000/options/audio.json

that renders jbuilder file , desired json. how can render jbuilder template .json extension?

the jbuilder documentation tells create jbuilder template *.json.jbuilder file. makes route .json extension. if remove .json part , create file *.jbuilder able go route without .json extension.

example:

filename: index.jbuilder route: 'ticket', to: 'tickets#index'

ruby-on-rails jbuilder

java - Lines drawn randomly -



java - Lines drawn randomly -

i got weird bug. i'm doing video game in java lwjgl implement graphics. can find unusual : 95% of times, gui looks must , 5% remaining of lines not drawn. checked if part of code must draw line read , is. can't figure out happens. ave thought how prepare ?

thank !!

edit : figure out didn't explain ou anything... create easier, tried implement gui element of awt bundle in lwjgl. untill now, have implemented label, progressbar, window , mainpanel (to draw background of gui).

as can see below, progressbar , label set within window manage everything, namely position , size of element within it. so, when draw window, draw within @ same time : in case, progressbar , label. label, time displayed progressbar not. because i'm sure bug must come drawing method of progressbar, had @ end of post.

this code of class draw on screen : public class connectiondrawer implements interfacedrawer {

private boolean needupdate = true; private blockingqueue<string> in; private progressbar bar; private mainpanel background; private window load_window; private label text; public connectiondrawer() { in = new linkedblockingqueue<string>(); bar = new progressbar(); bar.setbordercolor(1.0f, 1.0f, 1.0f, 1.0f); bar.setbarcolor(1.0f, 0f, 0f, 1.0f); bar.setmaxvalue(3); bar.setpadding(1); bar.setcurrentvalue(0); elementproperties prop_bar = new elementproperties( elementproperties.absolute, elementproperties.absolute); prop_bar.setabsolutesize(280, 30); prop_bar.setabsoluteposition(10, 40); text = new label("trying connect server..."); text.setborder(false); text.setsize(label.medium); text.setcolor(color.white); text.setverticalalign(label.top); text.sethorizontalalign(label.left); elementproperties prop_bar1 = new elementproperties( elementproperties.absolute, elementproperties.absolute); prop_bar1.setabsolutesize(280, 30); prop_bar1.setabsoluteposition(10, 5); background = new mainpanel(); background .setbackground(graphiccontroller.gettextureloader().cloudy_background); load_window = new window(); load_window.setbackgroundcolor(0f, 0f, 0f, 0.5f); load_window.enablebackground(true); load_window.enableborder(true); load_window.setbordercolor(0, 0, 0); load_window.addcomponent(bar, prop_bar); load_window.addcomponent(text, prop_bar1); } @override public void draw() { // todo auto-generated method stub graphiccontroller.getwindow().initgl2d(); gl11.glcolor3f(1.0f, 1.0f, 1.0f); if (needupdate) { load_window.setdimension(300, 80); load_window.setposition(data.getactifresolution().getwidth() - 310, data.getactifresolution().getheight() - 90); needupdate = false; } background.draw(); graphiccontroller.gettextureloader().white_text.bind(); load_window.draw(); } public void updateneeded() { this.needupdate = true; } @override public void checkkeyboard() { // todo auto-generated method stub if (display.iscloserequested()) graphiccontroller.getwindow().changedone(); } @override public void postmessage(object obj) { // todo auto-generated method stub in.add((string) obj); } }

and code of progressbar class not drawn every times :

public void draw() { system.out.println("progress draw"); //system.out.println(b_r+";"+b_g+";"+b_b+";"+b_a); gl11.glcolor4f(b_r, b_g, b_b, b_a); gl11.glbegin(gl11.gl_lines); { gl11.glvertex2f(x, y); gl11.glvertex2f(x + width, y); gl11.glvertex2f(x + width, y); gl11.glvertex2f(x + width, y + height); gl11.glvertex2f(x + width, y + height); gl11.glvertex2f(x, y + height); gl11.glvertex2f(x, y + height); gl11.glvertex2f(x, y); } gl11.glend(); float ratio; if (max == 0 || current == 0) { system.out.println("progress draw end"); return; } else if (max == 0) { ratio = 0; } else { ratio = ((float) current) / ((float) max); } gl11.glcolor4f(i_r, i_g, i_b, i_a); gl11.glbegin(gl11.gl_quads); { gl11.glvertex2f(x + pad_inside, y + pad_inside + 1); gl11.glvertex2f(x - 1 + ratio * width - pad_inside, y + pad_inside + 1); gl11.glvertex2f(x - 1 + ratio * width - pad_inside, y + height - pad_inside - 1); gl11.glvertex2f(x + pad_inside, y + height - pad_inside - 1); } gl11.glend(); }

so after multiple check, identify source of error. in fact, comes class displays text on screen. think need disable gl_texture_2d alternative after displaying text.

java user-interface lwjgl

c# - Extend Dictionary and create instance from other dictionary -



c# - Extend Dictionary and create instance from other dictionary -

i extending c# dictionary class:

class table<ta> : dictionary<int, ta> {}

but have dictionary, , want create table out of it. tried:

dictionary<int, int> mydico = ... // somewhere else table<int> mytable = new table{ mydico };

but complains with,

"table not contain constructor accepting argument."

i come java/scala background , because c# not have type aliases, way found utilize aliases.

just create constructor accepts dictionary, , pass base of operations constructor:

class table<ta> : dictionary<int, ta> { public table(idictionary<int, ta> dictionary) : base(dictionary) { } }

use this:

dictionary<int, int> mydico = ... // somewhere else table<int> mytable = new table(mydico);

c# dictionary

trying to create a cron on ubuntu server -



trying to create a cron on ubuntu server -

i've been trying create cron doesn't seem working. i'm running ubuntu 14.04. testing i've set cron run every minute.

btw, i'd created cron using, 'sudo crontab -e'. not sure if sudo needed, thought why not in case permissions might issue (by way, php script runs fine command line without sudo)

here's couple variations i've tried, don't work,

1 * * * * /usr/local/bin/php /var/www/html/test/index.php 1 * * * * /var/www/html/test/index.php

and, here's cron (the whole thing)...

# edit file introduce tasks run cron. # # each task run has defined through single line # indicating different fields when task run # , command run task # # define time can provide concrete values # min (m), hr (h), day of month (dom), month (mon), # , day of week (dow) or utilize '*' in these fields (for 'any').# # notice tasks started based on cron's scheme # daemon's notion of time , timezones. # # output of crontab jobs (including errors) sent through # email user crontab file belongs (unless redirected). # # example, can run backup of user accounts # @ 5 a.m every week with: # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/ # # more info see manual pages of crontab(5) , cron(8) # # m h dom mon dow command 1 * * * * /var/www/html/test/index.php ~ ~

if have not already, seek starting cron service command /etc/init.d/crond start. hope helps, allow know if doesn't.

ubuntu

amazon web services - NoHttpResponseException on uploading file to S3 (camel-aws) -



amazon web services - NoHttpResponseException on uploading file to S3 (camel-aws) -

i trying upload around 10 gb file local machine s3 (inside camel route). although file gets uploaded in around 3-4 minutes, throwing next exception:

2014-06-26 13:53:33,417 | info | ads.com/outbound | fetchroute | 167 - com.ut.ias - 2.0.3 | download finish local. pushing file s3 2014-06-26 13:54:19,465 | info | manager-worker-6 | amazonhttpclient | 144 - org.apache.servicemix.bundles.aws-java-sdk - 1.5.1.1 | unable execute http request: target server failed respond org.apache.http.nohttpresponseexception: target server failed respond @ org.apache.http.impl.conn.defaulthttpresponseparser.parsehead(defaulthttpresponseparser.java:95)[142:org.apache.httpcomponents.httpclient:4.2.5] @ org.apache.http.impl.conn.defaulthttpresponseparser.parsehead(defaulthttpresponseparser.java:62)[142:org.apache.httpcomponents.httpclient:4.2.5] @ org.apache.http.impl.io.abstractmessageparser.parse(abstractmessageparser.java:254)[141:org.apache.httpcomponents.httpcore:4.2.4] @ org.apache.http.impl.abstracthttpclientconnection.receiveresponseheader(abstracthttpclientconnection.java:289)[141:org.apache.httpcomponents.httpcore:4.2.4] @ org.apache.http.impl.conn.defaultclientconnection.receiveresponseheader(defaultclientconnection.java:252)[142:org.apache.httpcomponents.httpclient:4.2.5] @ org.apache.http.impl.conn.managedclientconnectionimpl.receiveresponseheader(managedclientconnectionimpl.java:191)[142:org.apache.httpcomponents.httpclient:4.2.5] @ org.apache.http.protocol.httprequestexecutor.doreceiveresponse(httprequestexecutor.java:300)[141:org.apache.httpcomponents.httpcore:4.2.4] ....... @ java.util.concurrent.futuretask.run(futuretask.java:262)[:1.7.0_55] @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1145)[:1.7.0_55] @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:615)[:1.7.0_55] @ java.lang.thread.run(thread.java:744)[:1.7.0_55] 2014-06-26 13:55:08,991 | info | ads.com/outbound | fetchroute | 167 - com.ut.ias - 2.0.3 | upload complete.

due camel route doesn't stop , continuously throwing interruptedexception:

2014-06-26 13:55:11,182 | info | ads.com/outbound | sftpoperations | 110 - org.apache.camel.camel-ftp - 2.12.1 | jsch -> disconnecting cxportal.integralads.com port 22 2014-06-26 13:55:11,183 | info | lads.com session | sftpoperations | 110 - org.apache.camel.camel-ftp - 2.12.1 | jsch -> caught exception, leaving main loop due socket closed 2014-06-26 13:55:11,183 | warn | lads.com session | eventadmin | 139 - org.apache.felix.eventadmin - 1.3.2 | eventadmin: exception: java.lang.interruptedexception java.lang.interruptedexception @ edu.oswego.cs.dl.util.concurrent.linkedqueue.offer(unknown source)[139:org.apache.felix.eventadmin:1.3.2] @ edu.oswego.cs.dl.util.concurrent.pooledexecutor.execute(unknown source)[139:org.apache.felix.eventadmin:1.3.2] @ org.apache.felix.eventadmin.impl.tasks.defaultthreadpool.executetask(defaultthreadpool.java:101)[139:org.apache.felix.eventadmin:1.3.2] @ org.apache.felix.eventadmin.impl.tasks.asyncdelivertasks.execute(asyncdelivertasks.java:105)[139:org.apache.felix.eventadmin:1.3.2] @ org.apache.felix.eventadmin.impl.handler.eventadminimpl.postevent(eventadminimpl.java:100)[139:org.apache.felix.eventadmin:1.3.2] @ org.apache.felix.eventadmin.impl.adapter.logeventadapter$1.logged(logeventadapter.java:281)[139:org.apache.felix.eventadmin:1.3.2] @ org.ops4j.pax.logging.service.internal.logreaderserviceimpl.fire(logreaderserviceimpl.java:134)[50:org.ops4j.pax.logging.pax-logging-service:1.7.1] @ org.ops4j.pax.logging.service.internal.logreaderserviceimpl.fireevent(logreaderserviceimpl.java:126)[50:org.ops4j.pax.logging.pax-logging-service:1.7.1] @ org.ops4j.pax.logging.service.internal.paxloggingserviceimpl.handleevents(paxloggingserviceimpl.java:180)[50:org.ops4j.pax.logging.pax-logging-service:1.7.1] @ org.ops4j.pax.logging.service.internal.paxloggerimpl.inform(paxloggerimpl.java:145)[50:org.ops4j.pax.logging.pax-logging-service:1.7.1] @ org.ops4j.pax.logging.internal.trackinglogger.inform(trackinglogger.java:86)[18:org.ops4j.pax.logging.pax-logging-api:1.7.1] @ org.ops4j.pax.logging.slf4j.slf4jlogger.info(slf4jlogger.java:476)[18:org.ops4j.pax.logging.pax-logging-api:1.7.1] @ org.apache.camel.component.file.remote.sftpoperations$jschlogger.log(sftpoperations.java:359)[110:org.apache.camel.camel-ftp:2.12.1] @ com.jcraft.jsch.session.run(session.java:1621)[109:org.apache.servicemix.bundles.jsch:0.1.49.1] @ java.lang.thread.run(thread.java:744)[:1.7.0_55]

please see code below , allow me know, going wrong:

transfermanager tm = new transfermanager( s3client.gets3client()); // transfermanager processes transfers asynchronously, // phone call homecoming immediately. upload upload = tm.upload( utils.getproperty(constants.bucket), gets3key(file.getname()), file); seek { upload.waitforcompletion(); logger.info("upload complete."); } grab (amazonclientexception amazonclientexception) { logger.warn("unable upload file, upload aborted."); amazonclientexception.printstacktrace(); }

the stacktrace doesn't have reference code, hence couldn't determine issue is. help or pointer appreciated.

thanks

amazon-web-services amazon-s3 apache-camel

python - Django: How do I update previously created database entries? -



python - Django: How do I update previously created database entries? -

i've got bunch of created database entries of model class created, called equations. created new type of model, equationgroup, , want able link existing equations in database newly created equationgroups. how that?

update: forgot mention i've got foreignkey relationship in equation equationgroup. here short version of models.py

class equationgroup(models.model): name = models.charfield(max_length=50) def __str__(self): homecoming self.name class equation(models.model): name = models.charfield(max_length=50, null=false, blank=false) grouping = models.foreignkey(equationgroup)

you can create script goes through equations , attaches them equations groups. using equations.objects.all() can iterable of of equations objects. can go through in loop , assign each 1 specified equations group.

example:

for equation in using equations.objects.all(): equation.equationgroup = some_group #based on specify goes in group. equation.save()

python database django

Add product short-description on product review page in magento -



Add product short-description on product review page in magento -

i using

$_helper->productattribute($_product, nl2br($_product->getshortdescription()), 'short_description');

in catalog/product/view.phtml show product short description.

it showing in single product page not in product review page though enabling template path hints shows both come view.phtml

any suggestions?

there logical implementation avalibale on magento.

i have seen in class mage_review_block_product_view short description set null . have comment code .now working

so re-create app/code/core/mage/review/block/product/view.php app/code/local/mage/review/block/product/view.php , edit

protected function _tohtml() { $this->getproduct()->setshortdescription(null); homecoming parent::_tohtml(); }

to

protected function _tohtml() { //$this->getproduct()->setshortdescription(null); homecoming parent::_tohtml(); }

or enable short_description used in product list admin>catalog>manage attribute

magento magento-1.8

java - adding row to a table in PDF using iText -



java - adding row to a table in PDF using iText -

pdfptable table = new pdfptable(8); pdfpcell cell; cell = new pdfpcell(); cell.setrowspan(2); table.addcell(cell); for(int aw=0;aw<8;aw++){ table.addcell("hi"); }

what getting in code table 8 columns , 3 rows. should 2 2 rows. , 1st column in 3 rows empty, remaining cells filled hi..

try this:

pdfptable table = new pdfptable(8); pdfpcell cell; for(int aw=0;aw<8;aw++) { cell = new pdfpcell(new paragraph("hi")); table.addcell(cell ); }

edit:

// step 1 document document = new document(); // step 2 pdfwriter.getinstance(document, new fileoutputstream(filename)); // step 3 document.open(); // step 4 pdfptable table = new pdfptable(8); for(int aw=0;aw<16 ; aw++){ table.addcell("hi"); } // step 5 document.add(table); // step 6 document.close();

see simpletable total sample code , resulting pdf:

as can see in screen shot, table has 8 columns , 2 rows (as expected).

reading original question, see first column has cell colspan 2. it's little alter take account:

pdfptable table = new pdfptable(8); pdfpcell cell = new pdfpcell(new phrase("hi")); cell.setrowspan(2); table.addcell(cell); for(int aw = 0; aw < 14; aw++){ table.addcell("hi"); }

now result looks this:

again 8 columns , 2 rows, cell in first column spans 2 rows.

java itext

ios - having issue with scrolling image with gyroscope -



ios - having issue with scrolling image with gyroscope -

i have unusual problem ipad air !!! , code runs fine on ipad 3 , ipad 4 , iphone 5s , ipod 5th gen , on ipad air , image scrolls automatically without user rotate device , here code :

@property (strong, nonatomic) cmmotionmanager *motionmanager; self.mainscrollview.frame = cgrectmake(0, 0, self.view.frame.size.width, self.view.frame.size.height); self.mainscrollview.bounces = no; self.mainscrollview.userinteractionenabled = no; //set image view uiimage *image= [uiimage imagenamed:@"your_image_name"]; uiimageview *movingimageview = [[uiimageview alloc]initwithimage:image]; [self.mainscrollview addsubview:movingimageview]; self.mainscrollview.contentsize = cgsizemake(movingimageview.frame.size.width, self.mainscrollview.frame.size.height); self.mainscrollview.contentoffset = cgpointmake((self.mainscrollview.contentsize.width - self.view.frame.size.width) / 2, 0); //inital motionmanager , detec gyroscrope every 1/60 sec //the interval may not need fast self.motionmanager = [[cmmotionmanager alloc] init]; self.motionmanager.gyroupdateinterval = 1/60; //this how fast image should move when rotate device, larger number, less roation required. cgfloat motionmovingrate = 4; //get max , min offset x value int maxxoffset = self.mainscrollview.contentsize.width - self.mainscrollview.frame.size.width; int minxoffset = 0; [self.motionmanager startgyroupdatestoqueue:[nsoperationqueue currentqueue] withhandler:^(cmgyrodata *gyrodata, nserror *error) { if (fabs(gyrodata.rotationrate.y) >= 0.1) { cgfloat targetx = self.mainscrollview.contentoffset.x - gyrodata.rotationrate.y * motionmovingrate; if(targetx > maxxoffset) targetx = maxxoffset; else if (targetx < minxoffset) targetx = minxoffset; self.mainscrollview.contentoffset = cgpointmake(targetx, 0); } }];

it's kind of animation !!! code works fine on other devices ! help ?thanks

could seek following: adds error handling code, error may returning gyroscope, , may homecoming value >0.09; utilize nslog more when testing pick apart code , see values returning.

@property (strong, nonatomic) cmmotionmanager *motionmanager; self.mainscrollview.frame = cgrectmake(0, 0, self.view.frame.size.width, self.view.frame.size.height); self.mainscrollview.bounces = no; self.mainscrollview.userinteractionenabled = no; //set image view uiimage *image= [uiimage imagenamed:@"your_image_name"]; uiimageview *movingimageview = [[uiimageview alloc]initwithimage:image]; [self.mainscrollview addsubview:movingimageview]; self.mainscrollview.contentsize = cgsizemake(movingimageview.frame.size.width, self.mainscrollview.frame.size.height); self.mainscrollview.contentoffset = cgpointmake((self.mainscrollview.contentsize.width - self.view.frame.size.width) / 2, 0); //inital motionmanager , detec gyroscrope every 1/60 sec //the interval may not need fast self.motionmanager = [[cmmotionmanager alloc] init]; self.motionmanager.gyroupdateinterval = 1/60; //this how fast image should move when rotate device, larger number, less roation required. cgfloat motionmovingrate = 4; //get max , min offset x value int maxxoffset = self.mainscrollview.contentsize.width - self.mainscrollview.frame.size.width; int minxoffset = 0; [self.motionmanager startgyroupdatestoqueue:[nsoperationqueue currentqueue] withhandler:^(cmgyrodata *gyrodata, nserror *error) { // if no error --- if(!error){ nslog(@"no error gyroscope %f",gyrodata.rotationrate.y); if (fabs(gyrodata.rotationrate.y) >= 0.1) { nslog(@"moving image"); cgfloat targetx = self.mainscrollview.contentoffset.x - gyrodata.rotationrate.y * motionmovingrate; if(targetx > maxxoffset) targetx = maxxoffset; else if (targetx < minxoffset) targetx = minxoffset; self.mainscrollview.contentoffset = cgpointmake(targetx, 0); } } // error returned gyro else nslog(@"error recieved %@",error); }];

ios objective-c iphone ipad

scala - What's the difference between "Generic type" and "Higher-kinded type"? -



scala - What's the difference between "Generic type" and "Higher-kinded type"? -

i found myself can't understand difference between "generic type" , "higher-kinded type".

scala code:

trait box[t]

i defined trait name box, type constructor accepts parameter type t. (is sentence correct?)

can say:

box generic type box higher-kinded type none of above correct

when discuss code colleagues, struggle between word "generic" , "higher-kinde" express it.

scala generics type-systems higher-kinded-types

.net - WCF to MVC Web API for WebInvoke Attribute (BodyStyle = WrappedRequest) -



.net - WCF to MVC Web API for WebInvoke Attribute (BodyStyle = WrappedRequest) -

i'm trying recreate wcf web service mvc web api has next attribute on web method:

[webinvoke(method = "*", bodystyle = webmessagebodystyle.wrappedrequest)]

vb:

<webinvoke(method = "*", bodystyle = webmessagebodystyle.wrappedrequest)> _

what mvc web api way of creating wrapped request?

i have same issue , couldn't find solution, however, below work-around for.

creating wrappedresponse name/value structure.

public class wrappedresponse<t> { public list<t> samplecollection { get; set; } public static wrappedresponse<t> getresult(list<t> list) { var result = new wrappedresponse<t>(); result.samplecollection = list; homecoming result; } }

returning wrappedresponse instance.

[route("products")] public ihttpactionresult get() { configuration.formatters.clear(); configuration.formatters.add(new jsonmediatypeformatter()); using (var context = new adventureworks2012entities()) { list<product> productslist = context.products.take(10).tolist(); var result = wrappedresponse<product>.getresult(productslist); homecoming ok(result); } }

.net wcf asp.net-web-api

java - Selenium @FindBy find by one xpath or another -



java - Selenium @FindBy find by one xpath or another -

i'm trying find element on page using

@findby(xpath = "somexpath") webelement someelement;

the problem element's xpath different (because of failed login message displayed in same table). how can find element 1 xpath or another?

xpath == "somexpath1" || xpath == "somepath2"

i've tried doing repeating annotation, this:

@findby(xpath = "somexpath1") @findby(xpath = "somexpath2") webelement someelement

but won't compile. , i've tried using @findbys seems work && rather ||.

any help appreciated. thanks!

several paths can combined | separator, works logical or.

@findby(xpath = "somexpath1 | somexpath2")

java selenium

actionscript 3 - Where is that syntax error on line 2? -



actionscript 3 - Where is that syntax error on line 2? -

ok, in next actionscript 3.0 code there syntax error on line 2, don't know is. i'm beginner please help me on this?

var numbertocast:number;

on next line there syntax error, says compiler, , haven't clue is

for (numbertocast = –1; numbertocast<2; numbertocast++){ trace("boolean(" + numbertocast +") " + boolean(numbertocast)); }

the problem - (numbertocast = –1;), it's not minus symbol. symptom of copying , pasting (out of microsoft office maybe? word bad replacing minus dash)

and per comment, need define (var) numbertocast (either prior loop or in loop declaration) or you'll different error after fixing minus.

actionscript-3

regex - "Match a literal character", or "match a character literally"? -



regex - "Match a literal character", or "match a character literally"? -

i making regex using regex101 tool , read in explanation field

[.] - literal character .

[\.] - matches character . literally

i lost between "literal character" , "character literally". difference between these two?

there no difference. sorry, take back. difference words firas dib, author of regx101, chose explain various tokens.

a literal character or matching literally refers specifying actual character in text: instance, a match a, opposed character class such \w match a.

you can match literal period in either of these 3 ways:

\. [.] [\.]

which alternative better?

some people alternative 2 because makes clear matching period, not catch-all dot. stands out. myself, utilize \.. people using character class less optimal, on modern processors makes no difference. pick. option 3 on top , typically used when doesn't know periods don't need escaped within character class. in view it's confusing. did author mean? trying create character class match either backslash or period, , made typo? (that [\\.]

regex

java - how to concat 2 vrchar in jdbc/derby? -



java - how to concat 2 vrchar in jdbc/derby? -

i want run code in jdbc/derby got below error. how can handle in jdbc?

code:

select id,namee+ " " + family names students

errorr:

the '+' operator left operand type of 'varchar' , right operand type of 'varchar' not supported.

derby uses || operator concat strings (like oracle):

select id, namee || " " || family names students

java netbeans jdbc derby

sql server - An issue on the setting of [DatabaseGenerated(DatabaseGeneratedOption.Identity)] -



sql server - An issue on the setting of [DatabaseGenerated(DatabaseGeneratedOption.Identity)] -

i used ef 6 code-first approach in codes existing database(mssql server 2014), , set [databasegenerated(databasegeneratedoption.identity)] attribute id (int type) of entity. each time, invokes exception message main key(id of entity) can't null when insert operation executes.

i can't figure out what's what's problem databasegenerated attribute .

sql-server entity-framework

MySQL join with federated view not working -



MySQL join with federated view not working -

i want bring together table view, 1 table l local, whereas view f federated view residing on server:

select * l left bring together f on l.id = f.id;

now bring together results in no hits despite fact there many matches between table , view. id field bigint.

frustrated, created temporary table t , dumped f it, making local re-create of f. using t instead of f, bring together works expected. process of creating t consumes memory , time.

what possible reasons odd mysql behaviour?

table definitions:

create table `l` ( `id` bigint(20) not null, `id2` bigint(20) not null, primary key (`id`,`id2`) ) engine=innodb default charset=utf8;

and (this table in fact view on remote server):

create table `f` ( `id` bigint(20) not null auto_increment, `field1` bigint(20) not null, ... `field5` tinyint(1) default null, primary key (`id`) ) engine=federated default charset=latin1 connection='mysql://username:pword...';

as states definition of federated storage-engine is, must have table construction definition (so, illustration .frm files myisam) on both servers. because how federated engine works:

therefore, can not utilize view since has different meaning , structure. instead should mirror table , you'll able utilize in queries.

mysql join federated-table

matlab - LBP not working for texture matching -



matlab - LBP not working for texture matching -

after seeing few papers had used lbp texture recognition, implemented simple lpb , used bhattacharya distance score similarity. the score not enough, different textures. doing error in code ?or lbp not measure texture.

function lbp() clc; im=imread('bark1.jpg'); subplot(2,2,1);imshow(im); [r c]=size(im); h1=tex_lpb(im,r,c); subplot(2,2,2);plot(h1 ); im_2=imread('t_shirt.jpg'); im_2=rgb2gray(im_2); subplot(2,2,3);imshow(im_2); [r c]=size(im_2); h2=tex_lpb(im_2,r ,c ); subplot(2,2,4);plot(h2); weight=sum(sqrt(h1.*h2)) end function h= tex_lpb(im,r,c) im_lpb=zeros(r,c); i=2:r-1 j=2:c-1 a=[]; %checking 8 nieghbours %n-w if(im(i,j)>im(i-1,j-1)) a=[a 0]; else a=[a 1]; end %n if(im(i,j)>im(i-1,j)) a=[a 0]; else a=[a 1]; end %n-e if(im(i,j)>im(i-1,j+1)) a=[a 0]; else a=[a 1]; end %e if(im(i,j)>im(i,j+1)) a=[a 0]; else a=[a 1]; end %s-e if(im(i,j)>im(i+1,j+1)) a=[a 0]; else a=[a 1]; end %s if(im(i,j)>im(i+1,j)) a=[a 0]; else a=[a 1]; end %s-w if(im(i,j)>im(i+1,j-1)) a=[a 0]; else a=[a 1]; end %w if(im(i,j)>im(i,j-1)) a=[a 0]; else a=[a 1]; end b=0; dec=8; %changing decimal k=0:7 b=a(dec)*(2^k)+b; dec=dec-1; end b; im_lpb(i,j)=b; end end h=hist_vec(im_lpb);% getting histogram end function h=hist_vec(im_lpb) [r c]=size(im_lpb); h=zeros(1,256); i=1:r j=1:c h(1,im_lpb(i,j)+1)=h(1,im_lpb(i,j)+1)+1; end end h=h/sum(h); end

image dataset

matlab image-processing textures histogram

Deleting log files which are a week old -



Deleting log files which are a week old -

i need help in writing script deletes "log" files 7 days old. going holiday, process done manually every week me. hence thinking create batch file , set in task scheduler run every week.

eg: there folder called "cache" , there 100 folders starting test-01,test-03,test-05

then within these test folders there logs files dated 120614.log,130614.log etc.. script should identify these log files under every folder , delete if 7 days old.

many thanks

you can utilize robocopy in peculiar way.

first utilize robocopy move week-old log files log folder tree temporary folder , after remove temporary folder. bonus 7zip moved log files before remove them.

robocopy c:\cache %temp%\erasecache /mov /minage:7 rmdir /s /q %temp%\erasecache how work

from robocopy /? learn:

usage :: robocopy source destination [file [file]...] [options]

/mov :: move files (delete source after copying). /minage:n :: minimum file age - exclude files newer n days/date.

and rmdir /?

rmdir [/s] [/q] [drive:]path

/s removes directories , files in specified directory in add-on directory itself. used remove directory tree. /q quiet mode, not inquire if ok remove directory tree /s

%temp% well-known environment variable holds directory current user has write permission

batch-file

stack - Java palindrome checker using queue AND restoring queue to original state -



stack - Java palindrome checker using queue AND restoring queue to original state -

i've written long , complicated method checking if list of elements in queue palindrome. know can improved, goal right past tests in practice-it. i've passed 9 out of 10, test can't seem pass odd elements/not palindrome.

for example: front end [5, 10, -1, 4, 3, 2, 2, 4, -1, 10, 5] back. expected output should false. output true.

also, unlike other tests, elements in queue aren't beingness displayed. unlike previous questions asked similar problem, queue must restored original state. here code far:

public static boolean ispalindrome(queue<integer> q) { stack<integer> s = new stack<integer>(); int size = q.size(); int extra = 0; if(q.isempty()) return true; else  if (size % 2 == 0) { for (int i = 0; i < size / 2; i++) { s.push(q.remove()); }       while (!s.isempty()) {  // while stack not empty: if (s.peek() != q.peek()) { int first = s.pop(); s.push(q.remove()); s.push(first); while (!q.isempty()) s.push(q.remove()); while (!s.isempty()) { q.add(s.pop()); } return false; } else { while (!q.isempty()) s.push(q.remove()); while (!s.isempty()) { q.add(s.pop()); // restore queue original order } return true; } } for (int k = 0; k < size / 2; k++) { q.add(q.remove()); s.push(q.remove()); } for (int l = 0; l < size / 2; l++) s.push(q.remove()); while (!s.isempty()) q.add(s.pop()); } return true; }

if has hard time reading or can suggest way create less convoluted well, appreciate that. give thanks you, , sorry 1 time again bloated code.

why not utilize simple algorithm doesn't care if destroys queue in process, re-create queue first step?

public static boolean ispalindrome(queue<integer> q) { homecoming ispalindromedestructive(copyqueue(q)); } private static boolean ispalindromedestructive(queue<integer> q) { //destructive algorithm treats q disposable. } private static queue<integer> copyqueue(queue<integer> q) { homecoming new linkedlist<integer>(q); }

you can implement copyqueue want, works.

java stack queue palindrome

javascript - View on Map Button: hot to activate a control? -



javascript - View on Map Button: hot to activate a control? -

i'm having problems activating command in google maps, goal when click command want zoom in on marker in map , display associated infowindow.

here .html file

<div id="detailspanel"> <div id="adamsondetails"> <div id="aduimages"> <img src="img/doodle1.jpg"/> <img src="img/doodle2.jpg"/> <img src="img/doodle3.jpg"/> </div> <div id="infotab"> <div id="viewonmap" onclick="viewadu()">view on map</div> </div> </div> <div id="sicdetails"> <div id="sicimages"> <img src="img/sic1.jpg"/> <img src="img/sic2.jpg"/> <img src="img/sic3.jpg"/> </div> </div> <div id="homedetails"> <div id="homeimages"> <img src="img/home1.jpg"/> <img src="img/home2.jpg"/> <img src="img/home3.jpg"/> </div> </div> </div>

this javascript generates markers

for (var = 0; < manilaplaces.length; i++) { var place = manilaplaces[i]; var marker = new google.maps.marker({ position: new google.maps.latlng(place[1], place[2]), map: map, icon: placemarker, title: place[0], zindex: place[4] }); // add together marker array manilamarkers.push(marker); }

this 1 generates infowindow

function aduinfo() { var contentstring = '<div id="content">' + '<div id="sitenotice">' + '</div>' + '<h1 id="firstheading" class="firstheading"><img src="lodging.png"> adu</h1>' + '<div id="bodycontent">' + '<p>text here ' + 'text here</p>' + '</div>' + '</div>'; manilainfowindows[0] = new google.maps.infowindow({ content: contentstring }); var adumarker = manilamarkers[0]; //marker zoom , closing of other infowindow adumarker.setmap(map); google.maps.event.addlistener(adumarker, 'click', function () { map.setzoom(17); map.setcenter(adumarker.getposition()); manilainfowindows[0].open(map, adumarker); }); }

the function below code doesn't work note showmap() executes function shows map on screen including map.setzoom(17) doesn't execute 3rd row code

function viewadu() { showmap(); map.setzoom(17); map.setcenter(adumarker.getposition()); }

everything in code works except one, been trying figure out nil works.

javascript html google-maps google-maps-api-3

php - How to put * asterisk to the right side in drupal 7 -



php - How to put * asterisk to the right side in drupal 7 -

i got stuck in simple task. i've spent 6 hours in searching solution on net can't anything.

please visit url https://direct.studentlingo.com/cart/checkout

i think got want do.

please help me!!!

php drupal drupal-7

c# - IIS Hosted WCF Rest Service keeeps prompting for Windows Auth Credentials -



c# - IIS Hosted WCF Rest Service keeeps prompting for Windows Auth Credentials -

i have wcf rest service i'm building. service hosted in iis under ssl. , have site in iis setup utilize windows authentication anonymous authentication disabled.

however, when effort navigate service.svc file in browser test windows authentication prompted credentials expected. however, after entering credentials continuous prompt me on , over. , don't know why or i'm missing.

if re-enable anonymous authentication , navigate service.svc file wsdl info loads..but understanding no longer using windows authentication @ point.

i have tested in ie , firefox , both of them same thing.

here web.config

<system.servicemodel> <bindings> <webhttpbinding> <binding name="webhttpbindingconfig"> <security mode="transportcredentialonly"> <transport clientcredentialtype="windows" proxycredentialtype="windows"/> </security> </binding> </webhttpbinding> </bindings> <behaviors> <servicebehaviors> <behavior name="httpenabled"> <servicemetadata httpgetenabled="true" httpsgetenabled="true" /> <servicecredentials> <windowsauthentication allowanonymouslogons="false" includewindowsgroups="true"/> </servicecredentials> </behavior> </servicebehaviors> <endpointbehaviors> <behavior name="endpbehavior"> <webhttp helpenabled="true"/> </behavior> </endpointbehaviors> </behaviors> <services> <service name="myservice" behaviorconfiguration="httpenabled"> <endpoint address="" binding="webhttpbinding" contract="mycontract" behaviorconfiguration="endpbehavior" bindingconfiguration="webhttpbindingconfig" /> </service> </services>

any help figuring out great. if need other info please allow me know. give thanks you.

problem: continuous prompt creds when attempting view service.svc in browser. expected result: upon entering valid creds service.svc page should load

edit: going post images of auth settings , illustration of dong give visual, don't have plenty reputation yet. sorry.

i figured out. ended beingness server configuration issue. discovered load service.svc file remote machine valid creds. after did searching found next article:

http://warnajith.blogspot.com/2011/06/iis-75-401-unauthorized-access-error.html

the issue needed disableloopbackcheck. after followed steps on page update registry loaded correctly

note: if you're on windows 2012 server not need step 1 in link provided.

hope helps else in future.

c# wcf rest iis windows-authentication

c# - Entity Framework: Navigation Properties as Primary Keys -



c# - Entity Framework: Navigation Properties as Primary Keys -

i'm using ef 6 mvc 5. have class defined follows:

public class conedsignup { [key, column(order = 0)] public virtual applicationuser attendee { get; set; } [key, column(order = 1)] public virtual conedsession conedsession { get; set; } [required] public datetime signuptime { get; set; } [required] public bool attended { get; set; } }

this link table many-to-many relationship have additional properties relationship. when seek create migration this, gives me error "models.conedsignup: : entitytype 'conedsignup' has no key defined. define key entitytype."

i defined keys it, doesn't it. how can utilize these navigation properties primary keys?

you should read article on msdn :-

http://msdn.microsoft.com/en-gb/data/jj679962.aspx

it explains conventions entity framework adheres too. explains how create own custom conventions.

you need setup classes in specific way ef recognises trying achieve.

c# asp.net-mvc entity-framework

css - How can I color fill an SVG image that is a background? -



css - How can I color fill an SVG image that is a background? -

i have svg image background element. need set color of image, can't seem figure out how that. css code is:

.myclass { background-image:url(path/to/my/image) no-repeat; display: block; width: 5em; height: 5em; }

did seek doing in css? not sure if work don't have fiddle fiddle with.

.myclass { background: reddish (path/to/my/image) no-repeat; display: block; width: 5em; height: 5em; }

css svg

securitymanager - Java : Is there an API to find which class needs the permission in a Custom security manager class? -



securitymanager - Java : Is there an API to find which class needs the permission in a Custom security manager class? -

i'm trying find class has requested permission dynamically in custom security manager. not able find api helps me codebase location of invoking class. below i'm trying do,

i have testapp class tries write file,

package test.profilingsecuritymanager; import java.io.printwriter; public class testapp { public static void main(string [] args) throws exception { system.setsecuritymanager(new newprofilingsecuritymanger()); printwriter author = new printwriter("profile.txt"); writer.println("test line"); writer.close(); } }

the over-ridden method in custom security manager below,

public void checkpermission(final permission permission) { seek { // see parent security manager code says super.checkpermission(permission); } grab (exception e) { // find code base of operations requested permission // can phone call stack here class [] sourceclasses = getclasscontext(); class invokingclass = sourceclasses[sourceclasses.length - 1]; // can accesscontrol context here // using -accesscontroller.getcontext() // how find codebase location of class // needed permission here } }

i need find codebase location of testapp when exception thrown within checkpermission method. 1 help me out on how this?

thanks

java securitymanager

How to find a regex for url value -



How to find a regex for url value -

product-resource/monitor-arms/cutsheets/edge

i trying "cutsheets" string above. trying select lastly "/" , previous "/".

do have thought how this?

thanks help-

you seek regex capture string cutsheets,

.*\/(.*)\/

or

.*\/(.*)\/.*$

demo

regex

types - Basic math in Swift -



types - Basic math in Swift -

why have these conversions between types? thought smart programming language these conversions done automatically. there missing?

let time: float = 55.3 allow min = int(floor(cdouble(time))); allow sec = int(round(cdouble( (time - float(min)) * 60.0 )))

who says have to? works fine (xcode 6 dp2 playground):

import foundation allow time = 55.3 allow min = floor(time); allow sec = round((time - min) * 60.0)

math types swift

assembly - Cracking C# application with OllyDebug -



assembly - Cracking C# application with OllyDebug -

i know if there way crack c# windows application ollydebug. have simple own crackme application written visual c# 2010 express. when open ollydebug , modify asm code need, there no "copy executable" alternative in ollydebug since registration form window dynamically allocated "new" operator (which is, believe, virtualalloc() function phone call in debugger). though able modify asm code (which nop'ing je jumps), not able save .exe file cracked code, looks ollydbg "sees" code in info segment not existing when application launches , dynamically allocated. can help me problem? think modifying *.exe should possible @ to the lowest degree 2 approaches:

1) dig deeper code ollydbg , find place actual code held before allocation (because new instance of registrationform doesn't come magically out of space, it?)

2) if allows fast creation of application in vs express , doesn't require much complicated code, utilize static calls each time clicking on "register" shows same registrationform window (which held in code section of application , hence modifyable in ollydbg).

it ok point out how rewrite code , maintain simple allocate same instance of registrationform (singleton?). thing need crack&save *.exe, relaunch , fill in info "complete registration".

here code of mycrackme class main() method:

using system; using system.collections.generic; using system.linq; using system.text; namespace mycrackme { class mycrackme { public static void main() { myform mainwindow = new myform(); system.windows.forms.application.run(mainwindow); } } }

main window class:

using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.windows.forms; namespace mycrackme { public partial class myform : form { public myform() { initializecomponent(); } private void exittoolstripmenuitem_click(object sender, eventargs e) { application.exit(); } private void abouttoolstripmenuitem_click(object sender, eventargs e) { messagebox.show("all rights reserved", "message"); } private void registertoolstripmenuitem_click(object sender, eventargs e) { registrationform registrationform = new registrationform(); registrationform.show(); } } }

registration form class:

using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.windows.forms; using system.runtime.interopservices; namespace mycrackme { public partial class registrationform : form { // utilize dllimport import win32 messagebox function. [dllimport("user32.dll", entrypoint = "messageboxa", charset = charset.ansi)] public static extern int msgbox(int hwnd, string text, string caption, uint type); public registrationform() { initializecomponent(); } private void button1_click(object sender, eventargs e) { if (textbox1.text == "lincoln" && textbox2.text == "12345") { msgbox(0, "registration completed successfully!", "registration message", 0); } else { msgbox(0, "registration failed", "message", 0); } } } }

here ollydbg screenshot , message comes when setting breakpoints

.net using il bytecodes, gets compiled native instructions when run application, runs in .net vm, similar java. might doing olly debug framework self, not jit generated native code. (which want if understand correctly). saving patched .net application not available in olly far know. there other solutions manipulate/observe msil code.

dbgclr ildasm cordbg cffexplorer

also pebrowse can debug jit generated native machine code too!

you might interested in these papers:

reverse code engineering science of .net applications shukhrat nekbaev

owasp .net debugging

dotnet

rewrite msil on fly on msdn

.net internals , native compiling

stackexchange network has site dedicated reverse engineering, please bring together there :) there might answer question on there.

c# assembly ollydbg cracking

ruby on rails - update nested_attributes_for errors with uniqueness constraint -



ruby on rails - update nested_attributes_for errors with uniqueness constraint -

so i'm working on build user model in rails , user model have associated email address model. email address model has uniqueness constraint on email. right have set user accepts_nested_attributes_for :email_address. works great on create on update error:

activerecord::jdbcerror: org.postgresql.util.psqlexception: error: duplicate key value violates unique constraint "index_email_addresses_on_email"

i can recreate bug doing in rails console:

u = user.create(:name => "foo", :new_password => "passw0rd", :email_address_attributes => {:email => "foo@bar.com"}) u.update({:name => "new name", :email_address_attributes => {:email => "foo@bar.com"}})

how update name while not caring email_address. hasn't changed?

some other notes , code:

i index email_address on email , i'm using rails 4.

class user < activerecord::base belongs_to :email_address validates :email_address, :presence => true accepts_nested_attributes_for :email_address end class emailaddress < activerecord::base validates_format_of :email, :with => rfc822::emailaddress validates :email, :presence => true has_one :user end

when update email_address_attributes in way, you're adding new email_address object user. need pass email address's id attribute, i.e.:

u.update({:name => "new name", :email_address_attributes => {:id => u.email_address.id, :email => "foo@bar.com"}})

or alternatively, can update user's email address in different update statement

u.update({:name => "new name"}) u.email_address.update({:email => "foo@bar.com"})

as controller, need add together email addresses's :id field permitted parameter.

def user_params params.require(:user).permit(:name, email_address_attributes: [:id, :email]) end

there more info strong parameters in strong parameters rails guide. check out more illustration section setup similar yours.

ruby-on-rails ruby ruby-on-rails-4

ruby on rails - Which is better Paperclip or CarrierWave? -



ruby on rails - Which is better Paperclip or CarrierWave? -

i should take 1 of these gems project. better? paperclip more flexible or not? thanks!)

depends on situation cannot tell improve may select according situation commonly used 3 of them:

paperclip carrierwave dragonfly

differences between three

more differences

and more differences

ruby-on-rails rubygems paperclip carrierwave

visual studio 2010 - Why does UMDH to report "failed to enumerate process modules"? -



visual studio 2010 - Why does UMDH to report "failed to enumerate process modules"? -

when running umdh on process on windows 7, response of "failed enumerate process modules". dumps work fine when process executing, fail when memory usage increases. exact point of failure unclear, , error doesn't give hints.

the target process had large_address_aware flag turned on. appear 1 time allocations went on 2g memory space, umdh reported "failed enumerate process modules". solved issue adding large_address_aware flag (using editbin /largeaddressaware umdh.exe -- editbin visual studio tool (c:\program files (x86)\microsoft visual studio 10.0\vc\bin\editbin.exe, me)). after adding flag, dumps umdh successful.

visual-studio-2010 umdh

The Cocos2D/Cocos2d-x internal implementation of drawDot in CCDrawNode/DrawNode -



The Cocos2D/Cocos2d-x internal implementation of drawDot in CCDrawNode/DrawNode -

for opengl es issue, tracing cocos2d 3.1.0 source code. focus on drawdot in ccdrawnode, here internal implementation:

-(void)drawdot:(cgpoint)pos radius:(cgfloat)radius color:(cccolor *)color; { glkvector4 color4 = premultiply(color.glkvector4); glkvector2 zero2 = glkvector2make(0, 0); ccrenderbuffer buffer = [self buffervertexes:4 andtrianglecount:2]; ccrenderbuffersetvertex(buffer, 0, (ccvertex){glkvector4make(pos.x - radius, pos.y - radius, 0, 1), glkvector2make(-1, -1), zero2, color4}); ccrenderbuffersetvertex(buffer, 1, (ccvertex){glkvector4make(pos.x - radius, pos.y + radius, 0, 1), glkvector2make(-1, 1), zero2, color4}); ccrenderbuffersetvertex(buffer, 2, (ccvertex){glkvector4make(pos.x + radius, pos.y + radius, 0, 1), glkvector2make( 1, 1), zero2, color4}); ccrenderbuffersetvertex(buffer, 3, (ccvertex){glkvector4make(pos.x + radius, pos.y - radius, 0, 1), glkvector2make( 1, -1), zero2, color4}); ccrenderbuffersettriangle(buffer, 0, 0, 1, 2); ccrenderbuffersettriangle(buffer, 1, 0, 2, 3); }

i remember drawdot allows draw circle radius. in knowledge of drawing circle opengl, utilize many triangles form circle, algorithm http://slabode.exofire.net/circle_draw.shtml. please kindly explain why cocos2d uses 2 triangles? or not 2 triangles, miss something?

for reference, cocos2d-x code is:

void drawnode::drawdot(const vec2 &pos, float radius, const color4f &color) { unsigned int vertex_count = 2*3; ensurecapacity(vertex_count); v2f_c4b_t2f = {vec2(pos.x - radius, pos.y - radius), color4b(color), tex2f(-1.0, -1.0) }; v2f_c4b_t2f b = {vec2(pos.x - radius, pos.y + radius), color4b(color), tex2f(-1.0, 1.0) }; v2f_c4b_t2f c = {vec2(pos.x + radius, pos.y + radius), color4b(color), tex2f( 1.0, 1.0) }; v2f_c4b_t2f d = {vec2(pos.x + radius, pos.y - radius), color4b(color), tex2f( 1.0, -1.0) }; v2f_c4b_t2f_triangle *triangles = (v2f_c4b_t2f_triangle *)(_buffer + _buffercount); v2f_c4b_t2f_triangle triangle0 = {a, b, c}; v2f_c4b_t2f_triangle triangle1 = {a, c, d}; triangles[0] = triangle0; triangles[1] = triangle1; _buffercount += vertex_count; _dirty = true; }

thanks

drawdot uses 2 triangles drawing dot(circle). uses specific fragment shader drawing circle.

https://github.com/cocos2d/cocos2d-iphone/blob/v3.1/cocos2d/ccdrawnode.m#l43

gl_fragcolor = cc_fragcolor*smoothstep(0.0, length(fwidth(cc_fragtexcoord1)), 1.0 - length(cc_fragtexcoord1));

for farther reference: http://people.freedesktop.org/~idr/opengl_tutorials/03-fragment-intro.html

cocos2d-x cocos2d-x-3.0

javascript - Finding the value of a class within a list -



javascript - Finding the value of a class within a list -

i have

<ul id="list"> <li data-markerid="0" class=""> <div class="list-label">a</div> <div class="list-details"> <div class="list-content"> <div class="loc-id">2</div> <div class="loc-addr">england</div> <div class="loc-dist">2 miles</div> <div class="loc-addr2">test</div> <div class="loc-addr2">bristol</div> </div> </div> </li> <li data-markerid="1" class=""> <div class="list-label">a</div> <div class="list-details"> <div class="list-content"> <div class="loc-id">3</div> <div class="loc-addr">england</div> <div class="loc-dist">60 miles</div> <div class="loc-addr2">test</div> <div class="loc-addr2">london</div> </div> </div> </li> </ul>

i'm wanting extract value of using jquery.

i tried:

var targetid = $(this).find('.loc-id').text();

but gets me values of both loc-id's. want 1 i'm selecting (clicking).

for total context, please here: parsing info using jquery

$('#list').click(function () { //change src of img var targetid = $(this).find('.loc-id').text(); // id // since array of objects isn't indexed, need loop find right 1 var foundobject = null; (var key in parsedarray) { if (parsedarray.hasownproperty(key) && parsedarray[key].id == targetid) { foundobject = parsedarray[key]; break; } } // if object found, extract image , set! if (!foundobject) return; var imagesrc = foundobject.locationphoto; // object $('#location-image').attr('src', imagesrc); // set new source });

thanks

in click handler, this references <ul> element has multiple <li> children.

change click handler deed delegate instead:

$('#list').on('click', 'li', function () {

now, within click handler, this references <li> element search should yield single value.

javascript jquery

html - javascript textarea value and if -



html - javascript textarea value and if -

i utilize next code:

<html> <head> <script type="text/javascript"> function asd(){ var b = document.getelementbyid("txt").value; var c = document.getelementbyid("txt2").value; if( b > c ){alert("the first value more sec value");} } </script> </head> <body> <textarea id="txt"></textarea> <input type="button" value="click me" onclick=asd()> <br> <textarea id="txt2"></textarea> </body> </html>

but codes work incorrectly. writing firs textarea, 5. i'm writng scnd textarea , 40. , alarm works. ı dont understand. searched , find solution.

if( parseint(b,10)) > (parseint(c,10)) )

so why has failed first time?

it failed first time because numbers parsed strings.

var b = document.getelementbyid("txt").value; //b = "5" var c = document.getelementbyid("txt2").value; // c = "40" if( b > c ){ // "5" > "40" false because browser not understand this. alert("the first value more sec value"); }

if utilize parseint strings parsed integer.

so:

var b = document.getelementbyid("txt").value; //b = "5" var d = parseint(b); // d = 5

the 'is greater/less than' sign work integers ( , floats etc.) not strings. that's why if-statement returned false.

javascript html

javascript - Add a dynamic vertical and horizontal scrollbar when the contents of the canvas increases in size -



javascript - Add a dynamic vertical and horizontal scrollbar when the contents of the canvas increases in size -

i trying add together vertical , horizontal scroll bar in canvas. image within canvas zoom in , out microsoft powerpoint slides or google maps , need button original size of image back. view hidden area after zoom, need scroll bars ( not drag mouse downwards ) . how can this.

i tried canvas scrollbar not working not working need.

here's illustration adds scrollbars accommodate oversized content.

the thought simple:

size container div smaller desired size

put oversized canvas in container div

set overflow:scroll on container div dynamic scrollbars

example code , demo: http://jsfiddle.net/m1erickson/a8u6p/

<!doctype html> <html> <head> <link rel="stylesheet" type="text/css" media="all" href="css/reset.css" /> <!-- reset css --> <script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script> <style> body{ background-color: ivory; padding:50px; } canvas{border:1px solid red;} div{ overflow:scroll; width:300px; height:300px; border:2px solid blue; } </style> <script> $(function(){ var canvas=document.getelementbyid("canvas"); var ctx=canvas.getcontext("2d"); var img=new image(); img.onload=function(){ ctx.drawimage(img,0,0,img.width,img.height,0,0,canvas.width,canvas.height); } img.src="https://dl.dropboxusercontent.com/u/139992952/stackoverflow/canvas%20compositing.png"; }); // end $(function(){}); </script> </head> <body> <div> <canvas id="canvas" width=800 height=500></canvas> </div> </body> </html>

javascript html canvas

c - Check for duplicate entry from text file -



c - Check for duplicate entry from text file -

i'm creating simple program, want add together entry item records. if item found on record, display error message. otherwise, print new line text file.

file *fp; fp = fopen("data.txt","r+"); printf("enter name:"); scanf("%s",&result); while(fscanf(fp,"%s",searchname) == 1) { if(strmp(searchname,result)) //do }

how display errror message if found in record , print new line if doesn't exist in record ?

i think want strcmp not strmp per post.

you can utilize

if(strcmp(searchname,result) == 0){ printf("error : in record\n"); break; } else //code add together record

c file duplicates printf

java - How to run Jetty server in a LAN? -



java - How to run Jetty server in a LAN? -

i'm running in troubling deploying app on jetty server.

if seek access app using localhost:8080/appname works fine. if seek utilize ip doesn't work (i mean on same computer, ip given ipconfig tool)

i don't know why, know launch server straight eclipse goals set "-jetty.host=0.0.0.0 -djetty.port=8080 jetty:run" funny thing is, if forgot or set else jetty.host parameter (like djetty.host=127.0.0.1) have "2014-06-18 16:59:52.238:info:oejs.serverconnector:main: started serverconnector@1b79a565{http/1.1}{0.0.0.0:8080}" in console output.

any thought wrong ?

thanks !

java eclipse maven jetty

How insert a youtube video in a WordPress plugin page? -



How insert a youtube video in a WordPress plugin page? -

i have created plugin wordpress , have uploaded wordpress plugin repository.

now, want show youtube video in plugin description 1 http://wordpress.org/plugins/easy-media-gallery/ (scroll downwards little see youtube video).

in readme.txt, have tried snippets without success:

[iframe src="http://www.youtube.com/embed/a3pdxmyof5u" width="100%" height="480"] [embed]http://www.youtube.com/watch?v=a3pdxmyof5u[/embed] [embed] http://www.youtube.com/watch?v=a3pdxmyof5u [/embed] [embed] http://www.youtube.com/watch?v=a3pdxmyof5u [embed]

is know how this?

thanks in advance help.

just set youtube link in description , automatically converted...

wordpress-plugin

How to merge two text files around a common value in python -



How to merge two text files around a common value in python -

i have 2 different files.

i need merge these 1 file. there mutual value. 2 files have format. matches not in sequence. dataset1 line1 may not match dataset2 line1. more dataset1 line1 match dataset2 line16 or line 45.

bold matching values. directional help appreciated.

beec,be-ec,,154.7,46.07,,31.63,54.6,4833.6,5.06 bplz,be-lz,,390.6,62.62,,49.0,145.0,27.3,61.52 bflp,bf-op,,180.1,34.89,,40.0,58.26,8533.8,7.31 mrm1234-beec-1635753e001 25.6 70.29 mrm1234-bplz-1814737e003 8.12 18.13 mrm1234-bflp-2470883e001 12.92 18.8

i know how utilize line.split array of each element.

i know how count first column l[6:4] of sec info set matching 4 letter value.

i've tried several ways suggested have not succeeded.

how merge columns in single row joined unique 4 digit identifier? matching of unique value , writing 1 line eludes me.

contents of file dat1:

beec,be-ec,,154.7,46.07,,31.63,54.6,4833.6,5.06 bplz,be-lz,,390.6,62.62,,49.0,145.0,27.3,61.52 bflp,bf-op,,180.1,34.89,,40.0,58.26,8533.8,7.31

contents of file dat2:

mrm1234-beec-1635753e001 25.6 70.29 mrm1234-bplz-1814737e003 8.12 18.13 mrm1234-bflp-2470883e001 12.92 18.8

use quick & dirty script concatenate lines of both files described.

dat1 = {} open('dat1') f: line in f.readlines(): dat1[line.split(',')[0]] = line.strip().split(',')[1:] dat2 = {} open('dat2') f: line in f.readlines(): key = line.strip().split()[0].split('-')[1] dat2[key] = line.strip().split()[1:] key in dat1.keys(): print("%s,%s,%s" % (key, str.join(',', dat1[key]), str.join(',', dat2[key])))

this produce next output.

bflp,bf-op,,180.1,34.89,,40.0,58.26,8533.8,7.31,12.92,18.8 beec,be-ec,,154.7,46.07,,31.63,54.6,4833.6,5.06,25.6,70.29 bplz,be-lz,,390.6,62.62,,49.0,145.0,27.3,61.52,8.12,18.13

python python-3.x

php - how to pass html code block using ajax and saving it to mysql -



php - how to pass html code block using ajax and saving it to mysql -

i trying save html ajax code:

var textz = "<!doctype html> <html> <head> </head> <body> test</body> </html>"; $.ajax({ type: "get", url: 'ajaxcall.php', data: {valeur:encodeuricomponent(textz),userid:userids}, success: function (dataz) { //$("#resultat").html(dataz); }, datatype: "html" });

it saves , looks :

%3c!doctype%20html%3e%0a%3chtml%3e%0a%3chead%3e%0a%3c%2fhead%3e%0a%3cbody%3e%0test%0a%3c%2fbody%3e%0a%3c%2fhtml%3e

but in case don't know how alter html. opposite encodeuricomponent in php ?

$decoded = urldecode ( $encoded );

see: http://www.php.net/manual/en/function.urldecode.php

php jquery html mysql ajax

networking - Enable outgoing traffic on google compute engine machine without assigning an external ip -



networking - Enable outgoing traffic on google compute engine machine without assigning an external ip -

i have 2 machines on google compute engine,

machine 1 x.x.x.x machine 2 y.y.y.y

machine 1 has external ip address , machine 2 no.

i need mahcine 2 consume services on net on port 80 , 443 using 3rd party library.

in gce default instances without external ip addresses not send packets outside network

routing packets net currently, packets sent net must sent instance has external ip address. if create route sends packets net particular instance, instance must have external ip. if create route sends packets net gateway, source instance doesn't have external ip address, packet dropped.

in machine 1 setup squid proxy http , https connections 3rd party library not allow setup proxy , not take care http_proxy , https_proxy variables.

is there way create default gateway on machine 1 , setup in machine 2 ? other solution?

you can utilize add together route going nat packages machine 1. visit https://developers.google.com/compute/docs/networking#addingroute more info. need configure ip tables, traffic gets routed machine 1. can visit topic @ google groups (https://groups.google.com/forum/#!topic/gce-discussion/ehyhch6ykym) process explained in more detail.

networking google-compute-engine gateway

android - Switching ListViewes visibility causes scrolling issues -



android - Switching ListViewes visibility causes scrolling issues -

i've tried set 2 listviewes @ 1 place, 1 of them visible @ time. (this set programmatically, setvisibility(view.gone)) after sec listview visible, , gone, first 1 not scrolling. i've made tests, , figured out, sec listview's onscrolllistener catches event. have thought how can set up, visible listview's onscrolllistener catches event? i've tried requestfocus(), didn't work.

here sinpets code:

public void toggle_services(view v) { if (home_services_detail.isshown()) { animationhelper.slide_up(this, home_services_detail); home_services_detail.setvisibility(view.gone); } else { home_services_detail.setvisibility(view.visible); animationhelper.slide_down(this, home_services_detail); home_services_detail.requestfocus(); } if (mobile_services_detail.isshown()) { animationhelper.slide_up(this, mobile_services_detail); mobile_services_detail.setvisibility(view.gone); } else { mobile_services_detail.setvisibility(view.visible); animationhelper.slide_down(this, mobile_services_detail); home_services_detail.requestfocus(); } }

and layout:

<linearlayout android:orientation="vertical" android:layout_width="775dp" android:layout_height="match_parent"> <!-- activity_info layout file --> <!-- clickable title --> <textview android:id="@+id/home_services_title" android:text="@string/home_services" android:clickable="true" android:onclick="toggle_services" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center|center_vertical|center_horizontal" style="@style/theader"/> <!--content hide/show --> <linearlayout android:id="@+id/home_services_detail" android:layout_width="match_parent" android:layout_height="fill_parent" android:orientation="vertical" android:layout_weight="1"> <linearlayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="60dp" android:weightsum="1"> <textview android:id="@+id/fees_header" android:layout_width="0dp" style="@style/fees_addons" android:layout_height="match_parent" android:text="@string/fees" android:layout_weight="0.91" android:gravity="center|center_vertical|center_horizontal"/> <textview android:id="@+id/addons_header" android:layout_width="360dp" style="@style/fees_addons" android:layout_height="match_parent" android:gravity="center|center_vertical|center_horizontal" android:text="@string/addons"/> </linearlayout> <listview android:id="@+id/homeserviceslist" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:listselector="@android:color/transparent" android:cachecolorhint="#00000000" android:dividerheight="0dp" android:divider="@null"/> </linearlayout> <textview android:id="@+id/mobile_services_title" android:text="@string/mobile_services" android:clickable="true" android:onclick="toggle_services" android:layout_width="match_parent" android:layout_weight="5.6" android:layout_gravity="bottom" style="@style/theader" android:gravity="center|center_vertical|center_horizontal" android:layout_height="fill_parent" android:maxheight="50dp"/> <!--content hide/show --> <linearlayout android:id="@+id/mobile_services_detail" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_weight="1"> <linearlayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="60dp" android:weightsum="1"> <textview android:id="@+id/mobile_fees_header" android:layout_width="0dp" style="@style/fees_addons" android:layout_height="match_parent" android:text="@string/fees" android:layout_weight="0.91" android:gravity="center|center_vertical|center_horizontal"/> <textview android:id="@+id/mobile_addons_header" android:layout_width="360dp" style="@style/fees_addons" android:layout_height="match_parent" android:gravity="center|center_vertical|center_horizontal" android:text="@string/addons"/> </linearlayout> <listview android:id="@+id/mobileserviceslist" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="1" android:listselector="@android:color/transparent" android:cachecolorhint="#00000000" android:dividerheight="0dp" android:divider="@null"/> </linearlayout> </linearlayout>

i managed solve problem. don't know why there unusual behaviour visibility altering, after made work around. in code, there visibility altering, removing layout parent should not on screen , add together layout should visible. both listviews works perfectly. think it's little bit slower visibility setting, it's working. necessary show on screen 2 title (mobile_services_title , home_services_title), that's reason set layout parameters programmatically.

the toggle function:

public void toggle_services(view v){ linearlayout.layoutparams bigwieght=new linearlayout.layoutparams(linearlayout.layoutparams.match_parent, linearlayout.layoutparams.match_parent, 11f); linearlayout.layoutparams smallwieght=new linearlayout.layoutparams(linearlayout.layoutparams.match_parent, linearlayout.layoutparams.match_parent, 1f); if(ishomevisible){ animationhelper.slide_up(this, home_services_detail); homeserviceslinearlayout.removeview(home_services_detail); homeserviceslinearlayout.setlayoutparams(bigwieght); mobileserviceslinearlayout.addview(mobile_services_detail); animationhelper.slide_down(this, mobile_services_detail); mobileserviceslinearlayout.setlayoutparams(smallwieght); } else { animationhelper.slide_up(this, mobile_services_detail); mobileserviceslinearlayout.removeview(mobile_services_detail); mobileserviceslinearlayout.setlayoutparams(bigwieght); homeserviceslinearlayout.addview(home_services_detail); animationhelper.slide_down(this, home_services_detail); homeserviceslinearlayout.setlayoutparams(smallwieght); } ishomevisible=!ishomevisible; }

and layout:

<linearlayout android:orientation="vertical" android:layout_width="775dp" android:layout_height="match_parent"> <!-- activity_info layout file --> <!-- clickable title --> <linearlayout android:id="@+id/homserviceslinearlayout" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1"> <textview android:id="@+id/home_services_title" android:text="@string/home_services" android:clickable="true" android:onclick="toggle_services" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center|center_vertical|center_horizontal" style="@style/theader"/> <!--content hide/show --> <linearlayout android:id="@+id/home_services_detail" android:layout_width="match_parent" android:layout_height="0dp" android:orientation="vertical" android:layout_weight="1"> <linearlayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="60dp" android:weightsum="1"> <textview android:id="@+id/fees_header" android:layout_width="0dp" style="@style/fees_addons" android:layout_height="match_parent" android:text="@string/fees" android:layout_weight="0.91" android:gravity="center|center_vertical|center_horizontal"/> <textview android:id="@+id/addons_header" android:layout_width="360dp" style="@style/fees_addons" android:layout_height="match_parent" android:gravity="center|center_vertical|center_horizontal" android:text="@string/addons"/> </linearlayout> <listview android:id="@+id/homeserviceslist" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:listselector="@android:color/transparent" android:cachecolorhint="#00000000" android:dividerheight="0dp" android:divider="@null"/> </linearlayout> </linearlayout> <linearlayout android:id="@+id/mobileserviceslinearlayout" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="9.5"> <textview android:id="@+id/mobile_services_title" android:text="@string/mobile_services" android:clickable="true" android:onclick="toggle_services" android:layout_width="match_parent" style="@style/theader" android:gravity="center|center_vertical|center_horizontal" android:layout_height="wrap_content" android:maxheight="50dp"/> <!--content hide/show --> <linearlayout android:id="@+id/mobile_services_detail" android:layout_width="match_parent" android:layout_height="fill_parent" android:orientation="vertical" android:layout_weight="1"> <linearlayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="60dp" android:weightsum="1"> <textview android:id="@+id/mobile_fees_header" android:layout_width="0dp" style="@style/fees_addons" android:layout_height="match_parent" android:text="@string/fees" android:layout_weight="0.91" android:gravity="center|center_vertical|center_horizontal"/> <textview android:id="@+id/mobile_addons_header" android:layout_width="360dp" style="@style/fees_addons" android:layout_height="match_parent" android:gravity="center|center_vertical|center_horizontal" android:text="@string/addons"/> </linearlayout> <listview android:id="@+id/mobileserviceslist" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="1" android:listselector="@android:color/transparent" android:cachecolorhint="#00000000" android:dividerheight="0dp" android:divider="@null"/> </linearlayout> </linearlayout> </linearlayout>

android listview scroll visibility

curl - How to do curl_multi_perform() asynchronously in C++? -



curl - How to do curl_multi_perform() asynchronously in C++? -

i have come utilize curl synchronously doing http request. question how can asynchronously?

i did searches lead me documentation of curl_multi_* interface question , example didn't solve @ all.

my simplified code:

curlm *curlm; int handle_count = 0; curlm = curl_multi_init(); curl *curl = null; curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, curlopt_url, "http://stackoverflow.com/"); curl_easy_setopt(curl, curlopt_writefunction, writecallback); curl_multi_add_handle(curlm, curl); curl_multi_perform(curlm, &handle_count); } curl_global_cleanup();

the callback method writecallback doesn't called , nil happens.

please advise me.

edit:

according @remy's below answer, got seems it's not quite needed. cause using loop still blocking one. please tell me if i'm doing wrong or misunderstanding something. i'm pretty new c++.

here's code again:

int main(int argc, const char * argv[]) { using namespace std; curlm *curlm; int handle_count; curlm = curl_multi_init(); curl *curl1 = null; curl1 = curl_easy_init(); curl *curl2 = null; curl2 = curl_easy_init(); if(curl1 && curl2) { curl_easy_setopt(curl1, curlopt_url, "http://stackoverflow.com/"); curl_easy_setopt(curl1, curlopt_writefunction, writecallback); curl_multi_add_handle(curlm, curl1); curl_easy_setopt(curl2, curlopt_url, "http://google.com/"); curl_easy_setopt(curl2, curlopt_writefunction, writecallback); curl_multi_add_handle(curlm, curl2); curlmcode code; while(1) { code = curl_multi_perform(curlm, &handle_count); if(handle_count == 0) { break; } } } curl_global_cleanup(); cout << "hello, world!\n"; homecoming 0; }

i can 2 http requests simultaneously. callbacks called still need finish before executing next lines. have think of thread?

read documentation 1 time again more carefully, particularly these portions:

http://curl.haxx.se/libcurl/c/libcurl-multi.html

your application can acquire knowledge libcurl when invoked transfer data, don't have busy-loop , phone call curl_multi_perform(3) crazy. curl_multi_fdset(3) offers interface using can extract fd_sets libcurl utilize in select() or poll() calls in order know when transfers in multi stack might need attention. makes easy programme wait input on own private file descriptors @ same time or perhaps timeout every , then, should want that.

http://curl.haxx.se/libcurl/c/curl_multi_perform.html

when application has found out there's info available multi_handle or timeout has elapsed, application should phone call function read/write whatever there read or write right now etc. curl_multi_perform() returns reads/writes done. function not require there info available reading or info can written, can called in case. write number of handles still transfer info in sec argument's integer-pointer.

if amount of running_handles changed previous phone call (or less amount of easy handles you've added multi handle), know there 1 or more transfers less "running". can phone call curl_multi_info_read(3) info each individual completed transfer, , returned info includes curlcode , more. if added handle fails quickly, may never counted running_handle.

when running_handles set 0 (0) on homecoming of function, there no longer transfers in progress.

in other words, need run loop polls libcurl status, calling curl_multi_perform() whenever there info waiting transferred, repeating needed until there nil left transfer.

the blog article linked mentions looping:

the code can used like

http http; http:addrequest("http://www.google.com");

// in update loop called each frame http:update();

you not doing looping in code, why callback not beingness called. new info has not been received yet when phone call curl_multi_perform() 1 time.

c++ curl asynchronous libcurl