Posts

Showing posts from July, 2015

iphone - Measure size of each char in an NSString -

we have [nsstring sizewithfont:] returns size of entire string. what getting array of sizes of each individual character within string? how (besides tokenizing string , calling sizewithfont each)? best, vance you should able size information individual glyphs (note though don't map one-to-one individual characters in string) using core graphics function cgfontgetglyphbboxes .

javascript - Convert JS date time to MySQL datetime -

does know how convert js datetime mysql datetime? there way add specific number of minutes js datetime , pass mysql datetime? while js possess enough basic tools this, it's pretty clunky. /** * first need create formatting function pad numbers 2 digits… **/ function twodigits(d) { if(0 <= d && d < 10) return "0" + d.tostring(); if(-10 < d && d < 0) return "-0" + (-1*d).tostring(); return d.tostring(); } /** * …and create method output date string desired. * people hate using prototypes way, if going * apply more 1 date object, having prototype * makes sense. **/ date.prototype.tomysqlformat = function() { return this.getutcfullyear() + "-" + twodigits(1 + this.getutcmonth()) + "-" + twodigits(this.getutcdate()) + " " + twodigits(this.getutchours()) + ":" + twodigits(this.getutcminutes()) + ":" + twodigits(this.getutcseconds()); };

asp.net - weird connection timeout issue -

i have asp.net site running on iis7 , in midnight, 5-7 minutes site down following error: error caught in application_error event exception type: system.net.sockets.socketexception error in: (url different withint site) error message: connection attempt failed because connected party did not respond after period of time, or established connection failed because connected host has failed respond stack trace: @ system.net.sockets.socket.receive(byte[] buffer, int32 offset, int32 size, socketflags socketflags) @ system.net.sockets.networkstream.read(byte[] buffer, int32 offset, int32 size) additional infomation: physical path: d(url different withint site) raw url: /default.aspx request type: google not usefull info on issue , nor myself cannot understand in code can happen because it's happening few minutes per day only, 30 minutes after midnight. that's not lot of information go on, if it's happening on predictable schedule that, pe...

String Manipulation in java -

i have 1 array of strings. want each of string, divide in 3 parts (number-string-number), , put each part in array. @ last want have 3 arrays 2 of them store numbers , 1 of them stores strings. number of spaces between numbers , strings not fixed. the format of strings in first array is: -2.2052 dalam -2.7300 -3.0511 dan akan -0.1116 it great if me sample code. here's algorithm implement : create 3 output arrays. should have same length original string array iterate through original array. for each string, find index of first space character , index of last space character. (look javadoc of string class methods doing that) extract substring before first space, substring between first , last space, , substring after last space. javadoc should you. convert first , third substring int (see javadoc double how it) store doubles , string ouput arrays.

reflection - Java reflecting nested anonymous classes -

why code return "class java.lang.object" ? object = new object() { public object b = new object(){ public int c; }; }; system.out.println(a.getclass().getfield("b").gettype()); why inner-inner type lost? how can reflect c field ? edit: this 1 works (as pointed out in answers): a.getclass().getfield("b").get(a) ... but have invoke getter, there way reflect c reflection meta data? because b declared object : public object b = ...; there distinction between type of variable (static type) , type of object referenced variable (runtime type). field.gettype() returns static type of field. if want runtime type of object referenced field, need access object , call getclass() on (since a declared object , therefore b not visible member have use reflection access it): system.out.println( a.getclass().getfield("b").get(a).getclass()); update: can't reflect c without accessing instance of object c...

jQuery Masonry conflict with jQuery UI Sortable -

jquery ui sortable not working when using masonry. idea how avoid conflict? appreciated. i think had similar problem. i managed fix recalling masonry within code setting sortable elements. (there might better way, i'm not sure?) $(function() { $("#youritem").sortable({ opacity: 0.9, cursor: 'move', update: function() { var order = $(this).sortable("serialize") + '&action=updaterecordslistings'; $.post("dosomething.php", order, function(theresponse){ //you can see i've re-called masonry once sortable object has been moved $('#youritem').masonry({columnwidth: 200, itemselector: 'youritem' }); }); } }); }); hopefully helps out – if there way i'd know.

firefox - How are they displaying one character for other -

please see this page , guide me: http://te.wikisource.org/wiki/%e0%b0%8b%e0%b0%97%e0%b1%8d%e0%b0%b5%e0%b1%87%e0%b0%a6%e0%b0%ae%e0%b1%81_-_%e0%b0%ae%e0%b0%82%e0%b0%a1%e0%b0%b2%e0%b0%ae%e0%b1%81_1_-_%e0%b0%b8%e0%b1%82%e0%b0%95%e0%b1%8d%e0%b0%a4%e0%b0%ae%e0%b1%81_1 in last 1 line, స నః పితేవ సూనవే ऽగ్నే సూపాయనో భవ | using this: ऽ, getting ఽ in firefox browser. how possible? but, safari not showing that. looks normal, ऽ. another thing firefox browser can't show unicode character properly, gives box, may see above, not there, in wikisource! getting perfect symbol. are showing image? if see view source, looks ऽ. trick of css or javascript or else? this font issue. wikisource doesn't specify specific font text, uses generic font-family: sans-serif; i assume safari , firefox choose different fonts standard sans-serif font on system, different characters ऽ . why is, can't tell because i'm not familiar telugu alphabet . these characters interchangeab...

