Tuesday 15 January 2013

java - Not able to get this error message to work -



java - Not able to get this error message to work -

the code compiles , until come in 101 , shows grade is: . doing wrong?

public static void main(string args[]) { scanner sc = new scanner(system.in); int yourgrade; char grade = 0; system.out.print("enter grade (between 0 , 100 inclusive): "); yourgrade = sc.nextint(); if ((yourgrade>0) && (yourgrade<40)) { grade='f'; } else if ((yourgrade>39) && (yourgrade<55)) { grade='d'; } else if ((yourgrade>54) && (yourgrade<70)) { grade='c'; } else if ((yourgrade>69) && (yourgrade<85)) { grade='b'; } else if ((yourgrade>84) && (yourgrade<=100)) { grade='a'; } if ((yourgrade<0) && (yourgrade>100)) { system.out.println(" " + grade + " not valid grade."); system.out.println("please come in value between 0 , 100 inclusive."); } else { system.out.println("your grade is: " + grade); }

i tried adding lastly bit before final if statement yet, still not able display want to. please forgive me if doing wrong started , know how right.

if ((yourgrade<0) && (yourgrade>100))

these 2 conditions can't both true. if want check if 1 or other true, utilize or instead of and.

if (yourgrade<=0 || yourgrade>100)

also changed <0 <=0 since grade conditions f don't include zero.

you might notice in case, grade variable still set character zero, because that's how initialised it. printing

system.out.println(" " + grade + " not valid grade.");

won't create much sense.

java

sql - mysql | Getting Database error, Invalid Use of Group Function -



sql - mysql | Getting Database error, Invalid Use of Group Function -

i using ignited datatables. working fine except filter. when searching in it, error

invalid utilize of grouping function

i getting query in error result.

select `f`.`formid`, `f`.`formname`, `f`.`formcipath`, min(g.ismenulink) ismenulink, group_concat(distinct g.groupid order g.groupid) groupids (`sys_forms` f) inner bring together `sys_forms_in_groups` g on `g`.`formid` = `f`.`formid` `g`.`groupid` in ('1', '1') , (upper(f.formname) '%da%' or upper(f.formcipath) '%da%' or upper(min(g.ismenulink)) '%da%' ) grouping `f`.`formid` limit 25

what wrong query.??

the problem have aggregation functions in where clause:

select `f`.`formid`, `f`.`formname`, `f`.`formcipath`, min(g.ismenulink) ismenulink, group_concat(distinct g.groupid order g.groupid) groupids (`sys_forms` f) inner bring together `sys_forms_in_groups` g on `g`.`formid` = `f`.`formid` `g`.`groupid` in ('1', '1') , (upper(f.formname) '%da%' or upper(f.formcipath) '%da%' or upper(min(g.ismenulink)) '%da%' --------------^ ) grouping `f`.`formid` limit 25;

you can remove function, think:

where `g`.`groupid` in ('1', '1') , (upper(f.formname) '%da%' or upper(f.formcipath) '%da%' or upper(g.ismenulink) '%da%' )

or move having clause.

select `f`.`formid`, `f`.`formname`, `f`.`formcipath`, min(g.ismenulink) ismenulink, group_concat(distinct g.groupid order g.groupid) groupids (`sys_forms` f) inner bring together `sys_forms_in_groups` g on `g`.`formid` = `f`.`formid` `g`.`groupid` in ('1', '1') , (upper(f.formname) '%da%' or upper(f.formcipath) '%da%' ) grouping `f`.`formid` having upper(min(g.ismenulink)) '%da%' limit 25;

mysql sql

entity framework - How to search and update records with EF -



entity framework - How to search and update records with EF -

i trying find records contain text string in field/property , replace text string new text string , save update record.

i not sure way code belowis not working. have set break points , name variable have replaced text when @ record in database, field still have original value.

var vendors = db.vendor.where(c=> c.name.contains("corp.")); foreach( var vendor in vendors) { var name = vendor.name.replace("corp.", "corporation"); vendor.name = name; } db.savechanges();

update ended using hack now.

var vendors = db.vendor.where(c=> c.name.contains("corp.")); foreach( var vendor in vendors) { var v = db.vendor.find(vendor.id); var name = vendor.name.replace("corp.", "corporation"); v.name = name; } db.savechanges();

i think forgot mark entity's state modified, seek next code

var vendors = db.vendor.where(c=> c.name.contains("corp.")); foreach(var vendor in vendors) { var name = vendor.name.replace("corp.", "corporation"); vendor.name = name; db.entry(vendor).state = entitystate.modified; } db.savechanges();

entity-framework

c# - No Settings tab in Properties of XNA project in Visual Studio -



c# - No Settings tab in Properties of XNA project in Visual Studio -

when i've created windows forms projects have been able store variables utilize on relaunch of application creating them in settings tab in project properties. working on xna project , want similar save 'hi-score' in game. however, when in properties there no settings tab. thought if can access alternative in xna project?

right-click on project in solution explorer, select add together -> component, , find settings file.

c# visual-studio-2010 xna settings

javascript - Make menu dissappear on click anywhere screen -



javascript - Make menu dissappear on click anywhere screen -

hi have code works perfect other 1 time click anywhere on screen create dropdown menu content disappear can't reopen menu. heres code i'm using along jsfiddle demo below.

class="snippet-code-js lang-js prettyprint-override">$(document).click(function (e) { var container = $(".dropdown_content"); if (!container.is(e.target) && container.has(e.target).length === 0) { container.fadeout('slow'); } }); class="snippet-code-css lang-css prettyprint-override">.dropdown { display: block; display: inline-block; margin: 0px 3px; position: relative; } /* ===[ demonstration ]=== */ .dropdown { margin-top: 50px } /* ===[ end demonstration ]=== */ .dropdown .dropdown_button { cursor: pointer; width: auto; display: inline-block; padding: 4px 5px; font-weight: bold; color: #000; line-height: 16px; text-decoration: none !important; } .dropdown input[type="checkbox"]:checked + .dropdown_button { color: #000; padding: 4px 5px; } .dropdown input[type="checkbox"] + .dropdown_button .arrow { display: inline-block; width: 0px; height: 0px; border-top: 5px solid #fff; border-right: 5px solid transparent; border-left: 5px solid transparent; } .dropdown input[type="checkbox"]:checked + .dropdown_button .arrow { border-color: white transparent transparent transparent } .dropdown .dropdown_content { position: absolute; border: 1px solid #fff; padding: 0px; margin: 0; display: none; padding: 7px; -webkit-transition: 500ms ease-in-out; -moz-transition: 200ms ease-in-out; -o-transition: 500ms ease-in-out; -ms-transition: 500ms ease-in-out; transition: 500ms ease-in-out; -webkit-box-shadow: rgba(0, 0, 0, 0.58) 0px 12px 25px; -moz-box-shadow: rgba(0, 0, 0, 0.58) 0px 12px 25px; box-shadow: rgba(0, 0, 0, 0.58) 0px 12px 25px; background: #fff; font-size: 12px; -moz-border-radius: 0 0 4px 4px; -webkit-border-bottom-right-radius: 4px; -webkit-border-bottom-left-radius: 4px; border-radius: 0 0 4px 4px; min-width: 140px; } .dropdown .dropdown_content li { list-style: none; margin-left: 0px; line-height: 16px; border-top: 1px solid #fff; border-bottom: 1px solid #fff; margin-top: 2px; margin-bottom: 2px; -webkit-transition: 0.2s ease-in-out; -moz-transition: 0.2s ease-in-out; } .dropdown .dropdown_content li:hover { background: #d32d41; text-shadow: 1px 1px 0px #9e2635; -moz-background-clip: padding; -webkit-background-clip: padding-box; -webkit-box-shadow: inset 0 0 1px 1px #f14a5e; -moz-box-shadow: inset 0 0 1px 1px #f14a5e; box-shadow: inset 0 0 1px 1px #f14a5e; border: 1px solid #9e2635; color: #fff; -moz-border-radius: 2px; -webkit-border-radius: 2px; border-radius: 2px; } .dropdown .dropdown_content li { display: block; padding: 2px 7px; padding-right: 15px; color: black; text-decoration: none !important; white-space: nowrap; } .dropdown .dropdown_content li:hover { color: white; text-decoration: none !important; } .dropdown input[type="checkbox"]:checked ~ .dropdown_content { display: block } .dropdown input[type="checkbox"] { display: none } class="snippet-code-html lang-html prettyprint-override"><div class="dropdown" id="dropdown"> <input type="checkbox" id="drop1" /> <label for="drop1" class="dropdown_button">click here<span class="arrow"></span></label> <ul class="dropdown_content"> <li><a href="*">user panel</a></li> <li><a href="*">log out</a></li> <li><a href="*">edit profile</a></li> <li><a href="*">edit options</a></li> <li><a href="*">edit avatar</a></li> <li><a href="*">edit signature</a></li> <li><a href="#">buddy list</a></li> </ul> </div>

jsfiddle demo here

http://jsfiddle.net/andreas84x/x5wvnzt7/5/

it's because of the cascading order:

browser default external style sheet internal style sheet inline

when click outside dropdown it'll alter style attribute display: none. when trying alter display block/inline-block in css doesn't take effect, because still inline display: none have priority.

the solution: utilize fadein on button click (remove css fix) :)

javascript jquery html css drop-down-menu

printing - iOS 8 Safari print redirect doesn't stop javascript execution -



printing - iOS 8 Safari print redirect doesn't stop javascript execution -

i have need provide ability print label on successful save , after print redirect search page. works in chrome, firefox, ie, ios 6/7 safari, etc. however, seems ios 8 no longer stops execution of javascript when window.print() issued javascript.

if navigate this jsfiddle example ios 8 safari (connected computer can view console logs) , click print button see console.log trigger when print dialog up. if want print , navigate print wrong screen unless have delay gives plenty time nail print isn't acceptable in case.

i did artificial delay because in ios 6/7 seemed print dialog stop execution of javascript. in case 500ms plenty create work.

has else seen issue when doing similar thing in ios 8 safari? have introduced new event hear utilize this?

// illustration code window.print(); settimeout(function() { console.log('this should print after print issued in ios print dialog.'); }, 500);

you can utilize window.matchmedia (caniuse link), combined window.onbeforeprint , window.onafterprint (for before ie support). reference using matchmedia can found here , here.

to satisfy using matchmedia ios, utilize nested events. first, hear media type alter print. then, within callback, hear media alter screen.

if (window.matchmedia) { var printquery = window.matchmedia('print'); printquery.addlistener(function() { var screenquery = window.matchmedia('screen'); printquery.addlistener(function() { //actions after print dialog close here }); }); }

javascript printing ios8 mobile-safari

android - Keeping data after update sqlite version -



android - Keeping data after update sqlite version -

i had 1 table in sqlite database. changed database version 2 , add together table. user info first table disappeared. asking you: how can maintain user data?

public class database extends sqliteopenhelper { private static final long serialversionuid = 1l; static int databaseversion = 2; static string databasename = "dbinformation"; string table1 = "create table people ( " + "id integer primary key autoincrement, " + "name text, "+ "age integer )"; string table2 = "create table piece of furniture ( " + "id integer primary key autoincrement, " + "type text, "+ "price integer )"; public database(context context) { super(context, databasename, null, databaseversion); // todo auto-generated constructor stub } @override public void oncreate(sqlitedatabase db) { // todo auto-generated method stub db.execsql(table1); } @override public void onupgrade(sqlitedatabase db, int oldversion, int newversion) { // todo auto-generated method stub db.execsql(table2); db.execsql("drop table if exists people"); this.oncreate(db); } }

how can maintain user data?

don't drop people table. create furniture table:

@override public void onupgrade(sqlitedatabase db, int oldversion, int newversion) { if (oldversion<2) { db.execsql(table2); } }

tomorrow, might bump schema version 3 , add together yet table:

@override public void onupgrade(sqlitedatabase db, int oldversion, int newversion) { if (oldversion<2) { db.execsql(table2); } if (oldversion<3) { db.execsql(create_rutabaga_table_statement); } }

and on.

android sqlite

c# - Trying to programmatically shutdown a farm server in ARR throws "Query not supported" error -



c# - Trying to programmatically shutdown a farm server in ARR throws "Query not supported" error -

i'm trying "shutdown gracefuly" sample server in server farm using microsoft.web.administration api. found similar solution on internet, did not work me.

var mgr = new servermanager(); var conf = mgr.getapplicationhostconfiguration(); var sect = conf.getsection("webfarms"); var webfarms = sect.getcollection(); var farm = webfarms[0]; var servers = farm.getcollection(); var server = servers[0]; var arr = server.getchildelement("applicationrequestrouting"); var counters = arr.getchildelement("counters"); //console.writeline(counters.attributes); // gives error "not supported" var method = arr.methods["setstate"]; var instance = method.createinstance(); instance.input.attributes[0].value = 2; //shutdown gracefully instance.execute(); // exception hresult: 0x80070032

c# arr remote-control

sql - Vector (array) addition in Postgres -



sql - Vector (array) addition in Postgres -

i have column numeric[] values have same size. i'd take element-wise average. mean average of

{1, 2, 3}, {-1, -2, -3}, , {3, 3, 3}

should {1, 1, 1}. of involvement how sum these element-wise, although expect solution 1 solution other.

(nb: length of arrays fixed within single table, may vary between tables. need solution doesn't assume length.)

my initial guess should using unnest somehow, since unnest applied numeric[] column flattens out arrays. i'd think there's nice way utilize sort of windowing function + group by pick out individual components of each array , sum them.

-- illustration info create table (vector numeric[]) ; insert values ('{1, 2, 3}'::numeric[]) ,('{-1, -2, -3}'::numeric[]) ,('{3, 3, 3}'::numeric[]) ;

i discovered solution on own 1 use.

first, can define function adding 2 vectors:

create or replace function vec_add(arr1 numeric[], arr2 numeric[]) returns numeric[] $$ select array_agg(result) (select tuple.val1 + tuple.val2 result (select unnest($1) val1 ,unnest($2) val2 ,generate_subscripts($1, 1) ix) tuple order ix) inn; $$ language sql immutable strict;

and function multiplying constant:

create or replace function vec_mult(arr numeric[], mul numeric) returns numeric[] $$ select array_agg(result) (select val * $2 result (select unnest($1) val ,generate_subscripts($1, 1) ix) t order ix) inn; $$ language sql immutable strict;

then can utilize postgresql statement create aggregate create vec_sum function directly:

create aggregate vec_sum(numeric[]) ( sfunc = vec_add ,stype = numeric[] );

and finally, can find average as:

select vec_mult(vec_sum(vector), 1 / count(vector)) a;

sql arrays postgresql vectorization

jquery - Apply Pattern to a 3d image using javascript -



jquery - Apply Pattern to a 3d image using javascript -

i want apply pattern 3d image using javascript.i have sample image

and pattern

i want apply pattern shirt utilize canvas set first image background image of canvas , apply pattern using code of javascript

<!doctype html> <html> <head> <titlelab></title> <style> #mycanvas{ border:1px solid #000000; background-image:url('image/shirt.jpeg'); background-size:cover } </style> <script> function drawshape(){ // canvas element using dom var canvas = document.getelementbyid('mycanvas'); // create sure don't execute when canvas isn't supported if (canvas.getcontext){ // utilize getcontext utilize canvas drawing var ctx = canvas.getcontext('2d'); // create new image object utilize pattern var img = new image(); img.src = 'pattern.jpg'; img.onload = function(){ // create pattern var ptrn = ctx.createpattern(img,'repeat'); ctx.fillstyle = ptrn;1 ctx.fillrect(10,100,100,100); } } else { alert('you need safari or firefox 1.5+ see demo.'); } } </script> </head> <body onload="drawshape();"> <canvas id="mycanvas" width="249" height="428"> </canvas> </body> </html>

how identify paths fill shirt . when fills looks sticker set on , how create realistic.is there library available larn there.need help. thanks.

have loog on link below

http://jsfiddle.net/m1erickson/kzfkd/

var canvas = document.getelementbyid("canvas"); var ctx = canvas.getcontext("2d"); var img1 = new image(); var img = new image(); img.onload = function () { img1.onload = function () { start(); } img1.src = "https://dl.dropboxusercontent.com/u/139992952/stackoverflow/4jisz1.png"; } img.src = "https://dl.dropboxusercontent.com/u/139992952/stackoverflow/boomu1.png"; function start() { ctx.drawimage(img1, 0, 0); ctx.globalcompositeoperation = "source-atop"; var pattern = ctx.createpattern(img, 'repeat'); ctx.rect(0, 0, canvas.width, canvas.height); ctx.fillstyle = pattern; ctx.fill(); ctx.globalalpha = .10; ctx.drawimage(img1, 0, 0); ctx.drawimage(img1, 0, 0); ctx.drawimage(img1, 0, 0); } <canvas id="canvas" width=436 height=567></canvas>

javascript jquery html5 canvas

.net - Mutex c#.how system recognize mutually exclusive codes -



.net - Mutex c#.how system recognize mutually exclusive codes -

i have method a() in project a

and method b() in project b

i need create both method mutually exclusive

at nowadays code follows

in project a

mutex mutex = new mutex(fale,"mt"); mutex.waitone(); //some lengthy code mutex.releasemutex();

in project b have

mutex mutex = new mutex(fale,"mt"); mutex.waitone(); //some different lengthy code mutex.releasemutex();

i see both function works mutually exclusive expected.

now have 2 questions here

one:i utilize name name “mt” in both methods. reason why 2 code became mutually exclusive.

is there different way 2 codes mutually exclusive if utilize different name?

two:suppose code on project goes in infinite loop how can start method in b?(how can avoid dead lock)

the way mutex work having 2 proceeses requesting ownership on same object, first 1 gets , sec must wait until first releases it. name scheme uses determine if they're "same" or not, using different name allow access both @ same time (since each 1 request ownership of own mutex, nobody else claims).

about sec question, infinite loop not deadlock, think it's more bug in first process else. in simple program, such thing error , programme crash. timeout might solve it, may create problem if there shared resource held (which reason why utilize mutually exclusive access in first place). take precautions in avoiding such bugs in first place, or if can legitimally happen, release mutex early.

c# .net mutex

swift - Bezier and b-spline arc-length algorithm giving me problems -- SOLVED -



swift - Bezier and b-spline arc-length algorithm giving me problems -- SOLVED -

i'm having bit of problem calculating arc-length of bezier , b-spline curves. i've been banging head against several days, , think i'm there, can't seem right. i'm developing in swift, think syntax clear plenty knows c/c++ able read it. if not, please allow me know , i'll seek translate c/c++.

i've checked implementations against several sources on , on again, and, far algorithms go, seem correct, although i'm not sure b-spline algorithm. tutorials utilize degree, , utilize order, of curve in calculations, , confused. in addition, in using gauss-legendre quadrature, understand i'm supposed sum integration of spans, i'm not sure i'm understanding how correctly. understand, should integrating on each knot span. correct?

thanks in advance assistance can give me.

when calculate length of bezier curve next command polygon, 28.2842712474619, while 3d software (cinema 4d , maya) tells me length should 30.871.

let beziercontrolpoints = [ vector(-10.0, -10.0), vector(0.0, -10.0), vector(0.0, 10.0), vector(10.0, 10.0) ]

the length of b-spline off. algorithm produces 5.6062782185353, while should 7.437.

let splinecontrolpoints = [ vector(-2.0, -1.0), vector(-1.0, 1.0), vector(-0.25, 1.0), vector(0.25, -1.0), vector(1.0, -1.0), vector(2.0, 1.0) ]

i'm not mathematician, i'm struggling math, think have gist of it.

the vector class pretty straight-forwared, i've overloaded operators convenience/legibility makes code quite lengthy, i'm not posting here. i'm not including gauss-legendre weights , abscissae. can download source , xcode project here (53k).

here's bezier curve class:

class bezier { var c0:vector var c1:vector var c2:vector var c3:vector init(ic0 _ic0:vector, ic1 _ic1:vector, ic2 _ic2:vector, ic3 _ic3:vector) { c0 = _ic0 c1 = _ic1 c2 = _ic2 c3 = _ic3 } // calculate curve length using gauss-legendre quadrature func curvelength()->double { allow gl = gausslegendre() gl.order = 3 // plenty quadratic polynomial allow xprime = gl.integrate(a:0.0, b:1.0, closure:{ (t:double)->double in homecoming self.dx(attime:t) }) allow yprime = gl.integrate(a:0.0, b:1.0, closure:{ (t:double)->double in homecoming self.dy(attime:t) }) homecoming sqrt(xprime*xprime + yprime*yprime) } // vectorize this, correctness > efficiency // derivative of x-component func dx(attime t:double)->double { allow tc = (1.0-t) allow r0 = (3.0 * tc*tc) * (c1.x - c0.x) allow r1 = (6.0 * tc*t) * (c2.x - c1.x) allow r2 = (3.0 * t*t) * (c3.x - c2.x) homecoming r0 + r1 + r2 } // derivative of y-component func dy(attime t:double)->double { allow tc = (1.0-t) allow r0 = (3.0 * tc*tc) * (c1.y - c0.y) allow r1 = (6.0 * tc*t) * (c2.y - c1.y) allow r2 = (3.0 * t*t) * (c3.y - c2.y) homecoming r0 + r1 + r2 } }

here b-spline class:

class bspline { var spanlengths:[double]! = nil var totallength:double = 0.0 var cp:[vector] var knots:[double]! = nil var o:int = 4 init(controlpoints:[vector]) { cp = controlpoints calcknots() } // method homecoming length of curve using gauss-legendre numerical integration func cachespanlengths() { spanlengths = [double]() totallength = 0.0 allow gl = gausslegendre() gl.order = o-1 // derivative should quadratic, o-2 suffice? // doing right? piece-wise integration? in o-1 ..< knots.count-o { allow t0 = knots[i] allow t1 = knots[i+1] allow xprime = gl.integrate(a:t0, b:t1, closure:self.dx) allow yprime = gl.integrate(a:t0, b:t1, closure:self.dy) allow spanlength = sqrt(xprime*xprime + yprime*yprime) spanlengths.append(spanlength) totallength += spanlength } } // b-spline basis function func basis(i:int, _ k:int, _ x:double)->double { var r:double = 0.0 switch k { case 0: if (knots[i] <= x) && (x <= knots[i+1]) { r = 1.0 } else { r = 0.0 } default: var n0 = x - knots[i] var d0 = knots[i+k]-knots[i] var b0 = basis(i,k-1,x) var n1 = knots[i+k+1] - x var d1 = knots[i+k+1]-knots[i+1] var b1 = basis(i+1,k-1,x) var left = double(0.0) var right = double(0.0) if b0 != 0 && d0 != 0 { left = n0 * b0 / d0 } if b1 != 0 && d1 != 0 { right = n1 * b1 / d1 } r = left + right } homecoming r } // method calculate , store knot vector func calcknots() { // number of knots in knot vector = number of command points + order (i.e. grade + 1) allow knotcount = cp.count + o knots = [double]() // open b-spline ends incident on first , lastly command points, // first o knots same , lastly o knots same, o order // of curve. var k = 0 in 0 ..< o { knots.append(0.0) } in o ..< cp.count { k++ knots.append(double(k)) } k++ in cp.count ..< knotcount { knots.append(double(k)) } } // vectorize this, correctness > efficiency // derivative of x-component func dx(t:double)->double { var p = double(0.0) allow n = o in 0 ..< cp.count-1 { allow u0 = knots[i + n + 1] allow u1 = knots[i + 1] allow fn = double(n) / (u0 - u1) allow thepoint = (cp[i+1].x - cp[i].x) * fn allow b = basis(i+1, n-1, double(t)) p += thepoint * b } homecoming double(p) } // derivative of y-component func dy(t:double)->double { var p = double(0.0) allow n = o in 0 ..< cp.count-1 { allow u0 = knots[i + n + 1] allow u1 = knots[i + 1] allow fn = double(n) / (u0 - u1) allow thepoint = (cp[i+1].y - cp[i].y) * fn allow b = basis(i+1, n-1, double(t)) p += thepoint * b } homecoming double(p) } }

and here gauss-legendre implementation:

class gausslegendre { var order:int = 5 init() { } // numerical integration of arbitrary function func integrate(a _a:double, b _b:double, closure f:(double)->double)->double { var result = 0.0 allow wgts = gl_weights[order-2] allow absc = gl_abscissae[order-2] in 0..<order { allow a0 = absc[i] allow w0 = wgts[i] result += w0 * f(0.5 * (_b + _a + a0 * (_b - _a))) } homecoming 0.5 * (_b - _a) * result } }

and main logic:

let beziercontrolpoints = [ vector(-10.0, -10.0), vector(0.0, -10.0), vector(0.0, 10.0), vector(10.0, 10.0) ] allow splinecontrolpoints = [ vector(-2.0, -1.0), vector(-1.0, 1.0), vector(-0.25, 1.0), vector(0.25, -1.0), vector(1.0, -1.0), vector(2.0, 1.0) ] var bezier = bezier(controlpoints:beziercontrolpoints) println("bezier curve length: \(bezier.curvelength())\n") var spline:bspline = bspline(controlpoints:splinecontrolpoints) spline.cachespanlengths() println("b-spline curve length: \(spline.totallength)\n")

update: problem (partially) solved

thanks mike answer!

i verified correctly remapping numerical integration interval a..b -1..1 purposes of legendre-gauss quadrature. math here (apologies real mathematicians out there, it's best long-forgotten calculus).

i've increased order of legendre-gauss quadrature 5 32 mike suggested.

then after lot of floundering around in mathematica, came , re-read mike's code , discovered code not equivalent his.

i taking square root of sums of squared integrals of derivative components:

when should have been taking integral of magnitudes of derivative vectors:

in terms of code, in bezier class, instead of this:

// wrong func curvelength()->double { allow gl = gausslegendre() gl.order = 3 // plenty quadratic polynomial allow xprime = gl.integrate(a:0.0, b:1.0, closure:{ (t:double)->double in homecoming self.dx(attime:t) }) allow yprime = gl.integrate(a:0.0, b:1.0, closure:{ (t:double)->double in homecoming self.dy(attime:t) }) homecoming sqrt(xprime*xprime + yprime*yprime) }

i should have written this:

// right func curvelength()->double { allow gl = gausslegendre() gl.order = 32 homecoming = gl.integrate(a:0.0, b:1.0, closure:{ (t:double)->double in allow x = self.dx(attime:t) allow y = self.dy(attime:t) homecoming sqrt(x*x + y*y) }) }

my code calculates arc length as: 3.59835872777095 mathematica: 3.598358727834686

so, result pretty close. interestingly, there discrepancy between plot in mathematica of test bezier curve, , same rendered cinema 4d, explain why arc lengths calculated mathematica , cinema 4d different well. think trust mathematica more correct, though.

in b-spline class, instead of this:

// wrong func cachespanlengths() { spanlengths = [double]() totallength = 0.0 allow gl = gausslegendre() gl.order = o-1 // derivative should quadratic, o-2 suffice? // doing right? piece-wise integration? in o-1 ..< knots.count-o { allow t0 = knots[i] allow t1 = knots[i+1] allow xprime = gl.integrate(a:t0, b:t1, closure:self.dx) allow yprime = gl.integrate(a:t0, b:t1, closure:self.dy) allow spanlength = sqrt(xprime*xprime + yprime*yprime) spanlengths.append(spanlength) totallength += spanlength } }

i should have written this:

// right func cachespanlengths() { spanlengths = [double]() totallength = 0.0 allow gl = gausslegendre() gl.order = 32 // doing right? piece-wise integration? in o-1 ..< knots.count-o { allow t0 = knots[i] allow t1 = knots[i+1] allow spanlength = gl.integrate(a:t0, b:t1, closure:{ (t:double)->double in allow x = self.dx(attime:t) allow y = self.dy(attime:t) homecoming sqrt(x*x + y*y) }) spanlengths.append(spanlength) totallength += spanlength } }

unfortunately, b-spline math not straight-forward, , haven't been able test in mathematica bezier math, i'm not exclusively sure code working, above changes. post update when verify it.

update 2: problem solved

eureka, discovered off-by 1 error in code calculate b-spline derivative.

instead of

// derivative of x-component func dx(t:double)->double { var p = double(0.0) allow n = o // wrong (should 1 less) in 0 ..< cp.count-1 { allow u0 = knots[i + n + 1] allow u1 = knots[i + 1] allow fn = double(n) / (u0 - u1) allow thepoint = (cp[i+1].x - cp[i].x) * fn allow b = basis(i+1, n-1, double(t)) p += thepoint * b } homecoming double(p) } // derivative of y-component func dy(t:double)->double { var p = double(0.0) allow n = o // wrong (should 1 less_ in 0 ..< cp.count-1 { allow u0 = knots[i + n + 1] allow u1 = knots[i + 1] allow fn = double(n) / (u0 - u1) allow thepoint = (cp[i+1].y - cp[i].y) * fn allow b = basis(i+1, n-1, double(t)) p += thepoint * b } homecoming double(p) }

i should have written

// derivative of x-component func dx(t:double)->double { var p = double(0.0) allow n = o-1 // right in 0 ..< cp.count-1 { allow u0 = knots[i + n + 1] allow u1 = knots[i + 1] allow fn = double(n) / (u0 - u1) allow thepoint = (cp[i+1].x - cp[i].x) * fn allow b = basis(i+1, n-1, double(t)) p += thepoint * b } homecoming double(p) } // derivative of y-component func dy(t:double)->double { var p = double(0.0) allow n = o-1 // right in 0 ..< cp.count-1 { allow u0 = knots[i + n + 1] allow u1 = knots[i + 1] allow fn = double(n) / (u0 - u1) allow thepoint = (cp[i+1].y - cp[i].y) * fn allow b = basis(i+1, n-1, double(t)) p += thepoint * b } homecoming double(p) }

my code calculates length of b-spline curve 6.87309971722132. mathematica: 6.87309884638438.

it's not scientifically precise, plenty me.

the legendre-gauss procedure defined interval [-1,1], whereas beziers , b-splines defined on [0,1], that's simple conversion , @ to the lowest degree while you're trying create sure code right thing, easy bake in instead of supplying dynamic interval (as say, accuracy on efficiency. 1 time works, can worry optimising)

so, given weights w , abscissae a (both of same length n), you'd do:

z = 0.5 in 1..n w = w[i] = a[i] t = z * + z sum += w * arcfn(t, xpoints, ypoints) homecoming z * sum

with pseudo-code assuming list indexing 1. arcfn defined as:

arcfn(t, xpoints, ypoints): x = derive(xpoints, t) y = derive(ypoints, t) c = x*x + y*y homecoming sqrt(c)

but part looks right already.

your derivatives right too, main question is: "are using plenty slices in legendre-gauss quadrature?". code suggests you're using 5 slices, isn't plenty result. using http://pomax.github.io/bezierinfo/legendre-gauss.html term data, want set n of 16 or higher (for cubic bezier curves, 24 safe, although still underperformant curves cusps or lots of inflections).

i can recommend taking "unit test" approach here: test bezier , bspline code (separately) known base of operations , derivative values. check out? 1 problem ruled out. on lg code: if perform legendre-gauss on parametric function straight line using:

fx(t) = t fy(t) = t fx'(t) = 1 fy'(t) = 1

over interval t=[0,1], know length should exactly square root of 2, , derivatives simplest possible. if work, non-linear test using:

fx(t) = sin(t) fy(t) = cos(t) fx'(t) = cos(t) fy'(t) = -sin(t)

over interval t=[0,1]; know length should exactly 1. lg implementation yield right value? problem ruled out. if doesn't, check weights , abscissae. match ones linked page (generated verifiably right mathematica program, pretty much guaranteed correct)? using plenty slices? bump number 10, 16, 24, 32; increasing number of slices show stabilising summation, adding more slices doesn't alter digits before 2nd, 3rd, 4th, 5th, etc decimal point increment count.

are curves you're testing known problematic curves? plot them, have cusps or lots of inflections? that's going problem lg, seek simpler curves see if values those, @ least, correct.

finally, check types: using highest precision possible datatype? 32 bit floats going run mysteriously disappearing fpu , wonderful rounding errors @ values need utilize when doing lg reasonable number of slices.

swift bezier numerical-integration

HTML label for ACE editor? -



HTML label for ACE editor? -

i have <div> based ace editor.

<label for="editorid">content</label><div id="editorid></div>

is possible create <label> for attribute work without adding onclick event?

yes, need assign id hidden textarea used ace

editor.container.id = ""; // remove id container div editor.textinput.getelement().id = "editorid"; // assign id textarea

html ace-editor label-for

javascript - Reset position after .animate() method -



javascript - Reset position after .animate() method -

i'm trying combine .toggle() method animation. i've followed methods laid out in this fiddle in this post, sec click isn't returning div original position.

the behavior should be:

click title content expands slide on headline click again content contracts slide downwards original position <-- isn't happening

html

<div id="headline"> <h1>this headline</h1> </div> <div id="page-wrap"> <!-- contains more 1 article, need whole thing slide --> <article class="post"> <div class="title"><h1>feedback</h1></div> <div class="content"> <p>videos can more direct instruction. currently, how give feedback on assignments?</p> <p>it takes lot of time, right?</p> <p>video can used give direct feedback pupil because communicates areas of improvement more written feedback alone.</p> </div> </article> </div>

css

#headline { position:fixed; top:10px; left:10px; width:380px; } #page-wrap { position:relative; top:200px; } .post { width:300px; } .post .title { cursor: pointer; } .post .content { display:none; }

script

$(".title").click(function() { $title = $(this); $content = $title.next(); $content.toggle( function() { $("#page-wrap").animate({"margin-top":"200px"}, 'fast') }, function () { $("#page-wrap").animate({"margin-top":"-200px"}, 'fast') } ) }); codepen demo here's live page more context.

javascript jquery css

c++ - Will QMessageBox block the running of the whole main thread in Qt? -



c++ - Will QMessageBox block the running of the whole main thread in Qt? -

i new qt

my situation is: reason, have emit heartbeat signal main thread, @ same time create qmessagebox window using:

reply = qmessagebox::question(this, tr("sure want quit?"), tr("sure quit?"), qmessagebox::yes|qmessagebox::no);

i want message box block user's input other windows, not want block heartbeat signal. how should this? or done default in qt?

qmessagebox::question internally executes event loop. continues running. don't need worried this.

however can unusual effects using such functions. e.g. if heartbeat open dialog dialog open if dialog open already. imagine have tcp/ip stack running. stack can go on happen... whereever qmessagebox::question() executed... in middle of function.

this why have policy in our company forbids utilize qmessagebox::question() (and similar) , phone call exec() on dialogs in our applications. creating modal dialogs on heap , utilize signals instead.

c++ qt qmessagebox

rust - Returning a closure with mutable environment -



rust - Returning a closure with mutable environment -

i trying build solution graham´s accumulator mill challenge requires function homecoming closure closes on mutable numeric variable initial value received through parameter. each phone call closure increments captured variable value parameter closure , returns accumulated value.

after reading closures rfc , questions returning unboxed closures (in particular this). come solution compiled, result not expect.

#![feature(unboxed_closures, unboxed_closure_sugar)] fn accumulator_factory(n: f64) -> box<|&mut: f64| -> f64> { allow mut acc = n; box |&mut: i: f64| { acc += i; acc } } fn main() { allow mut acc_cl = accumulator_factory(5f64); println!("{}", acc_cl.call_mut((3f64,))); println!("{}", acc_cl.call_mut((3f64,))); }

afaik closure captures acc value, generated struct acts environment mutable , acc_cl should retain same environment instance between calls.

but printed result 6 in both cases, seems modified value not persisting. , more confusing how result computed. on each execution of closure initial value of acc 3 though n 5 when called.

if modify generator this:

fn accumulator_factory(n: f64) -> box<|&mut: f64| -> f64> { println!("n {}", n); allow mut acc = n; box |&mut: i: f64| { acc += i; acc } }

then execution homecoming 3 , initial value of acc 0 on closure entry.

this difference in semantics looks bug. apart that, why environment reset between calls?

this run rustc 0.12.0.

recently closures capture mode has been changed. default closures biased capture reference because mutual utilize case closures passing them functions downwards phone call stack, , capturing reference create working environment more natural.

sometimes, however, capture reference limiting. example, can't homecoming such closures functions because environment tied phone call stack. such closures need set move keyword before closure:

#![feature(unboxed_closures, unboxed_closure_sugar)] fn accumulator_factory(n: f64) -> box<|&mut: f64| -> f64> { println!("n: {}", n); allow mut acc = n; box move |&mut: i: f64| { acc += i; acc } } fn main() { allow mut acc = accumulator_factory(10.0); println!("{}", acc.call_mut((12.0,))); println!("{}", acc.call_mut((12.0,))); }

this programme works intended:

n: 10 22 34

these 2 closure kinds covered this rfc.

unfortunately, current nightly version of rust compiler crashes on programme (it works on oct. 14 version). don't know why overloaded calls don't work, bug. reason why unboxed closures feature-gated :)

closures rust

Passing Edit uicontrol string to callback of another uicontrol in Matlab -



Passing Edit uicontrol string to callback of another uicontrol in Matlab -

i wrote code in matlab:

function[] = gui_function() window.value1 = uicontrol('style', 'edit', ... 'string', '5', ... 'callback', @is_number); window.computebutton = uicontrol('style', 'push', ... 'callback', {@test_script, str2double(get(window.value1, 'string'))}); end function[] = test_script(varargin) value1 = varargin{3}; end

i want pass text edit uicontrol button's callback. when following, value passed old value set when declaring uicontrol. ie. run gui , have value of 5 in edit. overwrite 20, after pushing button, value beingness passed still 5

what wrong in approach? how can done differently? give thanks in advance!

in opinion, best alternative when working guis utilize handles construction of gui, in every uicontrols stored along associated properties, in add-on (that's cool part) whatever want store in it, variables instance.

so modified code bit create utilize of handles structure. i'm not exclusively clear want, in illustration pushbutton used update content of sec edit box content of 1st edit box. that's basic, should help sense of handles , handles structure. if unclear please allow me know!

function gui_function() screensize = get(0,'screensize'); handles.figure = figure('position',[screensize(3)/2,screensize(4)/2,400,285]); handles.edit1 = uicontrol('style', 'edit','position',[100 150 75 50], ... 'string', '5'); handles.edit2 = uicontrol('style', 'edit','position',[100 80 75 50], ... 'string', 'update me'); handles.computebutton = uicontrol('style', 'push','position',[200 100 75 75],'string','pushme', ... 'callback', @pushbuttoncallback); guidata(handles.figure, handles); %// save handles guidata. it's accessible form everywhere in gui. function pushbuttoncallback(handles,~) handles=guidata(gcf); %// retrieve handles associated figure. textinbox1 = get(handles.edit1,'string'); set(handles.edit2,'string',textinbox1); %// update 2nd edit box content of first. %// whatever want... guidata(handles.figure, handles); %// don't forget update handles construction

you customize gui adding function callback (test_script) in same way implemented pushbuttoncallback. hope understood wanted :)

matlab callback

python - In Django template for mark next n elements -



python - In Django template for mark next n elements -

i'm trying figure out how mark next n elements in list when special element encountered.

i have info construction looks this

[ {"type": "normal1", "text": "some text 1"}, {"type": "special", "text": "some text 2", "length": 2}, {"type": "normal1", "text": "some text 3"}, {"type": "header", "text": "some text 4"}, {"type": "header", "text": "some text 5"}, ]

where types intermingled , length parameter arbitrary each special element. length parameter means special node "owns" next n elements. difference in formatting each normal type in non-trivial. want output this

<p class="normal1">some text 1</p> <div class="special"> <h1>some text2</h1> <p class="normal1">some text 3</p> <h2 class="header">some text 4</h2> </div> <h2 class="header">some text 5</h2>

i can't figure out how divs in there. far template looks this

{% line in line_list %} {% if line.type == "special" %} <h1>{{ line.text }}</h1> {% elif line.type == "header" %} <h2 class="{{ line.type }}">{{ line.text }}</h2> {% else %} <p class="{{ line.type }}">{{ line.text }}</p> {% endif %} {% endfor %}

i can alter info construction if need be, special element contains list normal elements owns, i'd either have duplicate code dealing different elements or recursive templates - i've read big no-no.

to solve problem , on ended defying advice i'd read , utilize recursive templates modified info structure. there several performance hits when doing way. doesn't matter much particular application. i'll outline below ended with.

new info structure

[ {"type": "normal1", "text": "some text 1"}, {"type": "special", "text": "some text 2", "nodes": [ {"type": "normal1", "text": "some text 3"}, {"type": "header", "text": "some text 4"} ]}, {"type": "header", "text": "some text 5"} ]

base_template

{% template_name="sub_template" %} {% include template_name %} {% endwith %}

sub_template

{% line in line_list %} {% if line.type == "special" %} <div class="{{ line.type }}"> <h1>{{ line.text }}</h1> {% line_list=line.nodes %} {% include template_name %} {% endwith %} </div> {% elif line.type == "header" %} <h2 class="{{ line.type }}">{{ line.text }}</h2> {% else %} <p class="{{ line.type }}">{{ line.text }}</p> {% endif %} {% endfor %}

python django templates

c# - Regex for git's repository -



c# - Regex for git's repository -

i want utilize regex validate git repository url. found few answers on stackoverflow none of them passes tests.

the debug here: http://regexr.com/39qia

how can create passes lastly 4 cases?

git@git.host.hy:group-name/project-name.git git@git.ho-st.hy:group-name/project-name.git http://host.xy/agroup-name/project-name.git http://ho-st.xy/agroup-name/project-name.git

i can't since i'm not familiar git link syntaxes, next regex additionally match 4 next values:

((git|ssh|http(s)?)|(git@[\w.-]+))(:(//)?)([\w.@\:/~-]+)(\.git)(/)? ^ ^^ ^

i have indicated changed parts; namely:

added - part after @ because ho-st not passing otherwise. moved - end of character class because otherwise /-~ mean character range / ~ matches lot of characters. escaped final dot (thanks @maticicero)

there lot of things simplified above, since don't know exact goals, i'm leaving regex close possible 1 have.

c# regex

python - Control not returning after self.close() encountered in PyQt -



python - Control not returning after self.close() encountered in PyQt -

i trying create ui using pyqt. has basic working. when script run on terminal, dialog box asking name should open , close when ok pressed. however, unable homecoming command qt app.

my code follows:

class interactive(qtgui.qwidget): def __init__(self): super(interactive,self).__init__() self.initgui() def initgui(self): self.setgeometry(300,300,290,150) self.setwindowtitle('input dialog') self.show() self.inputdialog = qtgui.qinputdialog() self.inputdialog.move(50,50) text, ok = self.inputdialog.gettext(self,'input dialog','enter name:') #self.text = text if ok: self.text = text print text self.close() if __name__ == "__main__": app = qtgui.qapplication(sys.argv) obj = interactive() #app.exec_() if app.exec_(): sys.exit() print "somerandomtext"

the print text within class working, test string "somerandomtext" not , programme not ending.

i have looked @ similar questions @ so, none seemed address same problem.do have create handler this?

normally, application quit automatically when lastly top-level window closes, preventedf happening in illustration because not allow event-loop started properly.

there numerous ways re-structure illustration avoid problem, simplest utilize timer this:

class interactive(qtgui.qwidget): def __init__(self): super(interactive,self).__init__() # delay initialization # self.initgui() ... if __name__ == "__main__": app = qtgui.qapplication(sys.argv) obj = interactive() qtcore.qtimer.singleshot(0, obj.initgui) app.exec_() print "somerandomtext"

ps:

the reason why deletelater() sort of works in other reply because posts deletion event event queue (which processed 1 time event-loop has started). close() method doesn't post event in way, , application doesn't chance quit automatically.

python qt pyqt pyqt4

c++ - How to release heap memory of thread local storage -



c++ - How to release heap memory of thread local storage -

i have construction used thread local storage this:

namespace { typedef boost::unordered_map< std::string, std::vector<xxx> > yyy; boost::thread_specific_ptr<yyy> cache; void initcache() { //the first time called current thread. if (!cache.get()){ cache.reset(new yyy()); } } void clearcache() { if (cache.get()){ cache.reset(); } } }

and class object have been created main thread:

class { public: void f() { initcache(); //and example: insertintocache(); } ~a(){ clearcache();// <-- does/can ?? } }

multiple threads can access object(s) of a stored, example, in global container. each of these threads need phone call a::f() time time. create own re-create of cache on heap 1 time , , bring together when done jobs.

so question : going clean-up threads' memory? , how? give thanks you

there's no reason phone call clearcache().

once thread exits or thread_specific_ptr goes out of scope, cleanup function invoked. if don't pass cleanup function thread_specific_ptr's constructor, utilize delete.

c++ multithreading boost-thread thread-local thread-local-storage

sorting - vb.net Pair Combinations to Create All Possible Sets -



sorting - vb.net Pair Combinations to Create All Possible Sets -

i need help figuring out how go programming problem. have unknown number of pairs. each pair length x width. want create sets of every possible combination of either length or width each pair. here illustration of i'm trying do:

if input 3 pairs, (1x2) (3x4) (5x6) next sets: (1,3,5) (1,3,6) (1,4,5) (1,4,6) (2,3,5) (2,3,6) (2,4,5) (2,4,6)

so if had 4 pairs, create total of 16 sets, etc. need able input each pair , after pairs have been entered, need print out sets. can never include both numbers given pair in same set. how create loop or there built in math function produce possible sets given number of pair inputs? hope described problem plenty if not, please inquire questions. thanks

this called cartesian product.

for example, if have 2 sets , b, such that

a = {1,2} b = {3,4}

then result of cartesian product x b equal to

a x b = {(1,3),(1,4),(2,3),(2,4)}

if want create cartesian product between result obtained above , new set, example:

n = {5,6}

the result of cartesian product x b x n, equal to

a x b = {(1,3),(1,4),(2,3),(2,4)} n = {5,6} ────────────────────────────────────────────────── x b x n = {(1,3,5),(1,3,6),(1,4,5),(1,4,6),(2,3,5),(2,3,6),(2,4,5),(2,4,6)}

each element of first set must paired each element of sec set.

i have developed 4 solutions cartesian product:

using mathematical model, without recursion. solution vectors using calculating each combination number. using recursion, collections class. using list (of ...) class, recursion.

these 3 solutions seemed me hard explain you. furthermore, hard me explain thoughts in english, because native language castilian.

so made effort create solution not utilize recursion, more simple , friendly programmer.

finally, create satisfactory solution. easy understand , without recursion. versatile. number of sets accepted, required, 2 onwards. can utilize number of items. depends on requirements of each developer.

i hope 4th. solution devised, please you, esteemed colleagues.

only need listbox1 within form4. here is:

public class form4 private sub form4_load(sender system.object, e system.eventargs) handles mybase.load '┌─────────── temporary code illustration ───────────┐ dim set_1 list(of string) = new list(of string) dim set_2 list(of string) = new list(of string) dim set_3 list(of string) = new list(of string) set_1.add("1") set_1.add("2") set_2.add("3") set_2.add("4") set_3.add("5") set_3.add("6") '└──────────────────────────────────────────────────┘ dim sets list(of object) = new list(of object) sets.add(set_1) sets.add(set_2) sets.add(set_3) dim product list(of string) = sets(0) = 1 sets.count - 1 product = cartesianproduct(product, sets(i)) next each element string in product me.listbox1.items.add(element) next end sub private function cartesianproduct(byval set_a list(of string), byval set_b list(of string)) list(of string) dim product list(of string) = new list(of string) each string in set_a each b string in set_b product.add(a & b) next next homecoming product end function end class

have nice day! :)

vb.net sorting

supervisord - How start process only after connection on Supervisor -



supervisord - How start process only after connection on Supervisor -

how can create supervisor wait net connection go before trying start process? if process running on wifi dependent server may fail if connection not yet established.

thanks!

i have 2 ideas.not good.

you can write wifi monitor program, monitored supervisod too. when wifi monitor programme detects connection available, phone call supervisorctl start true process.

write event listener. when wifi available, wifi monitor exit success_code(0). event listener receives notification wifi monitor has exited successfully. , event listener start process.

supervisord

java - InvocationTargetException trying to make new instance of service class -



java - InvocationTargetException trying to make new instance of service class -

in current project, when method called:

public collection<? extends object> list_values() throws exception { string nome = classe().getsimplename(); string nome_service = nome+"service"; string local_service = "com.spring.model."+nome; class<?> clazz = class.forname(local_service.tolowercase()+"."+nome_service); object serv = clazz.newinstance(); collection<? extends object> list = (collection<? extends object>) serv.getclass().getmethod("lista").invoke(serv); homecoming list; }

the application triggers invocationtargetexception caused error:

caused by: java.lang.nullpointerexception @ com.spring.config.generic.service.basicservice.lista(basicservice.java:51)

where basicservice superclass class stored in variable clazz.

anyone can tell me doing wrong here? right way create new instance of class?

ps.: line 51 in basicservice placed within method:

@transactional public list<?> lista() { homecoming dao.findall(); }

and fellow member dao defined way:

@autowired protected dao<e> dao;

ok, solve problem adding project class named applicationcontextholder, code:

@component public class applicationcontextholder implements applicationcontextaware { private static applicationcontext context; @override public void setapplicationcontext(applicationcontext applicationcontext) throws beansexception { context = applicationcontext; } public static applicationcontext getcontext() { homecoming context; } }

the final code function list_values(...) that:

public list<?> list_values() throws exception { string nome = classe().getsimplename(); class<?> clazz = class.forname("com.spring.model."+nome.tolowercase()+"."+nome+"service"); object object = clazz.newinstance(); applicationcontextholder.getcontext().getautowirecapablebeanfactory().autowirebean(object); homecoming (list<?>) object.getclass().getmethod("lista").invoke(object); }

java spring reflection invocationtargetexception

c# - What parameters can I use with Unity Input.getAxis? -



c# - What parameters can I use with Unity Input.getAxis? -

unity .getaxis(string name) seems homecoming thought offset generated user input (arrows, mouse or joystick). homecoming values conveniently in interval of <-1; 1> except mousewheel.

from various code samples can see many ways of getting input, there seems no actual name/input list. in case, want enable zoom using wheel or pgup , pgdn. wheel code looks this:

movement.y -= resourcemanager.scrollspeed * input.getaxis("mouse scrollwheel");

but page downwards , page up? and, in general, how can know names utilize in method?

input.getaxis , input.getbutton (as getbuttondown , getbuttonup) homecoming state of 1 of virtual input axis defined in input manager.

the homecoming values doesn't need in range [-1, 1]. virtual axes represent absolute value represented value between -1 , 1. there axes homecoming relative motion the predefined "mousewheel", "mouse x" , "mouse y". homecoming amount axis has moved since lastly frame.

the mousewheel has additional "problems". delta value taken os. if user has set scroll wheel advance 3 lines per "scroll unit", values of multiple of 3. if manage spin wheel fast plenty might values greater 3 or smaller -3.

there no default axes pageup or pagedown, can add together them if like. careful, getaxis homecoming state of virtual axis. when hold downwards positive button "1" long hold button down. if want hear events have utilize getbuttondown / getbuttonup.

however if want check key it's simpler utilize getkeydown / getkeyup takes keycode.

something like:

if(input.getkeydown(keycode.pageup)) movement.y -= 1; if(input.getkeydown(keycode.pagedown)) movement.y += 1;

edit if want know commonly available key names, take @ conventional game input page. @ bottom there's list of mutual keynames including "page up" , "page down". input manager refuses wrong key names. if type 1 in, unfocus input field , value stays, it's correct.

if set positive button whenever press button downwards virtual axis "slowly" increment 0 1 depending on "sensitivity" setting. sensitivity acceleration factor. if release button homecoming "slowly" 0 depending on "gravity" value deceleration factor.

if setup positive , negative button, axis can go both ways 1 when positive button pressed , downwards -1 when press negative button. if "snap" true snap 0 if press opposite button instead of going 0 , start growing in opposite direction.

the "dead" value defines dead-zone. if value of axis smaller dead (or greatern -dead) treated 0. of import real analog input devices have jitter around resting position.

the remaining properties "invert", "type" , 1 should clear when reading documentation.

it's possible define 2 axis same name defaule "horizontal" , "vertical" axes. axes same name treated one.

i think should cover of input manager stuff.

c# unity3d

php - Is it possible to add jQuery slider to come from the DB? -



php - Is it possible to add jQuery slider to come from the DB? -

i'm trying jquery slider come database display in html.

slider in html: http://puu.sh/ccd3x/7421da5d3a.jpg

my database: http://puu.sh/ccd5w/fe9465a903.png

this code it:

<div class="slider_bg"> <div class="wrap"> <div class="wrapper"> <div class="slider"> <!-- #camera_wrap_1 --> <div class="fluid_container"> <div class="camera_wrap camera_azure_skin" id="camera_wrap_1"> <div data-thumb="../images/thumbs/slider1.jpg" data-src="../images/slider/slider1.jpg"> </div> <div data-thumb="../images/thumbs/slider2.jpg" data-src="../images/slider/slider2.jpg"> </div> <div data-thumb="../images/thumbs/slider3.jpg" data-src="../images/slider/slider3.jpg"> </div> <div data-thumb="../images/thumbs/slider4.jpg" data-src="../images/slider/slider4.jpg"> </div> </div><!-- #camera_wrap_1 --> <div class="clear"></div> </div> <!-- end #camera_wrap_1 --> <div class="clear"></div> </div> </div> </div> </div>

what thought code work:

<?php $sql = "select image product productid=2"; $result = mysql_query($sql) or die(mysql_error($connection)); while ($row = mysql_fetch_array($result)) //display results { echo "<a href='../images/".$row['image']."'><img src='../images/".$row['image']."' /></a>"; } ?>

any help appreciated!

<?php $sql = "select image product productid=2"; $result = mysql_query($sql) or die(mysql_error($connection)); ?> <div class="slider_bg"> <div class="wrap"> <div class="wrapper"> <div class="slider"> <!-- #camera_wrap_1 --> <div class="fluid_container"> <div class="camera_wrap camera_azure_skin" id="camera_wrap_1"> <?php while($row = mysql_fetch_array($result)): //display results ?> <div data-thumb="../images/thumbs/<?php echo $row['image']; ?>" data-src="../images/slider/<?php echo $row['image']; ?>"> </div> <?php endwhile; ?> </div><!-- #camera_wrap_1 --> <div class="clear"></div> </div> <!-- end #camera_wrap_1 --> <div class="clear"></div> </div> </div> </div> </div>

php mysql

sql server - SQL stored procedure inserting duplicate OrderNumber -



sql server - SQL stored procedure inserting duplicate OrderNumber -

i searched net days, no effort, maybe cant inquire in right way.

i have sql table this:

create table items ( id int identity(1,1), ordernumber varchar(7), itemname varchar(255), count int )

then have stored procedure inserting items, on demand creating new ordernumber:

create procedure spx_insertitems @insertnewordernr bit, @ordernumber varchar(7), @itemname varchar(255), @count int begin set nocount on; if (@insertnewordernr = 1) begin declare @newnr = (select dbo.fun_getnewordernr()) insert items (ordernumber, itemname, count) values (@newnr, @itemname, @count) select @newnr end else begin insert items (ordernumber, itemname, count) values (@ordernumber, @itemname, @count) select scope_identity() end end

finally there user defined function returning new ordernumber:

create function dbo.fun_getnewordernr () homecoming varchar(7) begin /* func works */ declare @output varchar(7) declare @currentmaxnr varchar(7) set @currentmaxnr = (isnull((select max(ordernumber) items), 'some_default_value_here') /* lets assume @currentmaxnr '01/2014', here comes logic increments @newvalue='02/2014' , sets @output, so: */ set @output = @newvalue homecoming @output end

into items can inserted items not belong ordernumber.

whether item should become new ordernumber, procedure called @insertnewordernr=1, returns new order number, can used insert next items ordernumber while @insertnewordernr=0.

occasionally there happens there come simultaneously 2 requests @insertnewordernr , there problem - items, should correspond different ordernumbers same ordernumber.

i tried utilize transaction no success.

the table construction cant modified me.

what right way ensure, there won't used same newordernumber when simultaneous requests procedure come? stuck here long time till now. please, help.

you have problem long utilize max(ordernumber).

you might consider using sequences:

create sequence

create sequence dbo.ordernumbers int start 1 increment 1 no cache; go create sequence dbo.ordernumberyear int start 2014 increment 1 no cache; select next value dbo.ordernumberyear; --important, run 1 time after creation, years value must returned 1 initial time work correctly.

insert code

declare @ordernumberyear int = (select convert(int, current_value) sys.sequences name = 'ordernumberyear'); if(@ordernumberyear < year(getdate())) begin select @ordernumberyear = next value dbo.ordernumberyear; alter sequence dbo.ordernumbers restart 1 ; end if(@ordernumberyear != year(getdate())) raiserror(n'order year sequence out of sync.', 16, 1); declare @newnr varchar(15) = concat(format(next value dbo.ordernumbers, '00/', 'en-us'), @ordernumberyear); insert items (ordernumber, itemname, count) values (@newnr, @itemname, @count) select @newnr

sql sql-server stored-procedures duplicates

algorithm - Shortest distance with choosing only one coordinates from number of coordinates in same vertical line using python -



algorithm - Shortest distance with choosing only one coordinates from number of coordinates in same vertical line using python -

i have list = coordinates in have coordinates of points lying in xy plane.

there more 1500 points given in coordinates list. have find minimum distance left point right point in xy plane such if 2 or more points lies in same vertical line 1 of them chosen path , hence distance calculation.

example of coordinates list :

coordinates = [(-6, 0), (-5.82, 1.72), (-5.17, -0.27), (-4.28, 0.0), (-2.9, -0.74), (-2.9, -0.2), (-1.55, 0.08), (-1.37, -0.43), (4.8, -1.64), (4.92, -0.25), (5.05, -1.45), (5.36, -0.02), (6, 0)]

so in case point (-2.9,-0.74) not considered.

how utilize dijksra's algorithm such case or other fit algorithm shortest path removing such points in vertical lines not required.

i using itertools permutate , find possible paths , distance , minimum of not fit points more 1000 , not possible ignore same vertical line coordinates mentioned. please help in python

python algorithm python-3.x graph-algorithm shortest-path

c# - ado.net oracle stored procedure output varchar parameter split-cut-truncated -



c# - ado.net oracle stored procedure output varchar parameter split-cut-truncated -

i have oracle-stored procedure (sp) returns varchar parameter, when execute sp , seek read output, string cut. when execute sp on toad , made dbms.output, string returned.

procedure teststringoutput(num in number, str out varchar2) v_c number(38); v_e varchar2(2000); begin select '12345678910111213141516171819ppppppppppppppppppppppppp' str dual; exception when others v_c := sqlcode; v_e:= sqlerrm; dbms_output.put_line(v_c||'-> '||v_e); end;

the way phone call sp script:

declare p2 varchar2(2000) :=''; begin pkgtest.teststringoutput(1,p2); dbms_output.put_line('output string - > '||p2); end;

the output:

output string - > 12345678910111213141516171819ppppppppppppppppppppppppp

the way sp called c#:

public void testoutputstring() { string str = string.empty; using (connection) { oraclecommand objcmd = new oraclecommand(); objcmd.connection = connection; objcmd.commandtext = "pkgtest.teststringoutput"; objcmd.commandtype = commandtype.storedprocedure; objcmd.parameters.add("num", oracletype.number).value = 0; objcmd.parameters.add("str", oracletype.varchar, 2000).direction = parameterdirection.output; foreach (oracleparameter parameter in objcmd.parameters) if (parameter.value == null) parameter.value = dbnull.value; seek { connection.open(); objcmd.executenonquery(); str = (objcmd.parameters["str"].value.tostring()); } grab (exception ex) { throw new exception(ex.message); } connection.close(); } }

but when inspect response string, split until 123456789101112131415161718, part (19ppppppppppppppppppppppppp) lost. see image.

what doing wrong?

update: i'm sure happened, sp's homecoming messages wcf service, when client received response, split.

finally have utilize oracle info provider odp.net instead of ado.net - system.data.oracleclient (deprecated) , works.

c# oracle stored-procedures ado.net

javascript - dc.js chart groups not updating with correct values on charts after click on a parent chart -



javascript - dc.js chart groups not updating with correct values on charts after click on a parent chart -

my issue here have crossfilter grouping cut down function calculating savings, when filter applied on chart, seems not pass right filter across. have similar case working example.

i have created 2 jsbin's out of 1 of them has right behavior.

i have info 2 years in case 2010 , 2014. in savings(not working) chart carrier pie chart doesn't filter year whereas in difot(working) chart.

the links : difot(working) : http://jsbin.com/bagohavehu/2/edit savings (not working expected) : http://jsbin.com/yudametulo/2/edit

thanks lot time , effort.

regards, animesh

to track these calculation problems down, need utilize debugger , set breakpoints in reduction functions or in draw functions see reduced values ended with.

i find using browser's debugger hard (impossible?) in jsbin, have 1 time again pasted code 2 jsfiddles:

parsefloat version: http://jsfiddle.net/gordonwoodhull/aqhlv0qc/

parseint version: http://jsfiddle.net/gordonwoodhull/9bnejplx/1/

now, set breakpoint in chart.redraw (dc.js:1139) see values it's trying plot on clicking slice.

the first time breakpoint nail isn't interesting, because it's yearly chart clicked on, sec nail carrier chart, reveals lot. printing _chart.group().all() parseint version:

now, parsefloat version:

since calculations come out exact int version, end 1 - 0/0 === nan, , somewhere along way dc.js or d3.js silently forces nan zero.

but since float calculations never exact, end 1 - 0/-3e-15 === 1.

you want avoid dividing zero, or close zero, adding check in reduction function produces (i think) desired result:

var grouping = dim.group().reduce( function(p,v){ p.current += parsefloat(v.currentprice); p.compare += parsefloat(v.compareprice); if(math.abs(p.compare) > 0.01) { p.savings = p.current/p.compare; p.result = 1-p.savings; } else p.result = 0; homecoming p; }, function(p,v){ p.current -= parsefloat(v.currentprice); p.compare -= parsefloat(v.compareprice); if(math.abs(p.compare) > 0.01) { p.savings = p.current/p.compare; p.result = 1-p.savings; } else p.result = 0; homecoming p; }, function(){return { current: 0, compare: 0,savings:0, result:0};} );

working version (i think): http://jsfiddle.net/gordonwoodhull/y2sf7y18/1/

javascript dc.js crossfilter

multithreading - Best approach for ServerSocket Java -



multithreading - Best approach for ServerSocket Java -

i have serversocket in 1 of classes of java project. socket receives commands led new actions. example:

deleteallfromdb--> deletes entries on db.

sendmsgtox--> creates new message sent x.

something like:

in = new scanner(s.getinputstream()); message = in.next(); if (message.equalsignorecase("deleteallfromdb"){ //code //more code //even more code } ...

ok, think got thought (it's quite simple utilize examples because english language skills may confuse audience).

the problem methods within class getting bigger , heavier, socket doesn't read incoming messages until method executed , finished.

i think have 2 approaches solve this:

1. multithreaded server

rather processing incoming requests in same thread accepts client connection, connection handed off worker thread processes request

http://tutorials.jenkov.com/java-multithreaded-servers/multithreaded-server.html

2. threaded methods

once read incoming request (message=in.next()), launch thread responsible of methods executed (deletefromdb, sendmsgtox,etc).

any advice appreciated. also, mention, i'm working osgi framework, thou don't think that's relevant question (just in case..).

thanks in advance!

you execute code handles message in executorservice.

like that:

//outside handler: pool = executors.newfixedthreadpool(poolsize); // on message receipt message = in.next(); pool.execute(new messagehandler(message));

so can nicely scale setting poolsize.

so guess method 2

java multithreading sockets osgi serversocket

Understanding namespaces in Ruby -



Understanding namespaces in Ruby -

in code below:

::trace.tracer = ::trace::zipkintracer.new()

what relation between trace , zipkintracer?

zipkintracer within of trace namespace, this:

module trace class zipkintracer # ... end end

the :: before constant name means point root. illustration in next code:

class class1 end module module1 class class1 end def foo ::class1 end end

::class1 ensures refer "root" class1. if had:

def foo class1 end

the module1::class1 referred.

ruby

Drupal Computed Field with Views -



Drupal Computed Field with Views -

i have computed fields , in these fields, html codes simple_html_dom.php class sites. codes works on pages, when seek these fields utilize in view, drupal gives next error.

http://i.stack.imgur.com/w2rhc.jpg

anybody can help?

even if not best solution, after installing views php module of drupal, problem solved. still error message on every time seek alter something, having difficulties on making alter on view, saving , adding same thing 5 times , got successfull, still solution.

drupal drupal-7 drupal-views simple-html-dom computed-field

Google Analytics Android Sharedpreferences -



Google Analytics Android Sharedpreferences -

i want track shared preference settings users of app. example, have 1 shared preference that's boolean , want total number of users have set true , total set false. if user switches setting, want reflect in google analytics. i've gathered need set custom dimension user based scope.

what haven't been able confirm happen in next scenario. have 10 users, 5 have setting set true , other 5 false. if 1 of users switch preference true false, google analytics study total number of "true" users 4 or 5? i'm assuming "false" users study @ 6 regardless.

the results want "true" users = 4 , "false" users = 6.

1) possible accomplish?

2) if so, handled automatically @ google analytics or need manage in code?

the closest reply find how track user preferences google analytics android?

google analytics tracks "events" not "status" there can lot of confusion. ("behavior" series of events.) tracks things "active users" isn't trying do.

google gives ability have events , categorize , name them. so, essentially, have these options:

download , track data. need track new installs vs. changes (of course).

report each user's current status when utilize it. see "trends" based on using app, not changes.

if have plenty usage, study changes. tell if users trending toward 1 setting or another.

personally, track 2,000 info points across 50 apps , few 1000000 events daily. if there way more straight want, i'd know...

android google-analytics sharedpreferences

Wordpress with Advanced Custom Fields showing post content in Modal -



Wordpress with Advanced Custom Fields showing post content in Modal -

i have little issue coding wordpress website advance custom fields , modal.

how can incorporate modal advanced custom fields? modal shows generic name , company.

when move modal loop shows content every post.

pastebin link here

thanks paddy

it looks have sorted out using info attributes.

<div class="content row"> <ul class="slides"> <?php query_posts( 'showposts=-1&orderby=asc&category_name=speakers' ); ?> <?php while ( have_posts() ) : the_post(); ?> <?php if( have_rows('speakers') ): ?> <?php while( have_rows('speakers') ): the_row(); ?> <?php $image = get_sub_field('photo'); ?> <?php $company = get_sub_field('company'); ?> <?php $bio = get_sub_field('bio'); ?> <li class="slide col25 js-open-modal"> <a href="#modal1" class="easy-modal-open js-modal-open" data-post-id="<?= get_the_id(); ?>" data-image-url="<?php echo $image['url']; ?>" data-image-alt="<?php echo $image['alt'] ?>" data-title="<?php echo the_title(); ?>" data-company="<?php echo $company; ?>" data-bio="this bio text"> <img class="logo" src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt'] ?>" /> <h4 class="overlay"><?php echo the_title(); ?><br /><?php echo $company; ?></h4></a> </li> <?php endwhile; ?> <?php endif; ?> <?php endwhile; ?> <?php wp_reset_query(); ?> </ul> </div> <div class="easy-modal js-modal" id="modal1"> <div class="easy-modal-inner"> <img class="logo js-logo" src="" alt="" /> <h4><span class="js-title"></span><span class="js-company"></span></h4> <p class="js-bio"></p> <button class="easy-modal-close" title="close">&times;</button> </div> </div>

// , using in js

var modal = $('.js-modal'), modaltrigger = $('.js-modal-open'); modaltrigger.on('click', function(e){ e.preventdefault(); var t = $(this), url = t.data('image-url'), alt = t.data('image-alt'), title = t.data('title'), company = t.data('company'), bio = t.data('bio'); updatemodal(modal, url, alt, title, company, bio); // open modal here unless plugin using opens self? }); function updatemodal(elm, url, alt, title, company, bio) { elm.find('img').attr('src', url); elm.find('img').attr('alt', alt); elm.find('.js-title').text(title); elm.find('.js-company').text(company); elm.find('.js-bio').text(bio); }

wordpress modal-dialog advanced-custom-fields

ssdt - Register Data-Tier Application - "Database source is not a supported version of SQL Server" error -



ssdt - Register Data-Tier Application - "Database source is not a supported version of SQL Server" error -

i have sql server express 2014 database. in ssms, whenever effort register database data-tier application, receive error "database source not supported version of sql server (localdb)\projectsv12 (microsoft.sqlserver.dac)". how resolve?

tmi:

i have ssdt project attempting write conditional scripts based on database version. instance, lookup script might like:

declare @version_source varchar(100) = (select type_version msdb.dbo.sysdac_instances database_name = db_name()); if @version_source null begin set identity_insert instructor_title on; insert instructor_title (id, name, description) values (1, 'instructor', null), (2, 'assistant professor', null), (3, 'associate professor', null), (4, 'professor', null) ; set identity_insert instructor_title off; end

when publish, check "register data-tier application" , works fine. when start debugging (which deploys (localdb)\projectsv12), logic fails. sql server express database won't register data-tier application. results in variable @version_source returning null, script status true. realize write idempotent or database state conditional script instead, sense database version conditional script best architecture decision.

you seek checking box "allow incompatible platform" can find clicking on "advanced..." button on "debug" tab of "project properties".

the other thing is: target platform? drop-down list in "project settings" tab of "project properties"? should set sql server 2014. if sql server 2014 not alternative should latest version of ssdt (though sure create scheme restore point before installing reason latest version (as of few months ago) trashed visual studio, wouldn't compile stuff, , wouldn't uninstall easily; , tips on s.o. or anywhere else vs 2013 , have 2012).

sql-server ssdt

.net - I have a C# Windows Forms Application and I want the user to be able to schedule a recurring task -



.net - I have a C# Windows Forms Application and I want the user to be able to schedule a recurring task -

my application sends out email based on info entered form on ui. ui allows them "schedule" job. don't want utilize outside classes, e.g. quartz. don't want utilize task scheduler require rewriting app... understand can done timers, , have attempted utilize windows.forms.timer, however, not getting desired results. want run @ user specified interval , time, until set end date.

private void submit_btn_click(object sender, eventargs e) { bool run = false; location_alert_timer.tick += new eventhandler(location_alert_timer_tick); if (schedule_chk.checked == true) { run = true; if (recur_txt.text != "" || recur_txt.text != "0") { while (run == true) { if ((convert.todatetime(datetime.now.tostring("mm/dd/yyyy hh:mm")) <= convert.todatetime(end_date.value.tostring("mm/dd/yyyy") + " " + recur_time_txt.text))) { //execute_command(); datetime dt1; datetime dt2; timespan ts = new timespan(convert.toint16(recur_txt.text),0,0,0); //timespan ts = new timespan(0,0,30); dt1 = convert.todatetime(datetime.now.tostring("mm/dd/yyyy hh:mm")); dt2 = convert.todatetime(datetime.now.tostring("mm/dd/yyyy") + " " + recur_time_txt.text); if (dt1 >= dt2) { execute_command(); location_alert_timer.interval = (convert.todatetime(datetime.now.tostring("mm/dd/yyyy") + " " + recur_time_txt.text + ":00.000").add(ts) - datetime.now).milliseconds; location_alert_timer.start(); while (convert.todatetime(datetime.now.tostring("mm/dd/yyyy hh:mm")) <= convert.todatetime(end_date.value.tostring("mm/dd/yyyy") + " " + recur_time_txt.text)) { application.doevents(); } } else { location_alert_timer.interval = (convert.todatetime(datetime.now.tostring("mm/dd/yyyy") + " " + recur_time_txt.text + ":00.000") - datetime.now).milliseconds; location_alert_timer.start(); while (exitflag == false) { application.doevents(); } } } else { location_alert_timer.stop(); run = false; } } } else { execute_command(); } } else { execute_command(); } } void location_alert_timer_tick(object sender, eventargs e) { if (convert.todatetime(datetime.now.tostring("mm/dd/yyyy hh:mm")) <= convert.todatetime(end_date.value.tostring("mm/dd/yyyy") + " " + recur_time_txt.text)) { execute_command(); } else { exitflag = true; } }

my timer events not seem firing right , know because have set them incorrectly...

here form ui:

if has similar implementation in future, @itsmatt's explanation led me rewrite whole event, ground up...below final implementation, , works fantastically:

private void submit_btn_click(object sender, eventargs e) { bool run = false; if (schedule_chk.checked == true) { run = true; if (recur_txt.text != "" || recur_txt.text != "0") { while (run == true) { if ((convert.todatetime(datetime.now.tostring("mm/dd/yyyy hh:mm")) <= convert.todatetime(end_date.value.tostring("mm/dd/yyyy") + " " + recur_time_txt.text))) { datetime dt1; datetime dt2; timespan ts = new timespan(convert.toint16(recur_txt.text),0,0,0); dt1 = convert.todatetime(datetime.now.tostring("mm/dd/yyyy hh:mm")); dt2 = convert.todatetime(datetime.now.tostring("mm/dd/yyyy") + " " + recur_time_txt.text); if (dt1 >= dt2) { execute_command(); location_alert_timer.interval = convert.toint32((convert.todatetime(datetime.now.tostring("mm/dd/yyyy") + " " + recur_time_txt.text + ":00.000").add(ts) - datetime.now).totalmilliseconds); location_alert_timer.start(); timeractive = true; timerhold(); } else { location_alert_timer.interval = convert.toint32((convert.todatetime(datetime.now.tostring("mm/dd/yyyy") + " " + recur_time_txt.text + ":00.000") - datetime.now).totalmilliseconds); singleuse = true; location_alert_timer.start(); timeractive = true; timerhold(); messagebox.show(datetime.now.tostring()); messagebox.show(datetime.now.add(ts).tostring()); messagebox.show((convert.todatetime(datetime.now.add(ts).tostring()) - datetime.now).totalmilliseconds.tostring()); location_alert_timer.interval = convert.toint32((convert.todatetime(datetime.now.add(ts).tostring()) - datetime.now).totalmilliseconds); location_alert_timer.start(); timeractive = true; timerhold(); } } else { location_alert_timer.stop(); run = false; } } } } } public void timerhold() { while (timeractive) { application.doevents(); } } void location_alert_timer_tick(object sender, eventargs e) { if (singleuse) { if (uses < 1) { if (convert.todatetime(datetime.now.tostring("mm/dd/yyyy hh:mm")) <= convert.todatetime(end_date.value.tostring("mm/dd/yyyy") + " " + recur_time_txt.text)) { uses++; //doitonce(); execute_command(); } else { timeractive = false; } } else { singleuse = false; timeractive = false; location_alert_timer.stop(); } } else { if (convert.todatetime(datetime.now.tostring("mm/dd/yyyy hh:mm")) <= convert.todatetime(end_date.value.tostring("mm/dd/yyyy") + " " + recur_time_txt.text)) { //doit(); execute_command(); } else { timeractive = false; } } }

what using example?

a-simple-scheduler-in-csharp

c# .net winforms timer .net-3.5

php - Call to undefined function mb_detect_encoding() in....gets me crazy -



php - Call to undefined function mb_detect_encoding() in....gets me crazy -

i have loaded extensions...

extension=php_gettext.dll extension=php_mbstring.dll extension=php_exif.dll ; must after mbstring depends on extension=php_mysqli.dll

....in php.in file in of forums same error!!!

i have updated mysql5.5 & php 5.4

¿what else can solve problem?¿can help me?

i'm bit tired of trying thousands of possibilities , same message :)

thank you

php mysql phpmyadmin

android studio - Wich is the support library that I have to choose? -



android studio - Wich is the support library that I have to choose? -

my application has minsdk @ 15 , targetsdk @ 20. need back upwards library because application uses pageviewer view.

reading documentation read back upwards library vx designed used on api level x. think version's number x should between 15 , 20.

how should take number?

secondly, using android studio have add together next line in file named build.grandle, using back upwards library v4.

compile 'com.android.support:support-v4:20.0.0'

what meaning of suffix 20.0.0?

the back upwards libraries have different revisions/versions. can check more info here

adding part in gradle file:

compile 'com.android.support:support-v4:20.0.0'

you telling gradle support-library-v4 revision 20.0.0.

about version should use. if compiling api20, can utilize revision 20.

android-studio android-support-library

adding a new column after performig subtraction and division between two columns in R -



adding a new column after performig subtraction and division between two columns in R -

i have info set :

dataset a,

id bidding_price sale_price 10 74.88 67.27 11 23.1 18.14 12 62.5 56.14 13 34.5 27.09 14 55.32 49.69 15 900 706.77 16 260.84 260.84

i add together column diff performing next operation

diff =(bidding_price-sale_price)/(sale_price*100%)

and output should this:

id bidding_price sale_price diff 10 74.88 67.27 0.113126208 11 23.1 18.14 0.273428886 12 62.5 56.14 0.113288208 13 34.5 27.09 0.273532669 14 55.32 49.69 0.113302475 15 900 706.77 0.273398701 16 260.84 260.84 0.00

any help on appreciated.

use awesome dplyr package

library(dplyr) df <- data.frame("id"=c(1, 2, 3), "bidding_price"=c(10,11,12), "sale_price"=c(9,10,11)) df <- mutate(df, diff=(bidding_price - sale_price)/sale_price)

the output is

id bidding_price sale_price diff 1 1 10 9 0.11111111 2 2 11 10 0.10000000 3 3 12 11 0.09090909

r

php - how to use a specific UPDATE query if existing row is empty mysql -



php - how to use a specific UPDATE query if existing row is empty mysql -

i have searched far , wide specific case reply have seems me should work. doesn't.

i want concatenate info row in database. set if there no existing info injects filenames variable row.

if there existing info in row need append "," start can break filenames out later php on page.

here's have doesn't seem work.

$query = "update plan set plan_files = if(plan_files null,concat(plan_files, '{$filenames}'),concat(plan_files, ',{$filenames}')) plan_id='{$planid}'";

try this

$query = "update plan set plan_files = (case when plan_files null '".$filenames."' else concat(plan_files , ',".$filenames."') end ) plan_id =". $planid;

please create sure $filenames string , $planid int.

php mysql