Tuesday 15 July 2014

Node.js server is breaking without any error -



Node.js server is breaking without any error -

i using border module (https://github.com/tjanczuk/edge) read sql database. function follows:

function getbetweenrows(cb) { //console.log("lastcheckedid within function ", lastcheckedid); //console.log("lastinsertid within function ", lastinsertid); console.log("here 2"); var query = { connectionstring: "data source=localhost;initial catalog=db-name;integrated security=true", //source: "select * customermaster customerid between '" + lastcheckedid + "' , '" + lastinsertid + "';" source: "select * customermaster customerid between '2965' , '2972';" }; console.log("query ", query.source); console.log("here 3"); var getrows = edge.func('sql', query); console.log("here 4"); getrows(null, function(error, result) { console.log("here 5"); if (error) { console.log(error); throw error; log.error({rows:error}); } rows = result; log.info({rows:rows}); console.log(rows); console.log("here 6"); cb(rows); }); }

funny thing code working on other systems. on particular system, prints till here 4 , server breaks. doesn't show error whatsoever. how find out what's problem?

sorry, don't know posted happening diferently on diferent systems if want debug , find step step diferences on 2 systems, utilize node debugger:

http://nodejs.org/api/debugger.html

it's worth getting know.

also, have noticed occasional issues cannot yet explain, when throwing errors. seek commenting out throw line on offending scheme (an maybe log.js phone call well.) if fixes issue, know errors.

let me know find.

node.js

c++ - Would std::count_if be faster without an if? -



c++ - Would std::count_if be faster without an if? -

here's gcc std::count_if code

template<typename _inputiterator, typename _predicate> typename iterator_traits<_inputiterator>::difference_type count_if(_inputiterator __first, _inputiterator __last, _predicate __pred) { [snip] typename iterator_traits<_inputiterator>::difference_type __n = 0; (; __first != __last; ++__first) if (__pred(*__first)) ++__n; homecoming __n; }

my question: work improve (i.e., faster) use

__n += __pred(*__first); // instead of if statement

this version add, doesn't branch.

the replacement gave is not equivalent, because there far fewer restrictions on predicate think:

anything can used in conditional context (can contextually converted bool), valid return-type predicate (an explicit conversion bool enough). that return-type can react funny beingness added iterators difference-type. 25 algorithms library [algorithms] 25.1 general [algorithms.general]

8 predicate parameter used whenever algorithm expects function object (20.9) that, when applied result of dereferencing corresponding iterator, returns value testable true. in other words, if algorithm takes predicate pred argument , first iterator argument, should work correctly in build pred(*first) contextually converted bool (clause 4). function object pred shall not apply non-constant function through dereferenced iterator.

the homecoming giving replacement indigestion standard integer-type, , value neither 0 nor 1.

also, maintain in mind compilers can optimize nowadays (and c++ ones need to, template-stuff layered deep).

c++ performance gcc stl

performance - JMS queue consumer: synchronous receive() or single-threaded onMessage() -



performance - JMS queue consumer: synchronous receive() or single-threaded onMessage() -

i need consume q, , stamp sequence key on each message indicate ordering. i.e. consumption needs sequential. performance/throughput point of view, improve off using blocking receive() method, or async listener single-threaded configuration on onmessage() method?

thanks.

there many aspects impact performance , throughput; in pure jms terms it's not possible state sync or async model of getting messages less or more efficient. depend on big number of factors how application written, other resources it's using, implementation of chosen messaging provider , other factors such machine performance , configuration of both client , server machines.

this discussion, single vs multi-threaded jms producer, covered of these topics.

to sequence, if single threaded, single session jms specification gives assurances on message ordering; best review spec see if matches overall requirements.

often people insert application sequence number @ message production time; consumer can hence check getting right message in order. adding sequence number @ consumption time won't help consumer.

keep in mind stricter requirement messaging ordering more restrictive overall architecture gets , harder implement horizontal scalabilty.

performance queue order jms consumer

Installing New Relic .NET Agent in an Azure Web Role -



Installing New Relic .NET Agent in an Azure Web Role -

i configured free standard version of new relic in azure portal in add-ons section. created new web role , i'm deploying asp.net application web role. added newrelicwindowsazure bundle nuget. re-deployed web application , i'm getting nil registering in new relic command panel.

i believe issue not having agent installed on machines when new total installation. when rdp instance , install agent seems work fine.

how can shoehorn installation deployment? see nuget bundle added newrelic.cmd in root of web app, tried add together azure cloud service project in servicedefinition.csdef file so:

<startup> <task commandline="newrelic.cmd" executioncontext="elevated" /> </startup>

it seems installing -something-, looks new relic server agent installed not started, , don't see base of operations apm agent. how can automate installation successfully?

here answer. had apply more settings task:

<task commandline="newrelic.cmd" executioncontext="elevated" tasktype="simple"> <environment> <variable name="emulated"> <roleinstancevalue xpath="/roleenvironment/deployment/@emulated" /> </variable> <variable name="isworkerrole" value="false" /> <variable name="license_key"> <roleinstancevalue xpath="/roleenvironment/currentinstance/configurationsettings/configurationsetting[@name='newrelic.licensekey']/@value" /> </variable> </environment> </task>

azure azure-web-roles newrelic

java - JDBC insert error -



java - JDBC insert error -

i trying insert info database jdbc. using right table, db name, , parameters. checked.

code

public static void main(string[] args) throws ioexception/*, classnotfoundexception, sqlexception*/ { datainputstream d = new datainputstream(system.in); system.out.println("enter employee id : "); @suppresswarnings("deprecation") int empid = integer.parseint(d.readline()); system.out.println("enter employee name : "); @suppresswarnings("deprecation") string empname = d.readline(); system.out.println("enter employee id : "); @suppresswarnings("deprecation") double empsalary = double.parsedouble(d.readline()); seek { class.forname("com.mysql.jdbc.driver"); } grab (classnotfoundexception e) { e.printstacktrace(); } connection con; seek { con = drivermanager.getconnection("jdbc:mysql://localhost:3306/testdb","root",""); preparedstatement pst = con.preparestatement("insert `employee` values(?,?,?"); pst.setint(1, empid); pst.setstring(2, empname); pst.setdouble(3, empsalary); int rowcount = pst.executeupdate(); system.out.println(rowcount + " row has been instered"); } grab (sqlexception e) { e.printstacktrace(); }

and here errors gives me when seek run it:

com.mysql.jdbc.exceptions.mysqlsyntaxerrorexception: have error in sql syntax; check manual corresponds mysql server version right syntax utilize near '' @ line 1 @ com.mysql.jdbc.sqlerror.createsqlexception(sqlerror.java:936) @ com.mysql.jdbc.mysqlio.checkerrorpacket(mysqlio.java:2985) @ com.mysql.jdbc.mysqlio.sendcommand(mysqlio.java:1631) @ com.mysql.jdbc.mysqlio.sqlquerydirect(mysqlio.java:1723) @ com.mysql.jdbc.connection.execsql(connection.java:3283) @ com.mysql.jdbc.preparedstatement.executeinternal(preparedstatement.java:1332) @ com.mysql.jdbc.preparedstatement.executeupdate(preparedstatement.java:1604) @ com.mysql.jdbc.preparedstatement.executeupdate(preparedstatement.java:1519) @ com.mysql.jdbc.preparedstatement.executeupdate(preparedstatement.java:1504) @ com.test.jdbcexample.main(jdbcexample.java:47)

you have syntax error in line:

preparedstatement pst = con.preparestatement("insert `employee` values(?,?,?");

you missing closing parenthesis values clause.

java mysql sql jdbc insert

c++ - distinguish 2 keyboards keystrokes using eventfilter (embedded linux) -



c++ - distinguish 2 keyboards keystrokes using eventfilter (embedded linux) -

i know there has been few topics similar one, don't inquire same question , answers not need. seek explain briefly situation.

i have 2 keyboards, 1 standard usb keyboard (hid), other gpio keyboard. there keys commonly reported both keyboards need take different actions in qt application depending on keyboard key pressed.

at moment both keyboards work fine @ same time, can't find way identify keyboard comes pressed key.

is possible? i'm, using qt 4.8.5 , can recompile in case needed accomplish need.

any help, hint, tip highly appreciated.

thank help,

william

qt not have feature observe keyboard pressed. should utilize linux event interface distinguish between 2 inputs. when input available 1 of hardwares, can access reading character devices under /dev/input/ directory. instance have file /dev/input/by-id/usb-0b38_0010-event-kbd read see input specific keyboard.

you can read specific files 2 keyboards in 2 separate threads , each time read new info 1 of them, send signal main thread notify input of keyboards :

in first thread :

qfile file("/dev/input/by-id/fileforkeyboard1"); if(file.open( qiodevice::readonly | qiodevice::text ) ) { qtextstream stream( &file ); while(true) { stream.read(1); emit keyboard1_pressed(); } }

in sec thread :

qfile file("/dev/input/by-id/fileforkeyboard2"); if(file.open( qiodevice::readonly | qiodevice::text ) ) { qtextstream stream( &file ); while(true) { stream.read(1); emit keyboard2_pressed(); } }

note should have root access read these files.

c++ linux qt keyboard keystrokes

android - graphview unable to zoom -



android - graphview unable to zoom -

following simple sine wave graph display. want zoom in , out using pinch zoom gesture.

info = new graphviewdata[num]; double v=0; (int i=0; i<num; i++) { v = 2*math.pi*30*i; data[i] = new graphviewdata(i, math.sin(v/num)); } graphview = new linegraphview(this, "graphviewdemo"); // add together info graphview.addseries(new graphviewseries(data)); // set view port, here num = 256 graphview.setviewport(0, num-1); graphview.setscrollable(true); linearlayout layout = (linearlayout) findviewbyid(r.id.graph1); layout.addview(graphview);

is there property enabled utilize zoom feature, or should implement setviewport() manually , handle zoom feature?

graphview.setscalable(true);

add line zooming graph.

android android-graphview

sql - Arithmetic overflow error converting datetime's -



sql - Arithmetic overflow error converting datetime's -

i have table stores date info in nvarchar in format of (dd/mm/yyyy),when convert column datetime using convert(nvarchar(100), dt, 101) doesn’t have issue ,however when want select top x rows ,i got next error:

msg 8115, level 16, state 2,arithmetic overflow error converting look info type datetime.

the next sample of code:

declare @d nvarchar(100); set @d='20/11/2012' select top 1 @d, (select date_diff = datediff( day, cast(convert(nvarchar(100), @d, 101) datetime), '2014-10-01 00:00:00')) d

it's sql interpreting first date time 11th day of 20th month in year 2012.

try in 1 of sql's preferred date formats.

my preferred format dd-mmm-yyyy because never ambiguous:

declare @d nvarchar(100); set @d='20-nov-2012' select top 1 @d, (select date_diff = datediff( day, cast(convert(nvarchar(100), @d, 101) datetime), '01-oct-2014 00:00:00')) d

sql picks date format based on language.

you can explicit , tell utilize dmy format in query so:

set dateformat 'dmy'

based on comments below inferring sort of query:

--pretending table in database varchar dates :( create table #test (dt varchar(100)) insert #test values ('20/11/2012') set dateformat 'dmy' --works --set dateformat 'mdy' --doesn't work select top 1 dt, (select date_diff = datediff( day, cast(convert(nvarchar(100), dt, 101) datetime), '2014-10-01 00:00:00')) d #test drop table #test

but in case selecting varchar date table, setting date format correct's issue. seek testing differing dateformats.

sql sql-server

php - Handling files for multiple users at once (logistic prob) -



php - Handling files for multiple users at once (logistic prob) -

hey app creates files on server shown users right away in html element called iframe. far have been storing files same folder, overwriting old ones each time user requested new one. problem if more 1 user tried generate file @ once, 1 of them might not right file, or no file @ all. guess should create random temp folder each generation of files. work, server might filled in 100 generations of files. need delete random temp folder 1 time user done loading file in iframe, how phone call php function on load? other alternative method/idea, help me alot. how others handle such problems?

i create 1 single temp folder, , generate random file names (md5, guid, don't matter). same script generate file on folder visualization, before generation itself, should check files on folder, excluding files generated >= 1 day ago. check filemtime function , this question if have doubts how file creation/modification date.

php html pdf iframe user

c# - multithreaded unit test - notify calling thread of event to stop sleeping -



c# - multithreaded unit test - notify calling thread of event to stop sleeping -

i wrote test (nunit) test amazon ses email sending functionality should generate bounce notification in amazon sqs queue. poll queue in loop 1 min on new thread wait , verify bounce notification.

i'd increment time few minutes ensure dont miss it. response may come within seconds in case i'd want record how long took , finish test there no point go on waiting 1 time receipt verified.

how can accomplish threading scenario in clean way, , mean without polluting methodinmainapp() test code. in main app should not happen (it should go on polling indefinitely), should stop in test. should pass in threadstart function both entry points doesnt reply question im asking.

[test] public async void sendandlogbounceemailnotification() { thread bouncesthread = startup.methodinmainapp(); bouncesthread.start(); bool success = await _emailservice.sendasync(...); assert.areequal(success, true); //sleep thread 1 min while //bouncesthread polls bounce notifications thread.sleep(60000); } public static thread methodinmainapp() { ... thread bouncesthread = new thread(() => { while (true) { receivemessageresponse receivemessageresponse = sqsbouncesclient.receivemessage(bouncesqueuerequest); if(receivemessageresponse.messages.count > 0) { processqueuedbounce(receivemessageresponse); //done test } } }); bouncesthread.setapartmentstate(apartmentstate.sta); homecoming bouncesthread; }

use monitor class.

instead of thread.sleep(60000), utilize this:

lock (_lockobject) { monitor.wait(_lockobject, 60000); }

then want signal thread continue:

lock (_lockobject) { monitor.pulse(_lockobject); }

of course of study requires adding static readonly object _lockobject = new object() somewhere in class.

i'm not saying overall strategy right approach. seems here, improve unit test method explicitly phone call other method doing work wait , validate response. above should address specific question.

c# multithreading unit-testing nunit

angularjs - Is there a way to make Webstorm beta 9 do live expression updates in angular? -



angularjs - Is there a way to make Webstorm beta 9 do live expression updates in angular? -

i can debug angularjs app chrome , when alter text in

tag illustration text changes type it. however, if have look {{1+1}} , alter {{1+2}} see raw look , not evaluated one.

is i'm doing wrong or webstorm not back upwards it.

**edit: create short video show mean https://www.dropbox.com/s/2wnu969hi1ykxv0/webstorm9angularlive.mp4?dl=0

known issue, please follow web-6471 updates

angularjs webstorm

How to handle NotificationBar in android -



How to handle NotificationBar in android -

i tried code form reply of question: how set media controller button on notification bar?

by calling

shownotification()

method app gets closed. how prevent this? , how can handle method called if mobile phone api >= 16. because think available since api 16.

i've read, there solution lower api:

import android.support.v4.app.notificationcompat;

but didn't got working, wanted prevent calling it.

and can delete notification bar, ondestroy() of app?

the code on page hard case using remoteviews, , looks dubious anyway. (e.g. creates subclass of notification constructor creates notification.)

the normal approach utilize notificationcompat.builder build notification, , notificationmanager or notificationmanagercompat show , cancel it. see notifications api guide details , illustration code.

also see notifying user documentation , notifications design guide.

generally, app should show notification when activity not visible. when user taps on notification, should open activity should in turn cancel notification.

android android-notifications android-notification-bar

matlab - Unconstrained nonlinear optimization function -



matlab - Unconstrained nonlinear optimization function -

i want optimize unconstrained multivariable problem using fminunc function in matlab. here example:

minimize function f(w)=x'ax

create file myfun.m:

function f = myfun(x) f = x'*a*x + b'x

then phone call fminunc find minimum of myfun near x0:

[x,fval] = fminunc(@myfun,x0).

my problem in algorithm, matrix a , vector b in myfun.m not fixed, can changed on loops, cannot type them hand. how can pass values a , b?

there few options passing additional arguments objective function. simple 1 yours, create anonymous function, save values of a , b when created:

a = mymata(); b = myvecb(); myfun = @(x) x.'*a*x + b.'*x; [x,fval] = fminunc(myfun,x0); % utilize no @ anonymous function

the other 2 options global variables (yuck!) , nested functions. nested function version looks this:

function [x,fval] = myopt(a,b,x0) [x,fval] = fminunc(@myfunnested,x0); function y = myfunnested(x) y = x.'*a*x + b.'*x; end end

but think not utilize fminunc solve minimization of x'ax + b'x...

matlab

javascript - paste data from clipboard using document.execCommand("paste"); within firefox extension -



javascript - paste data from clipboard using document.execCommand("paste"); within firefox extension -

i trying paste clipboard info variable gets fed , fired via xmlhttprequest post message.

i have created firefox user.js code increment access clipboard based on recommendation.

user_pref("capability.policy.policynames", "allowclipboard"); user_pref("capability.policy.allowclipboard.sites", "mydomain"); user_pref("capability.policy.allowclipboard.clipboard.cutcopy", "allaccess"); user_pref("capability.policy.allowclipboard.clipboard.paste", "allaccess");

do need alter "mydomain" in line two? not want sites have access. internal firefox extension.

i have read several guides here , here mozilla.

here code have far. clipboard contents should sent post method via xmlhttprequest. xmlhttprequest works, have been using other variables.

var pastetext = document.execcommand('paste'); var req = new xmlhttprequest(); req.open('post', pastetext, true); req.onreadystatechange = function(aevt) { if (req.readystate == 4) { if (req.status == 200) dump(req.responsetext); else dump("error loading page\n"); } }; req.send(null);

i grateful help. give thanks you

what need not execcommand need read info clipboard. addon in privelaged scope don't need worry preferences. (user.js firefox-addon right?)

see here:

mdn :: using clipboard mdn :: nsiclipboard

this way can read contents var pastedcontents.

here illustration above worked in:

var trans = cc["@mozilla.org/widget/transferable;1"].createinstance(ci.nsitransferable); trans.adddataflavor("text/unicode"); services.clipboard.getdata(trans, services.clipboard.kglobalclipboard); var pastetextnsisupports = {}; var pastetextnsisupportslength = {}; trans.gettransferdata("text/unicode", pastetextnsisupports, pastetextnsisupportslength); var pastetext = pastetextnsisupports.value.queryinterface(ci.nsisupportsstring).data; var req = new xmlhttprequest(); req.open('post', pastetext, true); req.onreadystatechange = function(aevt) { if (req.readystate == 4) { if (req.status == 200) dump(req.responsetext); else dump("error loading page\n"); } }; req.send(null);

javascript firefox firefox-addon clipboard clipboarddata

php - mysql create dynamic tables -



php - mysql create dynamic tables -

i trying create table dynamically , problem facing creating columns dynamically. mean won't have fixed number of columns tried representing variable when run code gives me error. below tried.

the error

you have error in sql syntax; check manual corresponds your... $colarray = array(); foreach($ml $df){ $colarray[] = "`".$df."` varchar(250) not null,<br/>"; } $columns = implode("",$colarray); $sql = "create table if not exists {$table_name}( id int not null auto_increment, username varchar(250) not null, {$columns} date varchar(250) not null, primary key (id) )"; $stmt = $db->prepare($sql); echo $db->error; $stmt->execute();

this should work:

$colarray = array(); // since want these 2 columns in order // assign here $colarray[] = "id int not null auto_increment"; $colarray[] = "username varchar(250) not null"; foreach($ml $df) { $colarray[] = "`".$df."` varchar(250) not null"; } // since want column last, assign here $colarray[] = "date varchar(250) not null"; $columns = implode(",\r\n",$colarray); $sql = "create table if not exists {$table_name}( {$columns}, primary key (id))"; $stmt = $db->prepare($sql); echo $db->error; $stmt->execute();

php mysql

Cannot play video in TextureView Android -



Cannot play video in TextureView Android -

i have problem playing video on devices. using textureview mediaplayer, every methods of surfacetextureview called when phone call mediaplayer.start(), listener completition of playing called. in log error:

e/mediaplayer﹕ error (1, -2147483648)

when list log applications, can see errors , dont know if somehow related http://pastebin.com/rrxxqgdj

this log cyanogenmod android 4.3.1 on other devices samsung galaxy s3 mini error happening.

on nexus 4 works fine. i've tried convert video mp4 codec android h.264 , ffmpeg result still same. using texturevideoview implementation here: https://github.com/dmytrodanylyk/video-crop/blob/master/library/src/com/dd/crop/texturevideoview.java

thanks advice

as pointed out here may due fact video encoding parameters (profile, level, pixel format, etc.) not supported on platform, seek playing around source.

android video ffmpeg android-mediaplayer textureview

ios - Custom UIView drawing with layoutSubviews vs drawRect -



ios - Custom UIView drawing with layoutSubviews vs drawRect -

should drawing of cashapelayers called drawrect() or layoutsubviews()?

according apple's documentation on uiviews, drawing operations should placed in drawrect().

however not case in kevin cathey's wwdc session: what's new in interface builder (where demonstrates process of building custom uiview accessible in interface builder).

during demonstration performs drawing of view in layoutsubviews, rather drawrect.

his explanation that:

if implement drawrect, that's not going best performance; whereas, using sublayers , subviews going performance.

from i've read far on stackoverflow, seems overriding drawrect() method can cause reduced performance. partially due setneedsdisplay triggering manual redraws beingness expensive.

but looking through apple documentation , real world applications. makes sense drawrect() should responsible drawing of view, , layoutsubviews() handling positioning.

i depends. if size of shape going dependent on auto layout scheme might beneficial drawing in layout subview versus draw rect.

first, why layout subviews ever have improve performance? have uiview (my parent view) drawing circle view (my subview) using shape layer. size of circle determined width , height constraint in parent view. ever need redraw circle when either width/height constraints changed on parent view. instance beneficial have drawing code in layout subviews because ever need redraw shape layer when constraints change. let's see auto layout cycle

update constraints layout subviews render views

by time layout subviews called know size of frame working , can safely perform our drawing. know documentation says should utilize method set frame, bounds, etc. however, drawing within frame doesn't sound unreasonable depending on circumstances.

if circle view isn't dependent upon auto layout scheme , changed @ anytime regardless of layout of ui, more beneficial have drawing in draw rect can updated. think less ideal situation more ui's in ios conform using auto layout, hence recommendation of using layout subviews.

ios uiview

ios - Create view hierarchy programmatically with Auto Layout -



ios - Create view hierarchy programmatically with Auto Layout -

i want create view hierarchy programmatically using auto layout hierarchy has next structure: uiview -> uiwebview want leave space uitoolbar @ bottom of uiview.

the result should in xib file:

code far:

- (void)loadview { uiview *view = [[uiview alloc] initwithframe:[[uiscreen mainscreen] bounds]]; self.view = view; self.webview = [[uiwebview alloc] init]; self.webview.scalespagetofit = yes; [self.view addsubview:self.webview]; self.view.translatesautoresizingmaskintoconstraints = no; self.webview.translatesautoresizingmaskintoconstraints = no; nsdictionary *namemap = @{@"webview" : self.webview}; nsarray *c1array = [nslayoutconstraint constraintswithvisualformat:@"h:|-0-[webview]-0-|" options:0 metrics:nil views:namemap]; nsarray *c2array = [nslayoutconstraint constraintswithvisualformat:@"v:|-0-[webview]-45-|" options:0 metrics:nil views:namemap]; [self.view addconstraints:c1array]; [self.view addconstraints:c2array]; }

when trace using:

po [[uiwindow keywindow] _autolayouttrace]

i both uiview , uiwebview have ambiguous layout.

what problem approach?

you shouldn't set translatesautoresizingmaskintoconstraints no controller's self.view. if remove line, constraints have should adequate. btw, there's no need zeros in format string (although don't wound either),

this "h:|[webview]|" equivalent "h:|-0-[webview]-0-|".

ios objective-c autolayout

asynchronous - swift xml rss reader... make it async -



asynchronous - swift xml rss reader... make it async -

hi i'm trying work on simple exercise. made basic xml rss reader, works fine love improve , worry async loading. how should do?

import uikit class viewcontroller: uitableviewcontroller, nsxmlparserdelegate, uitableviewdelegate { allow urlstring = "http://www.nasa.gov/rss/dyn/breaking_news.rss" var element:nsstring = "" var items:[string] = [] var item = "" override func viewdidload() { super.viewdidload() // dispatch_queue_t myqueue = dispatch_queue_create("queue",null) loadparser() } //mark - tableviewdelegate override func numberofsectionsintableview(tableview: uitableview) -> int { homecoming 1 } override func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int { homecoming items.count } override func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { allow cell = tableview.dequeuereusablecellwithidentifier("cell", forindexpath: indexpath) uitableviewcell cell.textlabel.text = items[indexpath.row] homecoming cell } //mark - parser func loadparser(){ allow url = nsurl(string: urlstring) var parser = nsxmlparser(contentsofurl: url) parser?.delegate = self parser?.shouldprocessnamespaces = true parser?.shouldreportnamespaceprefixes = true parser?.shouldresolveexternalentities = true parser?.parse() } //mark: - parser delegate func parser(parser: nsxmlparser!, didstartelement elementname: string!, namespaceuri: string!, qualifiedname qname: string!, attributes attributedict: [nsobject : anyobject]!) { element = elementname if ((elementname nsstring).isequaltostring("item")){ item = "" } } func parser(parser: nsxmlparser!, didendelement elementname: string!, namespaceuri: string!, qualifiedname qname: string!) { if ((elementname nsstring).isequaltostring("item")){ items.append(item) } } func parser(parser: nsxmlparser!, foundcharacters string: string!) { if ( (element.isequaltostring("title")) && (element != "") ){ item += string } } func parserdidenddocument(parser: nsxmlparser!) { println(items) self.tableview.reloaddata() } }

i not sure how do. i'm trying wrap "loadparser" in dispatch queue in swift it's not working. can guys tell me how using gcd ? thanks

what about:

dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_default, 0), ^{ loadparser(); });

this should same original objective-c solution

swift asynchronous

c# - Mailchimp.Net api code is giving exception when adding interest group -



c# - Mailchimp.Net api code is giving exception when adding interest group -

i using mailchimp.net in asp.net c# web application.

i trying add together involvement grouping using next code:

mailchimp.mailchimpmanager mailchimpmanager = new mailchimp.mailchimpmanager("xxxxxxxxxxxx-us9"); if (session["listid"] != null) { string listid = session["listid"].tostring(); list<interestgrouping.innergroup> innergroup = new list<interestgrouping.innergroup>(); innergroup.add(new interestgrouping.innergroup() { name = "students", bit = 1, displayorder = 1, subscribers = 0 }); mailchimpmanager.addlistinterestgrouping(listid, this.textboxnewgroup.text, "radio", innergroup); }

but addlistinterestgrouping method giving next exception:

mailchimp.errors.mailchimpapiexception: backend database error has occurred. please seek 1 time again later or study issue.

internal excpetion is:

the remote server returned error: (500) internal server error.

i not getting why issue occurring, other methods of api working. has faced before or study author ? please help.

c# asp.net mailchimp

ios - Testflight Profile Installation Failed, the SCEP server return an invalid response -



ios - Testflight Profile Installation Failed, the SCEP server return an invalid response -

one of user having problem installing testflight app (not apple's testflight).

he encountered error: "profile installation failed, scep server homecoming invalid response."

i advise him follow steps listed here: http://help.testflightapp.com/customer/portal/articles/402816-registration-issues

he told me has no profile installed in profiles , after next steps, still encounter same error.

i @ lost , advise appreciated.

i got testers past scep error. works too.

workaround:

open ios settings app, select safari tap on "clear history , website data" open safari app , go testflightapp.com log testflight account on "connect device installing profile" screen, tap greenish button "connect device" tap "install" on "install profile" screen if have unlock passcode on device, may prompted come in it when scep error comes up, tap "ok" tap "cancel" on "install profile" screen you should redirected testflight in safari "device connected!" message

ios iphone testflight

excel vba - How do I make this VBA loop run faster? -



excel vba - How do I make this VBA loop run faster? -

this loop written excel takes ranges of 2 unique lists , searches them in table on different sheet. 2 column search, 2 values list must appear in row accumulator count. works fine when parse lots of info can waiting minutes on end. looking way create loop much faster. help appreciated. in advance.

sub parsetwo(byval startrng range, byval findrng range, _ byval pastestartrng range, byval strtitle string, byval findtablecolumn string, _ byval startoffset integer, byval handledoffset integer, _ byval handledbool boolean) '========================================================================== '========================================================================== 'turn off excel functionality code runs faster application.screenupdating = false application.displaystatusbar = false application.calculation = xlcalculationmanual application.enableevents = false '========================================================================== '========================================================================== dim x long 'declare accumulator. x = 0 'give x default value. '========================================================================== '========================================================================== dim firstloop boolean 'declare boolean value. firstloop = true 'declare initial value of boolean true. '========================================================================== '========================================================================== dim pastefindrng range 'set paste range "find" items. set pastefindrng = pastestartrng.offset(1, -1 dim pasteaccum range 'set paste range "accumulator". set pasteaccum = pastestartrng.offset(1, 0) '========================================================================== '========================================================================== dim initialfindrng range 'keep track of initial "find" range reference later. set initialfindrng = findrng '========================================================================== '========================================================================== while startrng.text <> vbnullstring 'do while there info in "start" range. while findrng.text <> vbnullstring 'do while there info in "find" range. worksheets("formatting").range("formattingtable[" & findtablecolumn & "]") set c = .find(findrng.text, lookin:=xlvalues, lookat:=xlwhole) firstaddress = c.address if handledbool = true if c.offset(0, handledoffset).text <> vbnullstring if c.offset(0, startoffset).text = startrng.text x = x + 1 end if end if else if c.offset(0, startoffset).text = startrng.text x = x + 1 end if end if set c = .findnext(c) loop while not c nil , c.address <> firstaddress end '========================================================================== '========================================================================== if firstloop = true 'if first time through loop paste find items pastefindrng.value = findrng.text set pastefindrng = pastefindrng.offset(1, 0) 'set pastefind range downwards 1 end if '========================================================================== pasteaccum.value = x 'set x paste. set pasteaccum = pasteaccum.offset(1, 0) 'set accumulator paste range downwards 1. x = 0 'reset x '========================================================================== set findrng = findrng.offset(1, 0) 'set find range downwards 1. '========================================================================== loop if firstloop = true 'if first time through loop paste title. pastestartrng.offset(0, -1) = strtitle end '========================================================================== pastestartrng.value = startrng.text 'paste value of start range. '========================================================================== set pastestartrng = pastestartrng.offset(0, 1) 'set paste start range on right 1. '========================================================================== set pasteaccum = pastestartrng.offset(1, 0) 'reset "accumulator" paste range. '========================================================================== set startrng = startrng.offset(1, 0) 'move "start" range downwards 1. set findrng = initialfindrng 'reset "find" range. '========================================================================== firstloop = false loop '======================================================================================== application.screenupdating = true application.displaystatusbar = true application.calculation = xlcalculationautomatic application.enableevents = true end sub

as tip, seek create variable with

range("formattingtable[" & findtablecolumn & "]")

value , avoid within loop. or improve replace:

worksheets("formatting").range("formattingtable[" & findtablecolumn & "]")

by range value within loop.

excel-vba nested-loops

grails - PostgreSQL Exception: “An I/O error occured while sending to the backend” -



grails - PostgreSQL Exception: “An I/O error occured while sending to the backend” -

i run 2 web app in machine , 1 db in machine.(they utilize same db) 1 can run well,but 1 downwards after 4 hours.

here error information:

error 2014-11-03 13:31:05,902 [http-bio-8080-exec-7] error spi.sqlexceptionhelper - i/o error occured while sending backend. | error 2014-11-03 13:31:05,904 [http-bio-8080-exec-7] error spi.sqlexceptionhelper - connection has been closed.

postgresql logs:

2014-10-26 23:41:31 cdt warning: pgstat wait timeout 2014-10-27 01:13:48 cdt warning: pgstat wait timeout 2014-10-27 03:55:46 cdt log: not receive info client: connection timed out 2014-10-27 03:55:46 cdt log: unexpected eof on client connection

who caused problem, app or database? or net?

reason:

at point clear tcp connection sitting idle broken, our app still assumed open. idle connections, mean connections in pool aren’t in active utilize @ moment application.

after search, came conclusion network firewall between app , database dropping idle/stale connections after 1 hour. seemed mutual problem many people have faced.

solution:

in grails, can set in datasource.groovy.

environments { development { datasource { //configure dbcp properties { maxactive = 50 maxidle = 25 minidle = 1 initialsize = 1 minevictableidletimemillis = 60000 timebetweenevictionrunsmillis = 60000 numtestsperevictionrun = 3 maxwait = 10000 testonborrow = true testwhileidle = true testonreturn = false validationquery = "select 1" } } } }

postgresql grails

java - Localizing numeric values in excel -



java - Localizing numeric values in excel -

bigdecimal mynumber = new bigdecimal(1234.56); numberformat instance = numberformat.getinstance(locale.german); string localizednumber = instance.format(mynumber); system.out.print("\nformatting " + localizednumber); o/p ->1.234,56

till here code works fine below line gives numberformatter exception given string contains comma in it.

bigdecimal bigdecimal = new bigdecimal(localizednumber);

i want numeric values localized cannot homecoming string putting number string shows below error in excel number in cell formatter text or preceded apostrophe

is there way can homecoming numeric value(bigdecimal / integer / biginteger etc) in localized format won't above error in excel , can perform filter operations on excel data.

i've tried new bigdecimaltype().valuetostring(value, locale); , new bigdecimaltype().stringtovalue(s, locale); of dynamic jasper reports api.

happy reply question asked me , quite surprised no 1 replied this. don't have number localization in excel export because it's done our operating scheme settings automatically.

go "region , language" -> format -> select language/country name -> apply , check excel before generated in english.

you see numbers in selected country's number format. :)

java excel dynamic-jasper

c# - Razor server side code block and Jquery -



c# - Razor server side code block and Jquery -

my application mvc5 c#, trying execute following:

@{ var s = model.physicalexam; if (s == null) { <script> alert("1"); $("#newsale1").hide(); </script> } else { <script> alert("2"); $("#newsale1").show(); </script> } }

alert works, not hide or show button. appreciate suggestions.

i guess newsale1 maybe isn't loaded in dom when script code executed. should set blocks within document ready event.

$( document ).ready(function() { console.log( "ready!" ); });

c# jquery asp.net-mvc razor

cordova - The crosswalk build for Android failed (XDK-app-Build) -



cordova - The crosswalk build for Android failed (XDK-app-Build) -

i build app yesterday. today cannot , don't know problem is...

the error is:

an error occurred while building application. verify build assets right , seek again.

build log:

the app id "com.my.app" app name "app" crosswalk version: stable (7.36.154.14) plugin installed: file (org.apache.cordova.file) plugin installed: pushwoosh (https://github.com/pushwoosh/pushwoosh- ... plugin.git) plugin installed: myadmob (https://github.com/floatinghotpot/cordo ... -admob.git) plugin installed: mylocalnotification (de.appplant.cordova.plugin.local-notification) plugin installed: accelerometer (org.apache.cordova.device-motion) plugin installed: photographic camera (org.apache.cordova.camera) plugin installed: capture (org.apache.cordova.media-capture) plugin installed: compass (org.apache.cordova.device-orientation) plugin installed: connection (org.apache.cordova.network-information) plugin installed: contacts (org.apache.cordova.contacts) plugin installed: device (org.apache.cordova.device) plugin installed: events (battery status) (org.apache.cordova.battery-status) plugin installed: geolocation (org.apache.cordova.geolocation) plugin installed: globalization (org.apache.cordova.globalization) plugin installed: in app browser (org.apache.cordova.inappbrowser) plugin installed: media (org.apache.cordova.media) plugin installed: dialogs (notification) (org.apache.cordova.dialogs) plugin installed: vibration (notification) (org.apache.cordova.vibration) plugin installed: splashscreen (org.apache.cordova.splashscreen) plugin installed: app security api (com.intel.security) plugin installed: sound (intel.xdk.audio) plugin installed: cache (intel.xdk.cache) plugin installed: photographic camera (intel.xdk.camera) plugin installed: contacts (intel.xdk.contacts) plugin installed: device (intel.xdk.device) plugin installed: file (intel.xdk.file) plugin installed: notification (intel.xdk.notification) plugin installed: player (intel.xdk.player) plugin installed: dolby* sound api (https://github.com/dolbydev/dolby-audio ... or-cordova) plugin installed: file transfer (org.apache.cordova.file-transfer) plugin installed: statusbar (org.apache.cordova.statusbar)

you can view log of android build class="snippet-code-js lang-js prettyprint-override">buildfile: .../appname/build.xml -check-env: [checkenv] android sdk tools revision 23.0.2 [checkenv] installed @ ... -setup: [echo] project name: appname [gettype] project type: application -pre-clean: clean: build successful total time: 0 seconds buildfile: .../appname/build.xml -set-mode-check: -set-release-mode: -release-obfuscation-check: [echo] proguard.config ${proguard.config} -pre-build: -check-env: [checkenv] android sdk tools revision 23.0.2 [checkenv] installed @ ... -setup: [echo] project name: appname [gettype] project type: application -build-setup: [getbuildtools] using latest build tools: 20.0.0 [echo] resolving build target appname... [gettarget] project target: android 4.4.2 [gettarget] api level: 19 [echo] ---------- [echo] creating output directories if needed... [mkdir] created dir: .../appname/bin [mkdir] created dir: .../appname/bin/res [mkdir] created dir: .../appname/bin/rsobj [mkdir] created dir: .../appname/bin/rslibs [mkdir] created dir: .../appname/gen [mkdir] created dir: .../appname/bin/classes [mkdir] created dir: .../appname/bin/dexedlibs [echo] ---------- [echo] resolving dependencies appname... [dependency] library dependencies: [dependency] [dependency] ------------------ [dependency] ordered libraries: [dependency] [dependency] ------------------ -code-gen: [mergemanifest] merging androidmanifest files one. [mergemanifest] manifest merger disabled. using project manifest only. [echo] handling aidl files... [aidl] no aidl files compile. [echo] ---------- [echo] handling renderscript files... [echo] ---------- [echo] handling resources... [aapt] generating resource ids... [aapt] nil matches overlay file icon.png, flavor ,,,,,,,,,,,,,,,,,,, [aapt] nil matches overlay file icon.png, flavor ,,,,,,,,,,,,xhdpi,,,,,,, [aapt] nil matches overlay file splash.png, flavor ,,,,,,,,,land,,,hdpi,,,,,,, [aapt] nil matches overlay file splash.png, flavor ,,,,,,,,,land,,,ldpi,,,,,,, [aapt] nil matches overlay file splash.png, flavor ,,,,,,,,,land,,,mdpi,,,,,,, [aapt] nil matches overlay file splash.png, flavor ,,,,,,,,,land,,,xhdpi,,,,,,, [aapt] nil matches overlay file splash.png, flavor ,,,,,,,,,port,,,hdpi,,,,,,, [aapt] nil matches overlay file splash.png, flavor ,,,,,,,,,port,,,ldpi,,,,,,, [aapt] nil matches overlay file splash.png, flavor ,,,,,,,,,port,,,mdpi,,,,,,, [aapt] nil matches overlay file splash.png, flavor ,,,,,,,,,port,,,xhdpi,,,,,,, [echo] ---------- [echo] handling buildconfig class... [buildconfig] generating buildconfig class. -pre-compile: -compile: [javac] compiling 63 source files .../appname/bin/classes [javac] warning: com/google/android/gms/ads/adlistener.class(com/google/android/gms/ads:adlistener.class): major version 51 newer 50, highest major version supported compiler. [javac] recommended compiler upgraded. [javac] warning: com/google/android/gms/ads/adrequest.class(com/google/android/gms/ads:adrequest.class): major version 51 newer 50, highest major version supported compiler. [javac] recommended compiler upgraded. [javac] warning: com/google/android/gms/ads/adsize.class(com/google/android/gms/ads:adsize.class): major version 51 newer 50, highest major version supported compiler. [javac] recommended compiler upgraded. [javac] warning: com/google/android/gms/ads/adview.class(com/google/android/gms/ads:adview.class): major version 51 newer 50, highest major version supported compiler. [javac] recommended compiler upgraded. [javac] warning: com/google/android/gms/ads/interstitialad.class(com/google/android/gms/ads:interstitialad.class): major version 51 newer 50, highest major version supported compiler. [javac] recommended compiler upgraded. [javac] warning: com/google/android/gms/ads/mediation/admob/admobextras.class(com/google/android/gms/ads/mediation/admob:admobextras.class): major version 51 newer 50, highest major version supported compiler. [javac] recommended compiler upgraded. [javac] warning: com/google/android/gms/common/connectionresult.class(com/google/android/gms/common:connectionresult.class): major version 51 newer 50, highest major version supported compiler. [javac] recommended compiler upgraded. [javac] warning: com/google/android/gms/common/googleplayservicesutil.class(com/google/android/gms/common:googleplayservicesutil.class): major version 51 newer 50, highest major version supported compiler. [javac] recommended compiler upgraded. [javac] warning: com/google/android/gms/ads/adrequest$builder.class(com/google/android/gms/ads:adrequest$builder.class): major version 51 newer 50, highest major version supported compiler. [javac] recommended compiler upgraded. [javac] warning: com/google/android/gms/ads/mediation/networkextras.class(com/google/android/gms/ads/mediation:networkextras.class): major version 51 newer 50, highest major version supported compiler. [javac] recommended compiler upgraded. [javac] warning: com/google/ads/mediation/networkextras.class(com/google/ads/mediation:networkextras.class): major version 51 newer 50, highest major version supported compiler. [javac] recommended compiler upgraded. [javac] note: input files utilize or override deprecated api. [javac] note: recompile -xlint:deprecation details. [javac] note: input files utilize unchecked or unsafe operations. [javac] note: recompile -xlint:unchecked details. [javac] 11 warnings -post-compile: -obfuscate: -dex: [dex] input: .../appname/bin/classes [dex] input: .../framework/bin/classes.jar [dex] input: .../framework/xwalk_core_library/bin/classes.jar [dex] input: .../appname/com.google.playservices/google-play-services_lib/bin/classes.jar [dex] input: .../appname/libs/dolby_audio_processing.jar [dex] input: .../appname/libs/com.google.zxing.client.android.captureactivity.jar [dex] input: .../appname/com.google.playservices/google-play-services_lib/libs/google-play-services.jar [dex] input: .../framework/xwalk_core_library/libs/xwalk_core_library_java.jar [dex] input: .../appname/libs/pushwoosh.jar [dex] pre-dexing .../framework/bin/classes.jar -> classes-c888b94ddba97b0e25b22525db35b6cc.jar [dex] pre-dexing .../framework/xwalk_core_library/bin/classes.jar -> classes-87b66cb50b13fe1ffdecf5ef05c79ce8.jar [dex] pre-dexing .../appname/libs/dolby_audio_processing.jar -> dolby_audio_processing-721546cd6baac89d8439fad4e1b2a961.jar [dex] pre-dexing .../appname/libs/com.google.zxing.client.android.captureactivity.jar -> com.google.zxing.client.android.captureactivity-7406fbf66dfb31f2544e7a8cf811691b.jar [dex] pre-dexing .../appname/com.google.playservices/google-play-services_lib/libs/google-play-services.jar -> google-play-services-bf5947c07197107dd868b3b9915d2dc1.jar [dex] pre-dexing .../framework/xwalk_core_library/libs/xwalk_core_library_java.jar -> xwalk_core_library_java-1aa58519e49aaf933d900f3c0be99fa5.jar [dex] pre-dexing .../appname/libs/pushwoosh.jar -> pushwoosh-fb05e2860f5f63773071342ca81e3b6d.jar [dex] converting compiled files , external libraries .../appname/bin/classes.dex... [dx] [dx] unexpected top-level exception: [dx] java.util.zip.zipexception: error in opening zip file [dx] at java.util.zip.zipfile.open(native method) [dx] at java.util.zip.zipfile.<init>(zipfile.java:127) [dx] at java.util.zip.zipfile.<init>(zipfile.java:143) [dx] at com.android.dx.cf.direct.classpathopener.processarchive(classpathopener.java:244) [dx] at com.android.dx.cf.direct.classpathopener.processone(classpathopener.java:166) [dx] at com.android.dx.cf.direct.classpathopener.process(classpathopener.java:144) [dx] at com.android.dx.command.dexer.main.processone(main.java:596) [dx] at com.android.dx.command.dexer.main.processallfiles(main.java:498) [dx] at com.android.dx.command.dexer.main.runmonodex(main.java:264) [dx] at com.android.dx.command.dexer.main.run(main.java:230) [dx] at com.android.dx.command.dexer.main.main(main.java:199) [dx] at com.android.dx.command.main.main(main.java:103) [dx] 1 error; aborting build failed .../tools/ant/build.xml:892: next error occurred while executing line: .../tools/ant/build.xml:894: next error occurred while executing line: .../tools/ant/build.xml:906: next error occurred while executing line: .../tools/ant/build.xml:283: null returned: 1 total time: 1 min 13 seconds error code 1 command: ant args: release,-f,.../appname/build.xml

can help me, please? great.

it's fixed. please re-build.

root cause:

intel xdk not back upwards library project, newly introduced in plugin (com.google.playservices@21.0.0).

<framework src="libs/google-play-services_lib" custom="true" />

you may ask, why alter of "com.google.playservices" cause admob plugin fail?

the admob plugin dependent on plugin named "com.google.playservices", adds google play services jar project.

the "com.google.playservices@19.0.0" simple jar file, worked quite well.

<source-file src="google-play-services.jar" target-dir="libs" />

but "com.google.playservices@21.0.0" using new feature include whole library project.

<framework src="libs/google-play-services_lib" custom="true" />

it works quite if build locally cordova cli, fail when build intel xdk.

to maintain compatible intel xdk, dependency of admob plugin changed "com.google.playservices@19.0.0", simple jar file.

now works intel xdk again.

cordova intel-xdk crosswalk-runtime intel-xdk-contacts

windows - Any way to see where python is importing a module from? -



windows - Any way to see where python is importing a module from? -

so installed facebook module, realized wrong one, used pip uninstall , installed facebook-sdk. here code:

import facebook token = '[token]' graph = facebook.graphapi(token) profile = graph.get_object("me") friends = graph.get_connections("me", "friends") friend_list = [friend['name'] friend in friends['data']] print friend_list

and

traceback (most recent phone call last): file "c:\users\mgraves\desktop\facebook.py", line 1, in <module> import facebook file "c:\users\mgraves\desktop\facebook.py", line 5, in <module> graph = facebook.graphapi(token) attributeerror: 'module' object has no attribute 'graphapi'

when looking up, every result says uninstall facebook , facebook-sdk , reinstall facebook-sdk. , have, many many times. searched /python27/ facebook afterwards create sure files gone.

is there way on windows machine trace importing "facebook" from?

module objects have __file__ attribute, , object representation includes file:

print facebook print facebook.__file__

in case, importing your own script; named facebook , masking installed module:

file "c:\users\mgraves\desktop\facebook.py", line 1, in <module> import facebook file "c:\users\mgraves\desktop\facebook.py", line 5, in <module> graph = facebook.graphapi(token)

note filename in first line, fact same file used import. python stores main script __main__, importing script results in module beingness created actual filename.

python windows python-2.7

c# - Configuring MemoryCache to run in a separate memory than application pool -



c# - Configuring MemoryCache to run in a separate memory than application pool -

i thinking of using memorycache in application:

http://msdn.microsoft.com/en-us/library/system.runtime.caching.memorycache%28v=vs.110%29.aspx

how when tested this, functions more of less old cache in asp.net 2.0. expires when application pool resets.

is there way prevent there memorycache doesn't reset when application pool recycles? help appreciated.

c# asp.net caching memorycache

parallel processing - MPI Parallelization time consumption -



parallel processing - MPI Parallelization time consumption -

i have 2 blocks of code consume 2 seconds each, in classic construction run sequentially, in 4 seconds

in mpi format, supposed consume 2 seconds takes 5 seconds

why?

int main ( int argc, char *argv[] ) { mpi_init( &argc, &argv ); mpi_comm_size(mpi_comm_world,&p ); mpi_comm_rank(mpi_comm_world,&id); if(id==0) { // 2 seconds block } if(id==1) { // 2 seconds block } mpi_finalize(); }

what take 5 seconds? if have measured time whole program, problem mpi_init() , mpi_finalize() time consuming. in order see speedup increment "blocks".

parallel-processing mpi

android - Why google cloud messaging .send works fine just when the connection is strong -



android - Why google cloud messaging .send works fine just when the connection is strong -

i trying send message payload using gcm send() function. every thing work fine when network connection strong,but when network connection weak or not strong, message doesn't arrive server, without exception!! although in same condition, other applications work fine , send , receive, app doesn't!

android google-cloud-messaging

MySQL select to find similar lat/lng with matching name column -



MySQL select to find similar lat/lng with matching name column -

i trying find rows in single table of locations have same latitude/longitude when rounded 2 decimal places same name. here table (for example):

+---------------------------------------+ | id | lat | lng | name | +---------------------------------------+ | 11 | -11.119 | 13.891 | smith's place | | 81 | -11.121 | 13.893 | smith's place | +---------------------------------------+

what select statement find instances (like 1 above) lat/lng match when rounded 2 decimal places...and names same?

i looking similar query doesn't work (but asking after):

select * pb_locations grouping round(lat,2),round(lng,2) name = name having count(id) > 1

where name = name true, since it's comparing within same row, not across different rows.

you need set 3 columns in group by clause.

select * pb_locations grouping round(lat, 2), round(lng, 2), name having count(*) > 1

mysql

java - Spring Security Login returns Request method 'POST' not supported -



java - Spring Security Login returns Request method 'POST' not supported -

i created simple spirng mvc application spring security , hibernate. when trying login returns error message "request method 'post' not supported". here web.xml , servelet contexts.

web.xml <?xml version="1.0" encoding="utf-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <!-- spring mvc --> <servlet> <servlet-name>appservlet</servlet-name> <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>appservlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <listener> <listener-class>org.springframework.web.context.contextloaderlistener</listener-class> </listener> <context-param> <param-name>contextconfiglocation</param-name> <param-value> /web-inf/spring/appservlet/servlet-context.xml, /web-inf/spring/springsecurity-servlet.xml </param-value> </context-param> <!-- spring security --> <filter> <filter-name>springsecurityfilterchain</filter-name> <filter-class>org.springframework.web.filter.delegatingfilterproxy</filter-class> </filter> <filter-mapping> <filter-name>springsecurityfilterchain</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app> servletcontext.xml <?xml version="1.0" encoding="utf-8"?> <beans:beans xmlns="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemalocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd"> <!-- dispatcherservlet context: defines servlet's request-processing infrastructure --> <!-- enables spring mvc @controller programming model --> <annotation-driven /> <!-- handles http requests /resources/** efficiently serving static resources in ${webapproot}/resources directory --> <resources mapping="/resources/**" location="/resources/" /> <!-- resolves views selected rendering @controllers .jsp resources in /web-inf/views directory --> <beans:bean class="org.springframework.web.servlet.view.internalresourceviewresolver"> <beans:property name="prefix" value="/web-inf/views/" /> <beans:property name="suffix" value=".jsp" /> </beans:bean> <!-- configure plugin json request , response in method handler --> <beans:bean class="org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter"> <beans:property name="messageconverters"> <beans:list> <beans:ref bean="jsonmessageconverter"/> </beans:list> </beans:property> </beans:bean> <!-- configure bean convert json pojo , vice versa --> <beans:bean id="jsonmessageconverter" class="org.springframework.http.converter.json.mappingjackson2httpmessageconverter"> </beans:bean> <!-- <beans:bean id="datasource" class="org.apache.commons.dbcp.basicdatasource" destroy-method="close"> <beans:property name="driverclassname" value="net.sourceforge.jtds.jdbc.driver" /> <beans:property name="url" value="jdbc:jtds:sqlserver://10.0.0.25:1433;databasename=3pltest;" /> <beans:property name="username" value="sa" /> <beans:property name="password" value="sa" /> </beans:bean> --> <beans:bean id="datasource" class="org.apache.commons.dbcp.basicdatasource" destroy-method="close"> <beans:property name="driverclassname" value="com.microsoft.sqlserver.jdbc.sqlserverdriver" /> <beans:property name="url" value="jdbc:sqlserver://sys-001\sqlexpress:1433;databasename=3pltest" /> <beans:property name="username" value="sa" /> <beans:property name="password" value="sa" /> </beans:bean> <!-- hibernate 4 sessionfactory bean definition --> <beans:bean id="hibernate4annotatedsessionfactory" class="org.springframework.orm.hibernate4.localsessionfactorybean"> <beans:property name="datasource" ref="datasource" /> <beans:property name="annotatedclasses"> <beans:list> <beans:value>com.dimensions.warehouse.model.employee</beans:value> <beans:value>com.dimensions.warehouse.model.user</beans:value> </beans:list> </beans:property> <beans:property name="hibernateproperties"> <beans:props> <beans:prop key="hibernate.dialect">org.hibernate.dialect.sqlserverdialect </beans:prop> <beans:prop key="hibernate.show_sql">true</beans:prop> </beans:props> </beans:property> </beans:bean> <beans:bean id="employeedao" class="com.dimensions.warehouse.dao.employeedaoimpl"> <beans:property name="sessionfactory" ref="hibernate4annotatedsessionfactory" /> </beans:bean> <beans:bean id="employeeservice" class="com.dimensions.warehouse.service.employeeserviceimpl"> <beans:property name="employeedao" ref="employeedao"></beans:property> </beans:bean> <beans:bean id="userdao" class="com.dimensions.warehouse.dao.userdaoimpl"> <beans:property name="sessionfactory" ref="hibernate4annotatedsessionfactory" /> </beans:bean> <beans:bean id="userservice" class="com.dimensions.warehouse.service.userserviceimpl"> <beans:property name="userdao" ref="userdao"></beans:property> </beans:bean> <beans:bean id="userdetailsservice" class="com.dimensions.warehouse.service.userdetailsserviceimp"> <beans:property name="userdao" ref="userdao" ></beans:property> </beans:bean> <context:component-scan base-package="com.dimensions.warehouse" /> <tx:annotation-driven transaction-manager="transactionmanager"/> <beans:bean id="transactionmanager" class="org.springframework.orm.hibernate4.hibernatetransactionmanager"> <beans:property name="sessionfactory" ref="hibernate4annotatedsessionfactory" /> </beans:bean> <tx:advice id="txadvice" transaction-manager="transactionmanager"> <tx:attributes> <tx:method name="get*" read-only="true" /> <tx:method name="find*" read-only="true" /> <tx:method name="*" /> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut id="userservicepointcut" expression="execution(* com.dimensions.warehouse.service.*service.*(..))" /> <aop:advisor advice-ref="txadvice" pointcut-ref="userservicepointcut" /> </aop:config> </beans:beans> springsecurity-servlet.xml <beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd"> <!-- enable use-expressions --> <http auto-config="true" use-expressions="true"> <intercept-url pattern="/employees**" access="hasrole('role_admin')" /> <!-- access denied page --> <access-denied-handler error-page="/403" /> <form-login login-page="/login" default-target-url="/welcome" authentication-failure-url="/login?error" username-parameter="username" password-parameter="password" /> <logout logout-success-url="/login?logout" /> <!-- enable csrf protection --> <csrf /> </http> <authentication-manager> <authentication-provider user-service-ref="userdetailsservice" > <password-encoder hash="plaintext" /> </authentication-provider> </authentication-manager> </beans:beans> appservlet.xml <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"> <context:component-scan base-package="com.dimensions.warehouse.*" /> <bean class="org.springframework.web.servlet.view.internalresourceviewresolver"> <property name="prefix"> <value>/web-inf/views/</value> </property> <property name="suffix"> <value>.jsp</value> </property> </bean> </beans>

java spring authentication spring-security

visual studio - VS 2013 update 3 RTM fails 0x80004002 errors -



visual studio - VS 2013 update 3 RTM fails 0x80004002 errors -

uses: windows 7 pro sp1; vs 2013 pro;

i tried install vs 2013 update 3 fails without neither throwing message or specifying reason. log specifies as:

[48ac:48b0][2014-11-12t18:39:45]e000: error 0x80004002: failed run per-user mode. [48ac:48b0][2014-11-12t18:39:45]i007: exit code: 0x80004002, restarting: no

the entire log:

[48ac:48b0][2014-11-12t18:39:44]i001: fire v3.7.3117.0, windows v6.1 (build 7601: service pack 1), path: d:\software\ide\vs 2013\update\vs2013.3\vs2013.3.exe, cmdline: '-burn.unelevated burnpipe.{b43bb71c-5897-420e-9edd-686f07fe192d} {55b523a4-48ff-4c01-b455-d5f599912969} 18624' [48ac:48b0][2014-11-12t18:39:44]i000: initializing string variable 'editiondisplayname' value '#loc.vsupdatededitiondisplayname' [48ac:48b0][2014-11-12t18:39:44]i000: initializing string variable 'factormsi' value '1.3' [48ac:48b0][2014-11-12t18:39:44]i000: initializing numeric variable 'morelanguagefwlinkid' value '376932' [48ac:48b0][2014-11-12t18:39:44]i000: initializing numeric variable 'privacyagreementfwlinkid' value '376910' [48ac:48b0][2014-11-12t18:39:44]i000: initializing numeric variable 'privacystatementfwlinkid' value '376910' [48ac:48b0][2014-11-12t18:39:44]i000: initializing numeric variable 'minoslevelfwlinkid' value '376920' [48ac:48b0][2014-11-12t18:39:44]i000: initializing numeric variable 'solutionfwlinkid' value '376911' [48ac:48b0][2014-11-12t18:39:44]i000: initializing numeric variable 'helpfwlinkid' value '376912' [48ac:48b0][2014-11-12t18:39:44]i000: initializing numeric variable 'ie10fwlinkid' value '376914' [48ac:48b0][2014-11-12t18:39:44]i000: initializing numeric variable 'winbluefwlinkid' value '376917' [48ac:48b0][2014-11-12t18:39:44]i000: initializing numeric variable 'sha256blockfwlinkid' value '376918' [48ac:48b0][2014-11-12t18:39:44]i000: initializing numeric variable 'win81prerelblockfwlinkid' value '376916' [48ac:48b0][2014-11-12t18:39:44]i000: initializing string variable 'netfxproductversion' value '4.5.30723' [48ac:48b0][2014-11-12t18:39:44]i000: initializing string variable 'professionalvsversion' value '11.0.50727' [48ac:48b0][2014-11-12t18:39:44]i000: initializing string variable 'baselinebundleversion' value '12.0.21005' [48ac:48b0][2014-11-12t18:39:44]i000: initializing string variable 'firstslipstreambundleversion' value '12.0.21006' [48ac:48b0][2014-11-12t18:39:44]i000: initializing string variable 'productkey' value 'vvxkcdccwd3b29pwqk2c3gyd7' [48ac:48b0][2014-11-12t18:39:44]i000: initializing string variable 'perftoolsres_langrelevant_chs' value 'true' [48ac:48b0][2014-11-12t18:39:44]i000: initializing string variable 'perftoolsres_langrelevant_cht' value 'true' [48ac:48b0][2014-11-12t18:39:44]i000: initializing string variable 'perftoolsres_langrelevant_csy' value 'true' [48ac:48b0][2014-11-12t18:39:44]i000: initializing string variable 'perftoolsres_langrelevant_deu' value 'true' [48ac:48b0][2014-11-12t18:39:44]i000: initializing string variable 'perftoolsres_langrelevant_esn' value 'true' [48ac:48b0][2014-11-12t18:39:44]i000: initializing string variable 'perftoolsres_langrelevant_fra' value 'true' [48ac:48b0][2014-11-12t18:39:44]i000: initializing string variable 'perftoolsres_langrelevant_ita' value 'true' [48ac:48b0][2014-11-12t18:39:44]i000: initializing string variable 'perftoolsres_langrelevant_jpn' value 'true' [48ac:48b0][2014-11-12t18:39:44]i000: initializing string variable 'perftoolsres_langrelevant_kor' value 'true' [48ac:48b0][2014-11-12t18:39:44]i000: initializing string variable 'perftoolsres_langrelevant_plk' value 'true' [48ac:48b0][2014-11-12t18:39:44]i000: initializing string variable 'perftoolsres_langrelevant_ptb' value 'true' [48ac:48b0][2014-11-12t18:39:44]i000: initializing string variable 'perftoolsres_langrelevant_rus' value 'true' [48ac:48b0][2014-11-12t18:39:44]i000: initializing string variable 'perftoolsres_langrelevant_trk' value 'true' [48ac:48b0][2014-11-12t18:39:44]i000: initializing string variable 'win8dev_dev11path' value '[programfilesfolder]microsoft visual studio 11.0\' [48ac:48b0][2014-11-12t18:39:44]i000: initializing string variable 'dev11_ut_path' value '[programfilesfolder]microsoft visual studio 11.0\' [48ac:48b0][2014-11-12t18:39:44]i000: initializing string variable 'winsdk_common_kitsrootpath' value '[programfilesfolder]windows kits\8.0\' [48ac:48b0][2014-11-12t18:39:44]i000: initializing string variable 'dev11_vc_path' value '[programfilesfolder]microsoft visual studio 11.0\' [48ac:48b0][2014-11-12t18:39:44]i000: initializing numeric variable 'ischainingx64vstodt' value '1' [48ac:48b0][2014-11-12t18:39:44]i000: initializing numeric variable 'ischainingx86vstodt' value '1' [48ac:48b0][2014-11-12t18:39:44]i000: initializing string variable 'include_windowsphoneappxemulator' value 'true' [48ac:48b0][2014-11-12t18:39:44]i000: setting string variable 'wixbundlelog' value 'd:\appdata\local\temp\dd_vsupdate_kb2829760_20141112183944.log' [48ac:48b0][2014-11-12t18:39:44]i000: setting string variable 'wixbundleoriginalsource' value 'd:\software\ide\vs 2013\update\vs2013.3\vs2013.3.exe' [48ac:48b0][2014-11-12t18:39:44]i000: setting string variable 'wixbundleoriginalsourcefolder' value 'd:\software\ide\vs 2013\update\vs2013.3\' [48ac:48b0][2014-11-12t18:39:44]i000: setting string variable 'wixbundlename' value 'visual studio 2013 update 3 (kb2829760)' [48ac:48b0][2014-11-12t18:39:45]i000: loading managed bootstrapper application. [48ac:48b0][2014-11-12t18:39:45]e000: error 0x80004002: failed create managed bootstrapper application. [48ac:48b0][2014-11-12t18:39:45]e000: error 0x80004002: failed create ux. [48ac:48b0][2014-11-12t18:39:45]e000: error 0x80004002: failed load ux. [48ac:48b0][2014-11-12t18:39:45]e000: error 0x80004002: failed while running [48ac:48b0][2014-11-12t18:39:45]i410: variable: baselinebundleversion = 12.0.21005 [48ac:48b0][2014-11-12t18:39:45]i410: variable: dev11_ut_path = c:\program files\microsoft visual studio 11.0\ [48ac:48b0][2014-11-12t18:39:45]i410: variable: dev11_vc_path = c:\program files\microsoft visual studio 11.0\ [48ac:48b0][2014-11-12t18:39:45]i410: variable: editiondisplayname =

loc.vsupdatededitiondisplayname [48ac:48b0][2014-11-12t18:39:45]i410: variable: factormsi = 1.3 [48ac:48b0][2014-11-12t18:39:45]i410:

variable: firstslipstreambundleversion = 12.0.21006 [48ac:48b0][2014-11-12t18:39:45]i410: variable: helpfwlinkid = 376912 [48ac:48b0][2014-11-12t18:39:45]i410: variable: ie10fwlinkid = 376914 [48ac:48b0][2014-11-12t18:39:45]i410: variable: include_windowsphoneappxemulator = true [48ac:48b0][2014-11-12t18:39:45]i410: variable: ischainingx64vstodt = 1 [48ac:48b0][2014-11-12t18:39:45]i410: variable: ischainingx86vstodt = 1 [48ac:48b0][2014-11-12t18:39:45]i410: variable: minoslevelfwlinkid = 376920 [48ac:48b0][2014-11-12t18:39:45]i410: variable: morelanguagefwlinkid = 376932 [48ac:48b0][2014-11-12t18:39:45]i410: variable: netfxproductversion = 4.5.30723 [48ac:48b0][2014-11-12t18:39:45]i410: variable: perftoolsres_langrelevant_chs = true [48ac:48b0][2014-11-12t18:39:45]i410: variable: perftoolsres_langrelevant_cht = true [48ac:48b0][2014-11-12t18:39:45]i410: variable: perftoolsres_langrelevant_csy = true [48ac:48b0][2014-11-12t18:39:45]i410: variable: perftoolsres_langrelevant_deu = true [48ac:48b0][2014-11-12t18:39:45]i410: variable: perftoolsres_langrelevant_esn = true [48ac:48b0][2014-11-12t18:39:45]i410: variable: perftoolsres_langrelevant_fra = true [48ac:48b0][2014-11-12t18:39:45]i410: variable: perftoolsres_langrelevant_ita = true [48ac:48b0][2014-11-12t18:39:45]i410: variable: perftoolsres_langrelevant_jpn = true [48ac:48b0][2014-11-12t18:39:45]i410: variable: perftoolsres_langrelevant_kor = true [48ac:48b0][2014-11-12t18:39:45]i410: variable: perftoolsres_langrelevant_plk = true [48ac:48b0][2014-11-12t18:39:45]i410: variable: perftoolsres_langrelevant_ptb = true [48ac:48b0][2014-11-12t18:39:45]i410: variable: perftoolsres_langrelevant_rus = true [48ac:48b0][2014-11-12t18:39:45]i410: variable: perftoolsres_langrelevant_trk = true [48ac:48b0][2014-11-12t18:39:45]i410: variable: privacyagreementfwlinkid = 376910 [48ac:48b0][2014-11-12t18:39:45]i410: variable: privacystatementfwlinkid = 376910 [48ac:48b0][2014-11-12t18:39:45]i410: variable: productkey = vvxkcdccwd3b29pwqk2c3gyd7 [48ac:48b0][2014-11-12t18:39:45]i410: variable: professionalvsversion = 11.0.50727 [48ac:48b0][2014-11-12t18:39:45]i410: variable: programfilesfolder = c:\program files\ [48ac:48b0][2014-11-12t18:39:45]i410: variable: sha256blockfwlinkid = 376918 [48ac:48b0][2014-11-12t18:39:45]i410: variable: solutionfwlinkid = 376911 [48ac:48b0][2014-11-12t18:39:45]i410: variable: win81prerelblockfwlinkid = 376916 [48ac:48b0][2014-11-12t18:39:45]i410: variable: win8dev_dev11path = c:\program files\microsoft visual studio 11.0\ [48ac:48b0][2014-11-12t18:39:45]i410: variable: winbluefwlinkid = 376917 [48ac:48b0][2014-11-12t18:39:45]i410: variable: winsdk_common_kitsrootpath = c:\program files\windows kits\8.0\ [48ac:48b0][2014-11-12t18:39:45]i410: variable: wixbundleaction = 5 [48ac:48b0][2014-11-12t18:39:45]i410: variable: wixbundleelevated = 1 [48ac:48b0][2014-11-12t18:39:45]i410: variable: wixbundlelog = d:\appdata\local\temp\dd_vsupdate_kb2829760_20141112183944.log [48ac:48b0][2014-11-12t18:39:45]i410: variable: wixbundlemanufacturer = microsoft corporation [48ac:48b0][2014-11-12t18:39:45]i410: variable: wixbundlename = visual studio 2013 update 3 (kb2829760) [48ac:48b0][2014-11-12t18:39:45]i410: variable: wixbundleoriginalsource = d:\software\ide\vs 2013\update\vs2013.3\vs2013.3.exe [48ac:48b0][2014-11-12t18:39:45]i410: variable: wixbundleoriginalsourcefolder = d:\software\ide\vs 2013\update\vs2013.3\ [48ac:48b0][2014-11-12t18:39:45]i410: variable: wixbundleproviderkey = vsupdate_kb2829760 [48ac:48b0][2014-11-12t18:39:45]i410: variable: wixbundletag = vsupdate_kb2829760,1033 [48ac:48b0][2014-11-12t18:39:45]i410: variable: wixbundleversion = 12.0.30723.0 [48ac:48b0][2014-11-12t18:39:45]e000: error 0x80004002: failed run per-user mode. [48ac:48b0][2014-11-12t18:39:45]i007: exit code: 0x80004002, restarting: no

fyi, vs version:

try following:

create new windows user business relationship on same machine

run install new user business relationship (which, default, instal visual studio in such way available user accounts on same machine)

delete new windows user business relationship id

visual-studio visual-studio-2013 installation updates

mysql - mysqli connect function in PHP -



mysql - mysqli connect function in PHP -

i've started mysqli. when create mysqli connection database having problem function.

my code :

$link=mysqli_connect("host", "user","password","database_name", true) or die ('i cannot connect database because: ' . mysqli_connect_error()); $query="call `database_name`.`table_name`('107','0100000000',63,122)"; $result=mysqli_query($link,$query); $rs = mysqli_fetch_array($result); $image = $rs['image']; $title = $rs['title']; echo $title; mysqli_close($link);

when execute in php code throws error.

error :

can't connect mysql server on 'host_name' (110)

but when utilize mysql extension works fine.please guide me doing mistake.

thanks

the 5th argument in mysqli_connect() port number.

true evaluates 1 , that's not right port. remove argument not required - default used.

in mysql_connect() 5th argument 'new link', true appropriate.

as migrating mysqli, might want read this answer gives basic changes old mysql extension.

by way, using syntax declaring new connection, thought might want know can have more 1 connection when using mysqli. have set new variable, ie;

$link1 = new mysqli($host,$username,$password,$database); $link2 = new mysqli($host2,$username2,$password2,$database2);

then can take connection utilize when executing queries etc. example;

procedural:

$result1 = mysqli_query($link1,$sql);

oo:

$result2 = $link2->query($sql);

php mysql database mysqli

Lambda calculus entire expression substitution -



Lambda calculus entire expression substitution -

about substitution of free occurances: can have substitution of entire expression(function, application), or of variable:

example:

current look \x.\y.(y, z) expression replaced: \y.(y z) p have \x.p.

is possible?

yes, possible. 1 way consider substitution of occurrences. occurrence string on set {1,2,3}, , every lambda-term m, sub-expression m/u @ occurrence u defined as:

m/[] = m m/0u = n/u, if m=\x. n m/1u = p/u, if m=pq m/2u = q/u, if m=pq

(i utilize symbol [] denote empty string.)

now define substitution m[u := n] term obtained replacing occurrence u n in m. i've seen kind of substitution in of p.-l. curien work.

lambda-calculus

java - JPA 2.1 says attribute "indexes is undefined" -



java - JPA 2.1 says attribute "indexes is undefined" -

im developing web-app using wildfly 8.0.0 hibernate jpa 2.1. problem is, can't annotate manytoone indexes.

import javax.persistence.cacheable; import javax.persistence.entity; import javax.persistence.generatedvalue; import javax.persistence.id; import javax.persistence.index; import javax.persistence.joincolumn; import javax.persistence.manytoone; import javax.persistence.table; import de.sessions.benutzerverwaltung.domain.benutzer; @entity @table(indexes = { @index(columnlist = "user_fk"), @index(columnlist = "session_fk") }) @cacheable public class comment implements serializable{ ...

eclipse says "the attribute indexes undefined annotation type table" in project works fine.

thanks in advance, tim

solved deleting class , creating new (ctrl+a, ctrl+c, ctrl+v) , problem gone. eclipse....

java jpa indexing undefined wildfly

Unexpected behavior from Python -



Unexpected behavior from Python -

i'm new python , bit confused way python treats empty object.

consider code piece;

a = {} if a: print "a alive!" else: print "a not alive!" if not a: print "not a!" else: print "a!" if none: print "a none!" else: print "a not none!"

i next output code piece.

a not alive! not a! not none! edit::

i under assumption object initialized {} valid object. why doesn't python treat way? , why diff output diff if conditions?

edit 2::

in c++, when say

object obj; if (obj){ }

it come in if block if obj not null(regardless if garbage value or whatever)

but same thing when translate python.

a = {} #this valid object if a: # doesn't work!

why? , read python evaluates {} false. why that?

i see nil weird in output. let's go step-by-step:

a dictionary, more dictionary object; a dictionary, it's empty, truth value false

therefore:

the first if, since a false, prints else statement , that's right; the sec if, since not a evaluates true because a false, prints if part , that's right too. last, not to the lowest degree a not none object, dict object, it's right else part taken , printed.

python python-2.7

ios - Button appearance clicked version -



ios - Button appearance clicked version -

i want buttons way, , instead of subclassing button, wrote this

[[uibutton appearancewhencontainedin:[eabaseviewcontroller class], nil]setbackgroundimage:[uiimage imagenamed:@"gradient_border"] forstate:uicontrolstatenormal]; [[uibutton appearancewhencontainedin:[eabaseviewcontroller class], nil]setbackgroundimage:[uiimage imagenamed:@"gradient_border_grey"] forstate:uicontrolstatehighlighted]; [[uibutton appearancewhencontainedin:[eabaseviewcontroller class], nil]setbackgroundimage:[uiimage imagenamed:@"gradient_border_grey"] forstate:uicontrolstateselected]; [[uibutton appearancewhencontainedin:[eabaseviewcontroller class], nil]setbackgroundimage:[uiimage imagenamed:@"gradient_border_grey"] forstate:uicontrolstateselected|uicontrolstatehighlighted]; [[uibutton appearancewhencontainedin:[eabaseviewcontroller class], nil]setbackgroundimage:[uiimage imagenamed:@"grey_border_grey"] forstate:uicontrolstatedisabled];

the problem is, when click button, instead of changing image gradient_border_grey changes alpha instead. cannot find how prepare it?

how prepare ?

i needed set button type custom prepare problem

ios uibutton

c - invalid operands to binary * (have ‘int’ and ‘int *’) -



c - invalid operands to binary * (have ‘int’ and ‘int *’) -

i trying find out factorial of number using recursion , passing pointers function arguments. error appears time. debugers , coders! need assistance this.

the code #include<stdio.h> int *factorial(int *); int value, p=0, q=1, x, tmp; void main() { int *result; puts("enter value::"); scanf("%d",&value); result = factorial(&value); printf("\nthe result is::%d\n", *result); } int *factorial(int *n) { if(*n == p || *n == q) { return(&q); } else { tmp = *n -1; *n *= (factorial(&tmp)); return(n); } } error: error: invalid operands binary * (have ‘int’ , ‘int *’) *n *= (factorial(&tmp));

this line :

*n *= (factorial(&tmp));

should be

*n *= *(factorial(&tmp));

however, careful implementation because recursive, uses pointers globals.

would standard implementation not work you?

int factorial(int n) { if(n==0) homecoming 1; else homecoming factorial(n-1)*n; }

with standard, need prompt user non-negative values only.

c pointers recursion factorial

php - Whats wrong in regular expression -



php - Whats wrong in regular expression -

whats wrong with:

$pattern = '/9[0-5[7-9]]{1}[\\d]{10})|([0-2]\\d{11}/'; $subject = '971093342689';

trying check in php

preg_match($pattern, $subject)

receive error:

preg_match(): compilation failed: unmatched parentheses @ offset 22

the 2 parentheses not closed:

$pattern = '/9[0-5[7-9]]{1}[\\d]{10})|([0-2]\\d{11}/'; ^^^^

if sign need, have escape it. otherwise need open , closed parentheses in regexp.

php regex

javascript - Mixitup.js and multiple filtering -



javascript - Mixitup.js and multiple filtering -

i've taken code http://codepen.io/patrickkunka/pen/iwcap , modified it, can't create work desired.

if select 1 filter, works fine - if start compare filters, it's not returning right result.

i'm returning "filters" dynamicly - shouldn't problem.

can give me heads on this?

link js fiddle :

http://jsfiddle.net/u6kslwts/26/

// loop through div's .mix class var genders = []; var models = []; var brands = []; var prices = []; $(".mix").each(function () { addtoarrayifnew(genders, $(this).attr('data-gender')); addtoarrayifnew(models, $(this).data('model')); addtoarrayifnew(brands, $(this).data('brand')); if ($(this).data('brand').match(/\s/g)){ $(this).addclass('brand_' + $(this).data('brand')); } addtoarrayifnew(prices, $(this).data('price')); // prepare invalid css class names }); // homecoming arrays html code if (models.length > 0) { var filtername = 'model'; var idname = 'modelsfilter'; $("#" + idname).append(renderhtmlfilterboxes(filtername, models)); } if (genders.length > 0) { var filtername = 'gender'; var idname = 'gendersfilter'; $("#" + idname).append(renderhtmlfilterboxes(filtername, genders)); } if (brands.length > 0) { var filtername = 'brand'; var idname = 'brandsfilter'; $("#" + idname).append(renderhtmlfilterboxes(filtername, brands)); } function renderhtmlfilterboxes(filtername, arraylist) { var htmlstr = ""; (var in arraylist) { htmlstr = htmlstr + '<div class="filterboxes"><div class="checkbox">'; htmlstr = htmlstr + '<input type="checkbox" value=".' + filtername + '_' + arraylist[i].replace(/[^a-za-z]+/g,'') + '" />'; htmlstr = htmlstr + '<label>' + arraylist[i] + '</label>'; htmlstr = htmlstr + '</div></div>'; } homecoming htmlstr; } function addtoarrayifnew(arr, item) { if (item && jquery.inarray(item, arr) == -1) { arr.push(item); } } function renderhtmlpricerange() { var lowest = number.positive_infinity; var highest = number.negative_infinity; var tmp; (var = prices.length - 1; >= 0; i--) { tmp = prices[i]; if (tmp < lowest) lowest = tmp; if (tmp > highest) highest = tmp; } console.log(highest, lowest); } // mix code // maintain our code clean , modular, custom functionality contained within single object literal called "checkboxfilter". var checkboxfilter = { // declare variables need properties of object $filters: null, $reset: null, groups: [], outputarray: [], outputstring: '', // "init" method run on document ready , cache jquery objects need. init: function () { var self = this; // best practice, in each method asign "this" variable "self" remains scope-agnostic. utilize refer parent "checkboxfilter" object can share methods , properties between parts of object. self.$filters = $('#filters'); self.$reset = $('#reset'); self.$container = $('#container'); self.$filters.find('.filterboxes').each(function () { self.groups.push({ $inputs: $(this).find('input'), active: [], tracker: false }); }); // console.log(self.groups); self.bindhandlers(); }, // "bindhandlers" method hear whenever form value changes. bindhandlers: function () { var self = this; self.$filters.on('change', function () { self.parsefilters(); }); self.$reset.on('click', function (e) { e.preventdefault(); self.$filters[0].reset(); self.parsefilters(); }); }, // parsefilters method checks filters active in each group: parsefilters: function () { var self = this; // loop through each filter grouping , add together active filters arrays (var = 0, group; grouping = self.groups[i]; i++) { group.active = []; // reset arrays group.$inputs.each(function () { $(this).is(':checked') && group.active.push(this.value); }); group.active.length && (group.tracker = 0); } // console.log(self.groups); self.concatenate(); }, // "concatenate" method crawl through each group, concatenating filters desired: concatenate: function () { var self = this, cache = '', crawled = false, checktrackers = function () { console.log(1); var done = 0; (var = 0, group; grouping = self.groups[i]; i++) { (group.tracker === false) && done++; } homecoming (done < self.groups.length); }, crawl = function () { // console.log(2); (var = 0, group; grouping = self.groups[i]; i++) { group.active[group.tracker] && (cache += group.active[group.tracker]); if (i === self.groups.length - 1) { self.outputarray.push(cache); cache = ''; updatetrackers(); } } }, updatetrackers = function () { //console.log(3); (var = self.groups.length - 1; > -1; i--) { var grouping = self.groups[i]; if (group.active[group.tracker + 1]) { group.tracker++; break; } else if (i > 0) { group.tracker && (group.tracker = 0); } else { crawled = true; } } }; self.outputarray = []; // reset output array { crawl(); } while (!crawled && checktrackers()); self.outputstring = self.outputarray.join(); // if output string empty, show rather none: !self.outputstring.length && (self.outputstring = 'all'); //console.log(self.outputstring); // ^ can check console here take @ filter string produced // send output string mixitup via 'filter' method: if (self.$container.mixitup('isloaded')) { // console.log(4); self.$container.mixitup('filter', self.outputstring); // console.log(self.outputstring); } } }; // on document ready, initialise our code. $(function () { // avoid non javascript browsers not see content, display:none first set // here, instead of css file // initialize checkboxfilter code checkboxfilter.init(); // instantiate mixitup $(".mix").css("display", "none"); $('#container').mixitup({ load: { filter: 'none' }, controls: { togglelogic: 'or', togglefilterbuttons: true, enable: true // won't needing these }, animation: { easing: 'cubic-bezier(0.86, 0, 0.07, 1)', duration: 600 } }); });

html :

<div id="filters"> <div id="gendersfilter"></div> <div id="brandsfilter"></div> <div id="modelsfilter"></div> </div> <div id="container"> <div class="mix brand_mystbrandname model_ gender_0" data-gender="0" data-brand="my 1st. brand name!" data-model="" data-price="1000">my 1st. brand name!</div> <div class="mix brand_casio model_ gender_0" data-gender="0" data-brand="casio" data-model="" data-price="10">my casio block</div> <div class="mix brand_seiko model_ gender_2" data-gender="2" data-brand="seiko" data-model="precision" data-price="200">my seiko block</div> <div class="mix brand_nikon model_lada gender_1" data-gender="1" data-brand="nikon" data-model="lada" data-price="40">my nikon block</div> <div class="mix brand_dell model_2 gender_inspirion" data-gender="1" data-brand="dell" data-model="inspirion" data-price="500">my dell block</div> </div> <script src="http://cdn.jsdelivr.net/jquery.mixitup/latest/jquery.mixitup.min.js"></script>

self.$filters.find('.filterboxes').each(function () { self.groups.push({ $inputs: $(this).find('input'), active: [], tracker: false }); });

changed to

> self.$filters.find('.filters').each(function () { > self.groups.push({ > $inputs: $(this).find('input'), > active: [], > tracker: false > }); > });

and added css class "filters" on each of groups

<div id="filters"> <div id="gendersfilter" class="filters"></div> ... </div>

javascript jquery