symfony1 - A lot of records in database -

i'm planning project site have 10 thousand users. in service 5 thousand static products stored in 1 table. each user have minimum 1 thousand products (max 5 thousand). , have question: how design relational model? of course users tables ok. i keep about: 10,000(users)*1,000(products) = 10,000,000 records. have 1 idea: create (for example) 100 tables , assign each products of user 1 table. user update 50 records every day. i use symfony 1.4, doctrine 1.x , mysql/postgresql. it's idea? 100's of tables same definition? sorry terrible idea. databases nowadays plenty capable of handling multi million row tables.

networking - Linux monitoring - Nagios and nrpe -

the communication between nagios , nrpe agent installed in monitored machined can without ssl? problem have 2 different versions of linux , cant find compatible versions of libssl-dev that. yes. check_nrpe plugin, used call command check on remote host (defined in nrpe.cfg file), supports -n option: not use ssl.

asp classic - ASP script code inside ASP.NET page? -

Image
how use asp code inside asp.net ? is possible run asp script code inside asp.net page ? if so, please give example. thanks -- asp code might this. how such such script inside asp.net ? function changecolor(value, random) dim colorarray colorarray = split(value, ",") divblockcolor = colorarray(random mod (ubound(colorarray) + 1)) end function i'm affraid isn't possible, asp code runs in different application environment asp.net. that's why example session("xyz") not shared between classic asp , asp.net web pages in same website. what could leave asp code in .asp page , , use forms post go , forth asp code. way not have rewrite entire .asp environment, , can migrate .net 1 bit @ time. this way can leave existing code, , use simple javascript automatically submit forms, posting values .net

html - Call iPhone Photo Library on WebView Button Click -

how can call iphone photo library when html button element (e.g., <input type="button"> ) clicked in webview? appreciated. one way call custom url open:\\imagebrowser then in uiwebviewdelegate catch url , open photo library picker: - (bool) webview:(uiwebview *)webview shouldstartloadwithrequest:(nsurlrequest *)request navigationtype:(uiwebviewnavigationtype)navigationtype { if ([[[request url] absoluteurl] isequaltostring:@"open:\\imagebrowser"] { // open image picker } }

new to ruby, help with simple output -

Image
i trying learn ruby, , trying exercise on site , need learn ruby write program asks number , sentence , prints sentence backwards many times. should: puts "enter number?" repeathello = gets = 0 begin puts "hello world!" + end while > repeathello you're making 2 mistakes in code pasted. first need add 1 each time loops. @ moment not increasing in value. within loop (between begin , end) need increment so: i += 1 (this shorthand = + 1). the second mistake on last line. reads 'do while greater repeathello', starts @ 0, not going greater. you need switch around to while < repeathello. you should end code this: puts "enter number?" number = gets puts "enter sentence?" sentence = gets = 0 begin puts sentence.reverse += 1 end while < number

c# - Viewing Entity SQL produced by Linq-to-Entities -

is there way can view entity sql (esql) linq-to-entities queries generating ef framework (that is, not native sql, esql, if makes sense?) thanks! you can't. not generated. actually, linq entities queries translated directly expression tree, , nodes of expression tree translated sql clauses, , integrated sql query. no entity sql.

asp.net - JsonResult or Json: which to use? -

in asp.net mvc 3, more correct use: json() or new jsonresult() ? either returns same result. helping solve office debate. json() extension method returns jsonresult object behind scenes (rather needing call constructor directly). i use extension method myself. keeps more in line other common return types action methods view() , partialview() , etc. i make sure create extension method custom actionresult types create. in end it's matter of personal preference.

database - DBunit can't find tables defined on dataset -

i have dataset (defined in xml) , using postgresql, pojos annotated jpa, , dbunit junit tests. when test runs, creates tables , sequences in database, when starts read dataset (xml) table definitions , columns, fires following error org.dbunit.dataset.nosuchtableexception "nameoftable" tried put name of table caps , normal caps, , won't work. table created in public schema, , tried define in xml table public."nameoftable" won't work.... ideas? i tried run tests dunit in following versions: 2.2.2, 2.3.0, , 2.4.5. thanks. with dbunit can either use specific schema test against, or full database (with potentially multiple schema). if use latter need specify schema in dataset when importing/exporting or can confused; in postgresql @ least, i've not tried else. to enforce add following code in: if (strschema == null || strschema.isempty()) { conn = new databaseconnection(jdbcconnection); conn.getconfig().setproperty( ...

payment - How to charge credit card AND set up automated recurring billing in one step with Authorize.Net -

i’m integrating authorize.net web application. i’ve used direct post method (dpm)to charge account initially. however, each transaction need set automated reoccurring billing. how go doing without asking information again, particularly when after dpm posts initial transaction, credit card data no longer available? i status of each reoccurring transaction can confirmed , followed on if necessary. you can't dpm takes user's credit card information off of website don't have access it. if want make initial payment , use arb create subscription need use aim arb.

.net - C#: is there a way to set a property of objects in a collection using lambda expression? -

i developing small project , thought try don't know can learn new. have collection of messages, called msgs. filter unread ones , set "read". that, called method lambda expression, imagine list of messages unread. set value "read" (assigning 't' messageread property). there way using lambda expressions? i got code, "all" method not loking for, found out checks if elements in list match condition. msgs.where(message => message.messageread == 'f').all(message => message.messageread = 't'); thanks lot, oscar what after foreach extension method, see discussions here: linq equivalent of foreach ienumerable<t>

What's wrong with my VHDL testbench? -

Image
i've created testbench test adder carry circuit (although doesn't matter circuit doing) you can see below i'm getting 'error' failures spit out testbench.at 261901ps, show values here in isim debugger.. test_s(8) , (0) both '1' , cout '1'. now, testbench looks this: assert (test_s(8) = cout) report "carry out failed cin = 1!"; so what's wrong? tried /= cout in case.. , seem same thing. want say, if test_s msb (8) different cout, issue error because that's broken behavior cout std_logic; test_s std_logic_vector(8 downto 0); your vhdl correct. asserting test_s(8) should equal cout , report when not. at cursor on waveform, test_s(8) 0 , cout 1. assert detecting , reporting it.

osx - The 'Open with' option is automatically changed with my app when my app is installed -

i developing desktop application organizes , plays movie files. so, have added mp4, mov, avi, m4v (mp4, mov, avi, m4v extensions) document type under properties of application target. problem when user installs app in applications folder of system, default option opening mp4 movie file changes voila quicktime player automatically. default option nothing 'open with' option provided in info window of file. happens of users. why happening? how solve this? the answer found here: http://markmail.org/message/kf7lxgpu52nn34k2

c# - Web Control TreeView select a Node programmatically -

i use asp.net 4 , c#. have treeview , select existing node programmtically. selectnode() method read http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.treeview.selectednode.aspx so not know how it. please reply treeview web control not win app. my code: protected void uxtreeview_databound(object sender, eventargs e) { treeview mytreeview = (treeview)uxmanageslotsdisplayer.findcontrol("uxtreeview"); mytreeview.nodes[2].selected = true; } you can try setting selected property of particular treenode.

Reading PDF files in PHP -

possible duplicate: read pdf files php can read pdf files using php code? yes, can. either install command line script can convert pdfs text , execute in php $content = shell_exec('/usr/local/bin/pdftotext '.$filename.' -'); //dash @ end output content ( source ) ... or write a php function this .

Problem with Exception Handling in WCF, try catch not work -

i have wcf service (nettcpbinding, duplex) wich works well. today hit wierd problem. following code runs fine , if "new a("123");" throws exception, catched. [servicebehavior(instancecontextmode = instancecontextmode.persession, concurrencymode = concurrencymode.single)] public class service: itestservice { // interface defined [operationcontract(isoneway = true)], fire , forget public void test() { try { var t = new a("123"); } catch(exception ex) {} } } but if change a.dll , change method parameters, expect missingmethodexception. nothing wcf:( wcf service abort , on client side faulted event wcf channel. so why catch not work? wcf handle such xceptions on way? thx help the failure doesn't happen @ point when create a, fails @ jit compilation of method test outside of try/catch block. if move creation of method , call try block catch exception something this [servicebehavior(instanceco...

python - Defining appropriate number of processes -

i have python code treating lot of apache logs (decompress, parse, crunching numbers, regexping etc). 1 parent process takes list of files (up few millions), , sends list of files parse workers, using multiprocess pool. i wonder, if there guidelines / benchmarks / advices can me estimate ideal number of child process ? ie. having 1 process per core better launching few hundreds of them? currently 3/4 time of script execution reading files , decompressing them, , in terms of resources, cpu 100% loaded, memory , i/o being ok. assume there lot can done proper multiprocessing settings. script running on different machines / os, os-specific hints welcome, too. also, there benefit in using threads rather multiprocess? i wonder, if there guidelines / benchmarks / advices can me estimate ideal number of child process ? no. having 1 process per core better launching few hundreds of them? you can never know in advance . there many degrees of freedom. you ca...

android activity - GWT ActivityManager with Panels -

how come activitymanager can used 1 widget , not panel? activitymanager can used implements acceptsonewidget interface. commonly used simplepanel . inside can put type of panel or widget.

c# - Can I do automatic basic DataAnnotations validation with the IValidatableObject interface? -

i'm using lot of ef4 poco entities default dataannotations validationattribute (required, stringlength, regularexpression, etc) on properties (this generated t4 script use) , want custom validate of entities via ivalidatableobject interface. my question is: can call, in implementation of ivalidatable.validate() method, base method validating properties on assositiated validationattribute? cost time writing same code validating each property. example validation: public ienumerable<validationresult> validate(validationcontext validationcontext) { icollection<validationresult> validationresults = new list<validationresult>(); if (string.isnullorempty(databasename)) { validationresults.add(new validationresult(messages.error_orderedcomponentdatabase_databasename_required, new string[] { "databasename" })); } else if (databasename.length > 50) { validationresults.ad...

python - How to make a class property? -

this question has answer here: using property() on classmethods 14 answers in python can add method class @classmethod decorator. there similar decorator add property class? can better show i'm talking about. class example(object): the_i = 10 def __init__( self ): self.an_i = 20 @property def i( self ): return self.an_i def inc_i( self ): self.an_i += 1 # possible? @classproperty def i( cls ): return cls.the_i @classmethod def inc_i( cls ): cls.the_i += 1 e = example() assert e.i == 20 e.inc_i() assert e.i == 21 assert example.i == 10 example.inc_i() assert example.i == 11 is syntax i've used above possible or require more? the reason want class properties can lazy load class attributes, seems reasonable enough. here's how this: class classpropertydescriptor(object): ...

Capturing data with jQuery to use with PHP - non-standard implementation question -

i have unique setup in program have multiple fields, each non-standard attributes. for instance (general example): <textarea id=1 name='text1' level=1 parent=0></textarea> <textarea id=2 name='text2' level=1 parent=1></textarea> <textarea id=3 name='text3' level=2 parent=2></textarea> <textarea id=4 name='text4' level=2 parent=3></textarea> i want use jquery capture each individual elements , attributes , send them php script. i have yet able figure 1 out using clean method. ideas? add class each 1 of them , serialize them using jquery class selector?

javascript - jquery ajax get download file -

$.get( url: downloadurl, function(data) { //after data, how ask browser pop save file? } ); data content dumped server side servlet. can binary don't use ajax this, location = downloadurl;

form submit - Javascript Disabling and Timing -

i need update application when user clicks on button, etc of input fields become disabled. here have far javascript. following works , everything, no worries there. function disableallinputs() { var inputs = getallinputs(); (i = 0; < inputs.length; i++) { inputs[i].disabled = true; } } function enableallinputs() { var inputs = getallinputs(); (i = 0; < inputs.length; i++) { inputs[i].disabled = false; } } function getallinputs() { var inputs = document.getelementsbytagname('input'); var selects = document.getelementsbytagname('select'); var allinputs = new array(); var counter = 0; (i = 0; < inputs.length ; i++) { allinputs[counter] = inputs[i]; counter++; } (i = 0; < selects.length; i++) { allinputs[counter] = selects[i]; counter++; } return allinputs; } now, in html have this: <form name="myform" method="post" a...

java web start - Looking for Webstart Maven Plugin sample application -

i looking source code complete application uses webstart maven plugin. any ideas? i tried webstart plugin in prrof of concept involving embedded tomcat server. plugin bound package phase , takes longtime execute, recommend invoke manually command line. generates zip file in target directory containing jnlp file , dependencies. file can extraced , put on webserver. url in pom should point path on server. when started, app runs tomcat server on localhost port 8080 simple servlet returns requested path string. let me know if works you. here pom of project, plugin configuration copied documentation here <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelversion>4.0.0</modelversion> <groupid>net.jhorstmann</groupid> <artifactid>embedd...

java - How to create multiple files, generating a random name for each file -

what i'm trying create lots of random files i'm lost. code below doesn't work, i'm wondering why doesn't work , can fix it. import java.io.*; import java.util.*; public class main { public static void main(string arg[]){ random rn = new random(); int randn = 1+rn.nextint(999999990); string i_s = integer.tostring(randn); formatter file; try{ for(int = 0; < 9999999; i++){ file = new formatter("%s.txt", i_s); } } catch(exception ex){ system.err.println("error"); } } } by generating random numbers, may end creating / overwriting same file multiple times. have absolutely unique set, this: final int max = 9999999; list<integer> list = new arraylist<integer>(); (int = 0; < max; i++) { list.add(i); } collections.shuffle(list); (int = 0; < max; i++) { // create files here ...

Asp.net Dynamic Data 4 One-to-One ForeignKey.ascx Returning Primary Key -

i have dynamic data 4 site using linqtosql (.dbml) 2 tables one-to-one relationship. 1 table (child) not have row corresponding primary table. whenever case (no child table row) instead of empty row cell dd foreignkey.ascx field template displaying link to: childtable/detail.aspx?childpkfield=primarytableguid i can't find combination of sql f-key setups and/or .dbml column property settings prevent this. solution far custom foreignkey.ascx template protected string getdisplaystring() { object value = fieldvalue; if (value == null) { //replace //return formatfieldvalue(foreignkeycolumn.getforeignkeystring(row)); //with return ""; } else { return formatfieldvalue(foreignkeycolumn.parenttable.getdisplaystring(value)); } } obviously not optimal solution. simplify have removed custom metadata both tables , other relationships tables invol...

indexing - What is generic name of this technique CouchDB uses to index aggregated data -

couchdb employs a cool pattern can used in multitude of other scenarios. i'm talking persisted b-tree index of map/reduce results. idea precalculate aggregated data , store @ different levels of b-tree index. index can used efficiently query aggregate without having reaggregate data time. then, if leaf-level value changes, ascending path through tree has recalculated. for example, if data price on time, index store sum , count of items @ day, month, , year levels. then, if wants query average price year-to-date had sum sums , counts full months since year start, plus days available last month, divide total sum total count. if past price has change, change has propagate through index, corresponding day's , month's , year's values have updated, , values other days , other months within year can reused calculation. what generic name of approach? similar exists in of popular rdbmses? experience using in practice? materialized view "a materialized vi...

css - HTML table with drop down box -

i have table, need ask user select data given in dropdown list respect current cell of table. after value selected user, when dropdown list loses focus, want set value in same cell normal text data. means dropdownbox should disappear , new value should appear in same cell normal text data. please me regarding this. with pure css , html not possible (apart extreme hacking can't think of). the best thing can use javascript. , others have suggesting jquery useful library make web development javascript easier.

iphone - Can I add OBject of button to NSMutableArray? -

i trying create number of buttons on view programatically , need array, can add button object in nsmutablearray ? yes can see following code // create buttons sliding menu. simplicity create 5 standard buttons. nsmutablearray *buttonarray = [[nsmutablearray alloc] init]; for(nsinteger = 0; < [self.slidemenuarray count]; i++) { // rounded rect nice uibutton *btn = [uibutton buttonwithtype:uibuttontypecustom]; nsstring *title=[slidemenuarray objectatindex:i]; [btn setframe:cgrectmake(0.0f, 4.0f, 90.0f, 20.0f)]; [btn settitle:[nsstring stringwithstring:title] forstate:uicontrolstatenormal]; [btn setbackgroundcolor:[uicolor clearcolor]]; [btn settitlecolor:[uicolor whitecolor] forstate:uicontrolstatenormal]; [[btn titlelabel] setfont:[uifont systemfontofsize:12]]; [btn addtarget:self action:@selector(buttonpressed:) forcontrolevents:uicontroleventtouchupinside]; uiimage *backgroundview; if(i==0) backgr...

sql - Count million users from DB realtime? -

what's efficient way select count(*) db in order count registered users , create counter realtime (or realtime)? dont want run query every second (on mln users)..was thinking running each hour , calculate new users , create estimated counter.. things tracking visitors won't work, bc come lots of sites, have use users database.. suggestions? what db? both sql server , oracle instance can maintain count in indexed (materialized) view. eg on sql server: create view metric schema binding select count_big(*) registeredusercount dbo.users ...; create clustered index cdxmetric on metric(registeredusercount); the engine maintain count accurate you, see improving performance sql server 2008 indexed views : select registeredusercount dbo.metric (noexpand); furthermore, can cache result , automatic invalidation, see linqtocache . if on mysql backed system, best way count once, keep count in memcached , update when register new user.

i want to scroll an Image in HTML without using <marquee> tag.... with the help of javascript -

i want give dynamic effect image in javascript...but without using of marquee there reason why hates <marquee> tag. that being said, try: http://www.vegabit.com/jquery_scroller/ (demo) http://plugins.jquery.com/project/jqscroller http://jscroller.markusbordihn.de/example/left/ (demo) http://jscroller.markusbordihn.de/example/ http://remysharp.com/demo/marquee.html (demo) http://remysharp.com/2008/09/10/the-silky-smooth-marquee/ this 1 doesn't require jquery: http://jscroller2.markusbordihn.de/example/left/ (demo) http://jscroller2.markusbordihn.de/example/

c# - Removing duplication in Test Driven Development -

i developing small parser class tdd style. here tests: ... [testmethod] public void can_parse_a_float() { initializescanner("float a"); token expectedtoken = new token("float", "a"); assert.areequal(expectedtoken, scanner.nexttoken()); } [testmethod] public void can_parse_an_int() { initializescanner("int a"); token expectedtoken = new token("int", "a"); assert.areequal(expectedtoken, scanner.nexttoken()); } [testmethod] public void can_parse_multiple_tokens() { initializescanner("int float b"); token firstexpectedtoken = new token("int", "a"); token secondexpectedtoken = new token("float", "b"); assert.areequal(firstexpectedtoken, scanner.nexttoken()); assert.areequal(secondexpectedtoken, scanner.nexttoken()); } what bugging...

javascript - INVALID_STATE_ERR: DOM Exception 11 -

ok, i've created working javascript ajax file, generates absurd number of these dom exceptions. i'm not sure why is, because can see, elements call still in existance. code here: window.onload = function(){init();} function init() { ajax = ajaxinit(); setinterval(function(){ajaxcontact(ajax);},2000); ajaxcontact(ajax); ajax.onreadystatechange = function() {update(ajax);} } function ajaxinit() { if (window.xmlhttprequest) { ajax = new xmlhttprequest(); } else { if (window.activexobject) { ajax = new activexobject("microsoft.xmlhttp"); } } if (ajax) { document.getelementbyid("status").innerhtml = "ajax initialized"; return ajax; } else { docuement.getelementbyid("status").innerhtml = "error: ajax not available"; return false; } } function ajaxcontact(ajax) { try { ajax.open("get",...

c# - Convert or cast object[] to xml document and retrieve values from xml nodes -

what optimized code converting object[] xml document? in function service return type object [] , object returned contains list of xml elements. need convert object[] xml data retrieval. also optimized code retrieving values particular node ( node name project) , values list ( abc, xyz) navigating through xml document given? <?xml version="1.0" encoding="utf-8" ?> <arrayofanytype xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema"> <anytype> <attributes xmlns="http://services.abc.com"> <attributes> <name>projectdetails</name> <values> <values>abc</values> <values>xyz</values> </values> </attributes> </anytype> </arrayofanytype> xmlserializer pretty job on serializing objects. no idea on optimized..it's .net..so uses optimal dat...

java - What are maven coordinates of Tomcat JDBC Connection Pool? -

what maven coordinates of tomcat jdbc connection pool ? with improved search functionality on maven central repository website can query artifacts given class name. query fc:"org.apache.tomcat.jdbc.pool.datasourcefactory" returns following artifact: <dependency> <groupid>org.apache.tomcat</groupid> <artifactid>tomcat-jdbc</artifactid> <version>7.0.42</version> </dependency> there multiple older versions , newer rc versions available.

java - Can someone explain what this error means please? -

java.lang.nullpointerexception @ java.lang.integer.compareto(unknown source) @ java.lang.integer.compareto(unknown source) i edited code, deleted no methods changed name of 1 or two, , now...boom! nothing works ! annoying because had working, went , commented , can't see whats changed...help ? :) you're trying this: integer = null; integer j = 42; i.compareto(j); // throws nullpointerexception since null or this: integer = 21; integer j = null; i.compareto(j); // throws nullpointerexception since j null but haven't shown code.

motorola droid - Problems loading MOTODEV_Studio_for Android_2.1.0_Windows-x86 -

i tried install motodev , experienced problem looking android sdk r10. kept complaining found r9. tried reinstall r10 , ran back/next problem installer. after many hours of frustration figured out motodev still didn't recognize r10. so took apple approach, uninstalled, java sdk, android sdk, eclipse, , motodev. cleared off remnants on disk start clean. i install each component clean in order: java sdk (jdk-6u24-windows-i586) android sdk (installer-r10-windows) 3.android compatibility package rev 1 4.third party add-ons google usb driver package rev 4 google market license package rev 1 google market billing package rev 1 5.virtual devices 2.2 api 8 2.3.1 api 9 2.3.3 api 10 3.0 api 11 eclipse (eclipse-sdk-3.6.1-win32.zip) c:\eclipse eclipse android plugin everything worked ok........................ then reinstalled motodev motodev (motodev_studio_for android_2.1.0_windows-x86) c:\program files\motorola mobility\motodev st...

android - Gridview with imageview and textview -

i found example http://www.firstdroid.com/2011/02/06/android-tutorial-gridview-with-icon-and-text/ force close , don't understand why... in logcat : 07-22 09:40:00.767: error/androidruntime(320): caused by: java.lang.classnotfoundexception: android.view.linearlayout in loader dalvik.system.pathclassloader@44dac780 07-22 09:40:00.767: error/androidruntime(320): @ dalvik.system.pathclassloader.findclass(pathclassloader.java:243) 07-22 09:40:00.767: error/androidruntime(320): @ java.lang.classloader.loadclass(classloader.java:573) 07-22 09:40:00.767: error/androidruntime(320): @ java.lang.classloader.loadclass(classloader.java:532) 07-22 09:40:00.767: error/androidruntime(320): @ android.view.layoutinflater.createview(layoutinflater.java:466) 07-22 09:40:00.767: error/androidruntime(320): @ android.view.layoutinflater.oncreateview(layoutinflater.java:544) 07-22 09:40:00.767: error/androidruntime(320): @ com.android.internal.policy.impl.phonelayoutinflate...

Sha1 generates different hash's from the same string in php when submitting from a different form -

so have weird problem. have login script , type in username , password. once password posted sha1 php function sha1() , compare sha1 version in database. if match logs in. part works fine. have same functionality mobile version, uses different form , different url. after type in password exact same steps, sha1 hash posted different sha1 hash in database. know type them in same each time, don't see why 2 values different. true username / password combination. missing something?? there no reason same text produce different sha1 values. i suggest log real password values before sha1 generated debug problem. i suspect may entering passwords different case or padded spaces or other characters reason.

php - only allow certain ips to access my "family site"? -

for days have been struggeling making ips accessing family site since want family enable access site. ill need guys. how far have gotten , if ip not in database redirect www.google.com . the code: $ip =$_server['remote_addr']; $result = mysql_query('select * `ips` `ip`="' . $ip . '"'); if(mysql_affected_rows($link) < 0){ header('location:http://google.com'); } edit: got idea of can use wont change computer mac address code need change of table , names inside. how go , when user try access site check if mac adress of computer in database else redirect google.com. kind regards fredrik if use apache webserver can change directory node content in httpd.conf configuration file allow your_ip , deny all. more suitable place create such restrictions. note default apache access <directory /> allow all. means apache serve file mapped url. change block such as <directory /> order deny,allow deny all...

client server - Hey need help with a mysql exception i am getting abt communication link failure -

hey guys, m running mysql server on host machine. code provided below.when try 2 run same code machine connected same router.i exception hav provided below code. please help. code:- import java.sql. ; import java.io. ; public class login{ public static void main(string[] args) throws ioexception { bufferedreader br=new bufferedreader(new inputstreamreader(system.in)); connection conn = null; string url = "jdbc:mysql://"+br.readline()+":3306/"; string dbname = "p2p"; string driver = "com.mysql.jdbc.driver"; string username = "root"; string password = "123"; system.out.println("please input username:"); string user=br.readline(); system.out.println("please input password:"); string pass=br.readline(); try { class.forname(driver).newinstance(); conn = drivermanager.getconnection(url+dbname,username,password); string sql="select password newuser username='"+user+"'";...

Load a single-column CSV file into a Ruby array -

i new ruby. below naive code load single-column csv file ruby array. question: there better? in particular, how not hard-code number of items? require 'csv' countries = array.new(240) = 0 csv.foreach "#{rails_root}/config/countries.csv" |country| countries[i] = country[0] = + 1 end try this: require 'csv' countries = csv.read("#{rails_root}/config/countries.csv").flatten

Tracking Facebook "Like" Referrals -

this not related tracking facebook "likes" independent website. looking find if facebook api supports tracking of referrals via likes. example, have auto repair/maintenance client. want add promo welcome landing page allows users refer friends "like" company page. once has referred 10+ "like"'s, company offer referrer free oil change or something. thoughts or idea here? not find native app, maybe not searching enough. i'm not sure if understood question correctly, let me try: have website http://client.com/ has referral system, example user a (which id = 1234 ) have referral url: http://client.com/landing_page.php?ref_id=1234 and on page, have facebook button. need "capture" if likes company page came url? okay, facebook provides event track when user "likes" something. it's called edge.create there can increment user referrals. for example on page ( landing_page.php ) http://client.com/landi...

validation problem with JSF h:form and PrimeFaces p:dialog -

i have jsf page create form. form consists of variety of input fields , list of sub-elements. to add sub-element, click "add element" link pops dialog box using primefaces p:dialog tag. it's similar login panel demo on prime faces page here, complete p:growl validation messages: http://www.primefaces.org/showcase/ui/dialoglogin.jsf my problem is, when click "add" in dialog box see growl validation messages fields in dialog box , fields on main form. want see messages dialog box. is there way this? tried embedding form within form, didn't work. is, tried ... <h:form> <p:messages /> <!-- show validation messages create form contents --> <h:inputtext value .../> <h:datatable value .../> <!-- list of sub elements --> <h:commandlink "shows add element dialog" ... /> <p:growl /> <!-- shows validation messages dialog contents --> <p:dialog> <h:form...

html - What's the state of the art for scientific graphics on websites? -

basically want build web interface server-side math engine. (like simplified version of qtoctave/gsl.) haven't seen many resources generate mathematical graphs on client side--bar plots, heat maps, etc. support in html5 seems lacking, this short discussion suggests. there web equivalent qwt, jcharts, etc.? what protovis? http://vis.stanford.edu/protovis/

design patterns - Is there a Ruby-Way™ to handle this kind of loop? -

i trying print section titles grouped elements in flat array. section title appear once per group. the example below works, feels pretty inelegant ruby. i'm there must better way ;) #!/usr/bin/ruby foo = [1,1,1,1,2,2,2,3,3] = 0; f = foo[i] comp = f while(i < foo.count) puts "section #{f}"; while(f == comp) puts f += 1 f = foo[i] end comp = f end desired output section 1 1 1 1 1 section 2 2 2 2 section 3 3 3 i hoping there kind of array#current or array#next instance methods, looks ruby array objects don't keep internal iterator. foo.group_by{|e| e }.each |header, group| puts "section #{header}" puts group.join("\n") end

mysql - How do I group a query after ordering it? -

i'm trying group query after order it, however, in sql (im using db2) can't group after doing order, if order after grouping grouping changes. reason because grouped based on multiple attributes not 1 (i need group 1 attribute since required match select statement have group multiple attributes. i tried doing virtual table using "with" , tried order within db2 says can group , not order inside attribute the same goes in statement . tried doing nested query inside attribute returns ordered result db2 restricts ordering inside attribute (only grouping allowed) so i'm not sure how this, how can group after ordering it? here sample table: pokemon: id name age 3 pikachu 1 2 bulbasure 3 1 charazard 2 11 pikachu 10 (in pokemon table) primary key id, name foreign key (name) references pokedex (name) ) pokedex: id status pikachu derp charazard herp bulbasure burp now i'm tr...

css - jquery ui date picker icons messed up -

Image
im using jquery ui datepicker. reason experiencing strange behaviour icons. word "next , "prev" appearing on top of icons. when hover next , prev words show in red (my link hover color). what wrong? working previously. was bizarre bug. an outer div containing datepicker had css style text-align right on it. when remove it worked. weird.

string - Finding all possible case permutations in Python -

i need work out list of possible permutations of case only in python example input of ar return [ 'ar','ar','ar','ar'] or arc [ 'arc','arc','arc','arc','arc','arc'] , know there nice method life of me can not figure out. def all_casings(input_string): if not input_string: yield "" else: first = input_string[:1] if first.lower() == first.upper(): sub_casing in all_casings(input_string[1:]): yield first + sub_casing else: sub_casing in all_casings(input_string[1:]): yield first.lower() + sub_casing yield first.upper() + sub_casing >>> [x x in all_casings("foo")] ['foo', 'foo', 'foo', 'foo', 'foo', 'foo', 'foo', 'foo'] >>> list(all_casings("foo")) ['foo', 'foo...

Windows Workflow 4 Set Properies? -

i have invokemethod activity in sequence "myobject", , run methodname "mymethod". method takes no parameters, mymethod expects value there. if calling object c# code do var myobject = new myobject { myparam = }; is there way in wf? thanks. it depends on how instance of myobject instantiated. the easiest way set myparam property when creating instance. if in variables tab given scope, set default follows: new myobject {.myparam = something} note must use vb.net syntax. alternately create custom class descends codeactivity , write c# code. won't need invokemethod activity then.

how to enable process control extension (PCNTL) in PHP MAMP? -

have mamp , need enable -pcntl on current mamp installation. how can so? thanks help. there way of compiling pcntl extension , linking in existing php build, it's bit in-depth. i'm doing following on mac osx snow leopard (64bit), mamp , php version 5.3.6. remember change php version numbers in following lines if yours different! please note make required, isn't installed default on mac osx. need install via mac developer tools, http://developer.apple.com/unix/ first, download tar of php source code matches version using in mamp (e.g. mine 5.3.6), can @ http://www.php.net/releases/ . untar , cd php-[version]/ext/pcntl , e.g.: $ wget http://museum.php.net/php5/php-5.3.6.tar.gz $ tar xvf php-5.3.6.tar.gz $ cd php-5.3.6/ext/pcntl you need run phpize in pcntl directory, binary file comes mamp: pcntl$ /applications/mamp/bin/php/php5.3.6/bin/phpize this creates bunch of files needed preparing extension compiling. we need add flags tell compile li...

Problem processing an array of textareas when they are loaded dynamically with jQuery and PHP -

Image
i experiencing problems trying multitextarea on form. i've php view has various forms, processed different in same file. works, i've tested , works. in forms there + icon let user add more instances of <textarea /> . + icon loads via ajax new textarea same name of previous textarea (for example, name="example[]"). if post this, gets first item 1 wasn't loaded jquery. problem ones loaded dynamically totally ignored , don't know why. my extract of php view: <?php echo form_open("projects/view/".$projectid); ?> <!-- generates valid <form /> tag --> <table> <tr> <th><?php echo lang("label_conx");?></th> <td class="textarea-edit"> <textarea class="context" name="conx[]"><?php echo set_value("conx[]");?></textarea> </td> ...

Rails nested form new association -

i creating form nested attributes. relevant parts there sale model (the master model form), vehicle model (sale has_one vehicle , vehicle belongs_to sale), , registration_number model (many many vehicles, through assignment table). i using excellent flexbox jquery plugin, allows existing item selected or new item created. because working flexbox, fields in question being coded largely in html, bypassing rails helpers. when attempt create new registration number (using field name sale[vehicle_attributes][registration_numbers_attributes][0][number] ), works great, new registration number created , assigned vehicle. when try assign existing registration number (using field name sale[vehicle_attributes][registration_numbers_attributes][id] ), however, following error: couldn't find registrationnumber id=3 vehicle id=5 this doesn't seem make lot of sense - way see it, rails should trying create association, not find existing association? ideas might doing wrong? t...

winapi - print callstack of a thread (c++), StackWalker or not? -

needing print callstacks of c++ application thread thread handle, turned stackwalker mentioned in previous stackoverflow answers. however, the stakwalker code dated 2005. suspect changed since then. when compile , run it, error (below), , output seems incomplete, truncated @ error. test shall print more testcases. does have updated or different working callstack-printing published code ? e:\boris\stackwalker\stackwalker\main.cpp (31): func5 e:\boris\stackwalker\stackwalker\main.cpp (32): func4 e:\boris\stackwalker\stackwalker\main.cpp (33): func3 e:\boris\stackwalker\stackwalker\main.cpp (34): func2 e:\boris\stackwalker\stackwalker\main.cpp (35): testcurrentthread e:\boris\stackwalker\stackwalker\main.cpp (139): main f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c (582): __tmaincrtstartup f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c (399): maincrtstartup vvvvv error: symgetlinefromaddr64, getlasterror: 487 (address: 7c817077) ^^^^^ 7c817077 (kernel32): (filenam...

python - Inserting email into auth_user in web2py on first time login while using pam_auth -

i using pam_auth login web2py installation. when user logs in first time, want store email obtain ldap query. how can in web2py. in other words, want execute piece of ldap query in python @ time of first login user. web2py default authentication system has event table, stores every event user. i.e stores events registration, login, logout, etc. so can see if first time login querying table. user_id = #get user id query = (db.auth_event.description.like('%logged-in%'))&(db.auth_event.user_id==user_id) if db(query).count() == 1: #this first login of user ldap_mail = #call ldap email #store email adress in auth_user db(db.auth_user.id==user_id).update(email=ldap_mail)

php - the_post_thumbnail() without proportion -

is possible tell wordpress show the_post_thumbnail() without proportion rate. i need width , height want the_post_thumbnail(array(350,350)); if image larger height, put height 350px , ignore width i've set 350 too. how hack ? just use timthumb method explained here: http://www.binarymoon.co.uk/demo/timthumb-basic/ works great , let need after copying timthumb.php proper wp theme directory. pass source image , h x w of exact size of final cropped image, so: timthumb.php?src=castle1.jpg&h=350&w=350 instructions , examples provided following above link. good luck!! marcelous

visual studio 2008 - Trouble connecting to remote private msmq to read -

i not windows security expert. want lay out right away. i built windows service running on windows 7 machine trying receive messages private msmq on machine (within same domain). machine running windows 2003. have windows service run local system. getting "access message queuing system denied." exception. don't know best solution is. should create specific account service run under , give necessary permissions account under queue? should change service run under networkservice, or that? like said earlier, not windows security expert, advice appreciated. thanks one part of problem generic non-expert windows security. if want access resource, file share or message queue, need have permission. host queue doesn't know accounts local windows 7 machine. both machines in same domain make sense run windows service under domain account. can set permissions on queue accordingly. the other part of problem how pull messages remote queue. isn't si...

java - Eclipse reporting problem in my web.xml, but it is processed fine -

i'm using google app engine google plugin in eclipse, here header of web.xml: <?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> based on of gae documentation, added this: <security-constraint> <web-resource-collection> <url-pattern>/tasks/*</url-pattern> </web-resource-collection> <auth-constraint> <role-name>admin</role-name> </auth-constraint> </security-constraint> however eclipse reports error @ "url-pattern": cvc-complex-type.2.4.a: invalid content found starting element 'url-pattern...