Posts

Showing posts from February, 2012

javascript - Focusing next text field on condition satisfaction -

i trying learn jquery. have 2 text fields. when length of first field becomes 3 need cursor move next text box. how can accomplish it? please me find answer <input id="phone_field1" maxlength="3" name="phone_1" type="text"> <input id="phone_field2" maxlength="3" name="phone_1" type="text"> my code given here. please me. do below: $('#phone_field1').on('input',function(){//or keyup,you can use input rather id if($(this).val().length == $(this).prop('maxlength')){ $(this).next().focus(); } }); add missing bracket.

javascript - Jqgrid not showing data on reloading when using GroupView and loadonce as true -

i using jqgrid 4.6 loadonce true , grouping column. have sorted data coming server per documentation of grouping given here . can't see data in grid when try reload data using below code jquery("#ramtargettable").jqgrid('setgridparam',{datatype:'json'}).trigger('reloadgrid'); below code jquery("#ramtargettable").jqgrid({ url: '<%=url.content("~/ramtarget/gettargetdata")%>', width: 1220, height: 250, datatype: "json", colnames: [my column names], colmodel: [my model], emptyrecords: 'no turbines found selected plant', searchoptions: { searchhidden: true }, mtype: 'get', loadonce: true, hidegrid: false, rowlist: [], pager: ...

mysql - Better way to retrieve the Count of records -

i dealing small-scale website has tags identify genre of topic. every tag has followers similar so. when tag being entered, suggestions populate shows auto-completed tags along followers. what best way design table these tags ease retrieval follower-count , manage tags. 1. 'tags'( id int, tagname string) tag_followers( tag_id int, userid int) followerscount query : select count(*) tag_followers tag_id = (select id tags tagname = "games") ....... 2. 'tags'( id int, tagname string, follower_count int) tag_followers( tag_id int, userid int) followerscount query : select follower_count tags tagname = "games" i had these 2 ideas. can't judge me in fast retrieval on long run. please me choose. also, if there better way above two, please suggest me. in advance. i suggest first approach , query should like: select count(1) tag_followers tf join tags t on tf.tag_id = t.id , ...

php - Overriding validation messages FOSUserBundle -

i overriding validation messages in entity. when got errors, validation messages displayed twice: first message fosuserbundle(login short) , second message(min 6). why? <?php namespace acme\userbundle\entity; use fos\userbundle\model\user baseuser; use doctrine\orm\mapping orm; use symfony\component\validator\constraints assert; /** * @orm\entity * @orm\table(name="users") */ class user extends baseuser { /** * @orm\id * @orm\column(type="integer") * @orm\generatedvalue(strategy="auto") */ protected $id; /** * @assert\length(min=5, max=16, * minmessage="min 6", * maxmessage="max 16", * ) */ protected $username; //.. } you need create own group of validators: http://symfony.com/doc/current/book/validation.html#validation-groups

SAS proc import .xls with several spreadsheet and append -

situation: have workbook .xls 4 spreadsheets named "sheeta", "sheetb", "sheetc", "sheetd" . for import 1 spreadsheet following. proc import out = outputtablea datafile = "c:\user\desktop\excel.xls" dbms = xls replace; sheet = 'sheeta'; namerow = 3; startrow = 5; run; all spreadsheet have same number of variables , format. combine 4 outputtablex using data step: data combinedata; set outputtablea outputtableb outputtablec outputtabled; run; i new sas, m thinking whether array , do-loop can help. i not use loop (as they're overly complicated). instead, make data driven. use reese's solution if can; if must use proc import due namerow/datarow options, works. first, create libname. libname mylib excel "c:\blah\excelfile.xls"; we won't use it, if prefer xls options, lets sheets. proc sql; select cats('%xlsimport(sheet=',substr(memname,1,len...

ios - How can I create 3 columns using UICollectionView -

i want create 3 columns uicollectionview, here code did: have attached uicollectionviewflowlayout uicollectionview , set itemsize collection view's width divides 3: self.collectionview.backgroundcolor = [uicolor bluecolor]; uicollectionviewflowlayout *flowlayout = [[uicollectionviewflowlayout alloc] init]; double width = self.collectionview.frame.size.width; width /= 3; [flowlayout setitemsize:cgsizemake(width, 100)]; [flowlayout setscrolldirection:uicollectionviewscrolldirectionhorizontal]; [self.collectionview setcollectionviewlayout:flowlayout]; but when run it, see 1 item per row width of item set correctly. right of item bunch of white spaces. can please tell me missing? thank you. update: i have tried minimum spacing set. still not work. see 1 column of cells: self.collectionview.backgroundcolor = [uicolor bluecolor]; uicollectionviewflowlayout *flowlayout = [[uicollectionviewflowlayout alloc] init]; [flowlayout setitemsize...

Cannot connect Wordpress to MySQL database -

doing local website work learn wordpress theme development. tried set wordpress through prompts, tried manually entering information in wp-config.php file, neither work. still cannot connect database, setup-config.php page returns "error establishing database connection". i've double, triple, , quadruple checked login credentials (database name, username, password etc.), complete , correct. deleted wp-config.php , tried again through web page, same result. mysql running, mac system preferences panel says so, , can login , run sql queries @ command line, although have root. should running mysql root? this problem exists wordpress , instance of phpmyadmin i've installed, don't think it's php code such, smells more permissions thing. it's worth, i've edited httpd.conf file wordpress on port 80 , phpmyadmin on 8081. apache serving sites should , php running, it's getting either site connect database that's problem. system information: ...

winapi - How To CaptureScreen at Virtual Desktop? -

i run test program windows8 or 7 64/32bit but can't capture screen when running virtual desktop here code hwnd h1 = createwindows(....) or dialog.. //if line remove capture code works fine hdesktopcurrent = null; horiginalinput = null; hdesktopcurrent = getthreaddesktop(getcurrentthreadid()); horiginalinput = openinputdesktop(0, false, desktop_switchdesktop); hdeskvirtual= null; attr.nlength = sizeof(attr); attr.lpsecuritydescriptor = null; attr.binherithandle = true; hdeskvirtual= createdesktopex( "my_new_desktop_1", null, null, 0, generic_all, &attr, 0, null); switchdesktop(hdeskvirtual); setthreaddesktop(hdeskvirtual); //capture here switchdesktop(originaldesktop); setthreaddesktop(originaldesktop); ps: when nerver create windows hwnd before switchdesktop (ex:createwindows,creatdialog...) works perfertly capture.. but create windows frame or dialog, didn't work captured blackscreen plz..help me!

vertica - Why does vsql can return all the records, while program using ODBC driver can't? -

Image
i simple test vertica : ha=> insert test(name, city) values( 'nan', 'nanjing'); output -------- 1 (1 row) ha=> select node_name, wos_row_count, ros_row_count projection_storage anchor_table_name = 'test'; node_name | wos_row_count | ros_row_count ---------------+---------------+--------------- v_ha_node0001 | 1 | 3 (1 row) ha=> select * test; id | name | city --------+------+--------- 250001 | nan | nanjing 250002 | nan | nanjing 250003 | nan | nanjing 250004 | nan | nanjing (4 rows) the select operation displays ok (the data in wos , ros all display). then write simple program uses odbc : ret = sqlexecdirect(stmt_handle, (sqlchar*)"select * test", sql_nts); if (!sql_succeeded(ret)) { printf("execute statement failed\n"); goto err; } while ((ret = sqlfetch(stmt_handle)) == sql_success) { row_num++; } printf("row number %d\n", row_num); ...

java - Same activity getting stacked -

i have activity suppose finish , close application. now, in cases, varying on how user navigating activity, activity getting stacked. when activity stacking up, calling finish() or android.os.process.killprocess(android.os.process.mypid()); or both showing same activity again. the manifest : <activity android:name="newactivities.homeactivity" android:label="@string/title_activity_home" android:screenorientation="portrait"> </activity> the activity : public class homeactivity extends activity { private edittext studentnameedittext; private button startyourstorybutton, loginbutton, navcollegesbutton, settingsbutton, search_friends_button, browsestoriesbutton; private textview textview1; @override protected void oncreate(bundle savedinstancestate){ super.oncreate(savedinstancestate); setcontentview(r.layout.activity_home); // if (getfrompreference...

java - Local variables referred from inner class must be final or effectively final -

please have @ below code private void displayinitialrevenue_method() { //get dates combo string selectedcouple = revenueyearcombo.getselecteditem().tostring(); if (selectedcouple.equals("select year")) { return; } string[] split = selectedcouple.split("/"); //related db double totalamount = 0.0; //get data database dbconnector = new dbhandler(); dbconnector.makeconnection(); defaulttablemodel model = (defaulttablemodel) initialrevenuetable.getmodel(); model.setrowcount(0); resultset selectalldetails = dbconnector.selectalldetails("sql code "); try { if (selectalldetails.isbeforefirst() == false) { joptionpane.showmessagedialog(null, "this table empty"); } else { while (selectalldetails.next()) { string clientname = selectalldetails.getstring("client name"); string providername = selectalldetails.g...

java - Returning NULL from string with appened chars -

the string dexversion returns null i tried many things taking string , appending readdata[] char , worked fine , tried see if char vs. character results inconclusive import java.io.*; import java.net.*; import java.lang.*; import java.util.*; class main { public static void main(string args[]) { string version = new string("1.0 (alpha)"); main main = new main(); datahandling data = new datahandling(); boolean doneprocessing = false; int x = 0,y = 0; string dexversion = new string("v:"); string pokemon[][] = new string[700][10]; system.out.println(":"); system.out.println("pokeutility:main_thread_started_in_static_method_main"); system.out.println("pokeutility:starting_version=" + version); system.out.println("pokeutility:downloading_pokedex_data"); data.download(); system.out.println("pokeutility:reading_...

javascript - Which is the better way , die or echo for ajax response? -

i using ajax in 1 of web pages this. have specified datatype json here. jquery.ajax({ url: "www.mydomain.com/ajax.php", type: "post", datatype: "json", data:{to_email_address:"myemail@gmail.com"}, success:function(response){ response = jquery.parsejson(response); if(response){ alert("success"); } else{ alert("failed, try again"); } } }); in ajax.php , use echo json_encode function follows <?php if(!($mail_to_address, $mail_subject, $content, $headers)) { echo json_encode(false); } else{ echo json_encode(true); } ?> but have seen somewhere , using die instead of echo like <?php if(!($mail_to_address, $mail_subject, $content, $headers)) { die(json_encode(false)); } else{ die(json_encode(true)); } ?> can please explain better way , why? in advance ...

How do I convert an unsigned integer to an integer in Rust? -

so i'm trying random number, i'd rather not have come uint instead of int... not sure if match right, either, compiler doesn't far because it's never heard of from_uint thing i'm trying do: fn get_random(max: &int) -> int { // here use * dereference max // ...that is, access value @ // pointer location rather // trying math using actual // pointer match int::from_uint(rand::random::<uint>() % *max + 1) { some(n) => n, none => 0, } } from_uint not in namespace of std::int , std::num : http://doc.rust-lang.org/std/num/fn.from_uint.html original answer: cast u32 int as . if cast uint or u64 int , risk overflowing negatives (assuming on 64 bit). docs: the size of uint equivalent size of pointer on particular architecture in question. this works: use std::rand; fn main() { let max = 42i; println!("{}" , get_ra...

c# - Chaining a compiled query's invocation -

suppose have compiled query hits db , select. func<mycontext, int, iqueryable<myresult>> myquery = compiledquery.compile<mycontext, int, iqueryable<employee>>((context, empid) => (ctx.employees.where(e => e.id == empid)); and myquery.invoke(ctx, parama).orderby(x => x.somecolumn).take(10).tolist(); will orderby done in-memory (i.e query context contains myquery) or invoke chain 'myquery' orderby , tolist() order , take done in db. believe latter. right?

html - Getting Form fields that were added using Javascript -

Image
i using code below add in new product line when user clicks on "add new item", once submit form added rows found. i have tried dumping form , form fields appear ones on page once has loaded cannot data rest of rows. i have tried moving form tags around without luck below page script use add in new rows: <cfinclude template="header.cfm"> <cfparam name="form.step" default="1"> <cfparam name="form.submit" default=""> <script type='text/javascript'> //<![cdata[ $(document).ready(function() { var currentitem = 1; $('#addnew').click(function(){ currentitem++; $('#items').val(currentitem); var strtoadd = '<tr><td class="copy" valign="top">item name:</td><td><input type="text" name="itemname'+currentitem+'" id="itemname'+currentitem+'" required="yes" message="pl...

jquery - how to send stringified Json from view to controller in MVC4 -

i want send stringified json object on button click. trying follows... on button click able call required action method, it's passing null parameter .. memberlogin.cshtml <input type="button" value="» continue" id="btnlogin" onclick="postdata();"> <script type="text/javascript"> function postdata() { var objlogindto = new object(); objlogindto.username = $("#txtusername").val(); objlogindto.password = $("#txtmemberpassword").val(); objlogindto.captchatext = $("#txtcaptcha").val(); var stringifieddata = json.stringify(objlogindto); $.ajax({ url: '@url.content("~/member/memberlogin/memberlogin")', async: false, type: "post", data: stringifieddata, datatype: "json", contenttype: "application/json; charset=utf-8", ...

behavior - Yii check scenario in beforeSave() -

for 1 action need transform $album_id before save db in model function beforesave() do: // преобразовать album -> album_id $album_id=array(); foreach($this->string2array($this->album, '\|') $one) $album_id[]=album::model()->findbyattributes(array('album' => $one))->id; $this->album_id = $this->array2string($album_id); but action don't need transform, because $album_id in proper state. set scenario 'batchcreate' in action: public function actioncreate() { yii::import('ext.multimodelform.multimodelform'); $model = new album('create'); $song = new song(); $song->setscenario('batchcreate'); ... } and try check scenario in model: if(!($this->scenario === 'batchcreate')) { // преобразовать album -> album_id $album_id=array(); foreach($this->string2array($this->album, '\|') $one) $album_id[]=album::model()->findbyattributes...

HTML drop down javascript help needed -

i have 2 html drop down <select> <option value="">please select</option> <option value="volvo">volvo</option> <option value="saab">saab</option> <option value="mercedes">mercedes</option> <option value="audi">audi</option> </select> <select> <option value="">please select</option> <option value="a">a</option> <option value="b">b</option> </select> now, if select volvo first drop down , b second dropdown , change audi in first dropdown, want value of second drop down show please select instead of b (selected previously) using javascript ps: new javascript it's easy as: <select onchange="document.getelementbyid('secondoption').selectedindex = 0;"> <option value=""...

javascript - How to remove duplicate row ids in array -

hi need array, when add item array need remove first otherwise becomes duplicate, have looked on site @ similar questions cant find right approach, have function adds item array if item selected in list seen below. var updateidsofselectedrows = function (id) { var index = $.inarray(id, idsofselectedrows); var rowdata = $("#unlinkedsamplestable").getrowdata(id); var selrowids = $("#unlinkedsamplestable").jqgrid("getgridparam", "selarrrow"); if ($.inarray(id, selrowids) >= 0) { idsofselectedrows.push(id); // add id statusesofselectedrows.push(rowdata.statusenum); // add status sampleidsofselectedrows.push(rowdata.sampleid); // ad sample id } else { //else remove idsofselectedrows.splice(index, 1); // remove id list statusesofselectedrows.splice(index, 1); // remove status list sampleidsofse...

uberjar - Running Spring boot fat JAR -

c:\users\sinpik\desktop\jar\extract>java -jar packageproject-client.jar java.lang.reflect.invocationtargetexception @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) @ java.lang.reflect.method.invoke(unknown source) @ org.springframework.boot.loader.mainmethodrunner.run(mainmethodrunner.java:53) @ java.lang.thread.run(unknown source) caused by: java.lang.noclassdeffounderror: org/springframework/boot/springapplication @ pachname.application.main(application.java:14) ... 6 more caused by: java.lang.classnotfoundexception: org.springframework.boot.springapplication @ java.net.urlclassloader$1.run(unknown source) @ java.net.urlclassloader$1.run(unknown source) @ java.security.accesscontroller.doprivileged(native method) @ java.net....

Tcl Script: Invalid command name return when executing proc body -

in tcl script, want catch return of tcl proc in order execute finalization actions. example code follows: proc x10 { } { return [expr $a * 10] } proc procf {} { set 13 catch {[info body x10]} __result return $__result } procf the previous code gives me error: invalid command name " return [expr $a * 10] " although replacing info body x10 return [expr $a * 10] works expected. thought both of them exchangeable , should give same output. so, why first gives error , difference between both of them ? your code failing because getting body of x10 , treating command name. tcl doesn't split things automatically — have ask — , critical language safety factor. you'd have this: proc procf {} { set 13 catch {eval [info body x10]} __result return __result } or (because first argument catch script): proc procf {} { set 13 catch [info body x10] __result return __result } but i'd inclined in case (as presented ex...

Android: remove a TextView after an animation -

in app add textview programmatically , after animation (traslate+alpha) in way textview point = new textview(getapplicationcontext()); //... option textview animation anim = animationutils.loadanimation(getapplicationcontext(), r.anim.move_result_point); anim.setanimationlistener(this); point.startanimation(anim); my xml animation is <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/linear_interpolator" android:fillafter="true"> <translate android:fromydelta="0%p" android:toydelta="-50%p" android:duration="700" /> <alpha android:fromalpha="1" android:toalpha="0" android:duration="700"/> </set> the want remove textview generated when animation finish, know can in @override public void onanimationend(animation arg0)...

c# - Read multiple lines with StreamReader with StreamReader.Peek -

let's have following file format (key value pairs): objec1tkey: object1value object2key: object2value object3key: object3value object4key: object4value1 object4value2 object4value3 object5key: object5value object6key: object6value i'm reading line line streamreader . objects 1, 2, 3, 5 , 6 wouldn't problem because whole object on 1 line, it's possible process object. but object 4 need process multiple lines. can use peek this? ( msdn peek: returns next available character not consume it. ). there method peek returns next line , not character? if can use peek , question is, can use peek 2 times can read 2 next lines (or 3) until know there new object (obect 5) processed? i recommend separate io line handling entirely. instead of making processing code use streamreader , pass either ilist<string> or ienumerable<string> ... if use ilist<string> make easy access lines index (so can keep track of "the key i'm processing s...

Remove bloggers automatic 'add URL' feature to menu items -

my blogger template ( klarity ) automatically adds domain name infront of link want add menu. example: want create link page 'about'. need create list item link pointing towards /about.html . this problem when want link menu item external domain. if want create link between menu item 'shop' , www.myshop.com cannot change href of link www.myshop.com because blogger adds domain name infront of it, making like: www.mydomain.com/www.myshop.com. from understand blogger through following code: data:post.url or similar. have looked kind of code , tried cutting out far have not managed rid of www.mydomain.com infront of every list item. how can remove www.mydomain.com menu items? solution think of, if there others please suggest them! so figured out problem, easy: just change link looks this: <a href="http://www.yourdomain.com">my domain</a> make sure don't forget http, otherwise going errors (thats's mistake made)

Prevent matlab from memory allocation when using chol -

i want compute cholesky decomposition of 50000 50000 matrix. implemented as a = chol(a, 'lower'); as can see, symmetric matrix a replaced cholesky factor. however, matlab briefly allocates twice amount of data needed store a . on desktop system can set swap 32 gib. resolve out of memory error. on hpc cluster nodes offer 32gib of memory , 4gib of swap. in theory, sufficient, in practice unnecessary memory allocation performed matlab results out of memory error. i know lapack routine dpstrf (also used matlab) not need allocate additional memory. question is: have reimplement code in c or fortran or there other solution?

sql - join three tables in firebirdsql -

i have problem: i'd join 3 table in order values, example: sellers idsellers nameseller stock idstock qtystock cost fkseller sell idsell qtysell price fkseller i want out total amount of stock , sell tables each seller u have tried following query doubles values each sell: select sellers.nameseller, sum(stock.qty*stock.cost)as stocks, sum(sell.qty*sell.price) sells sellers left join stock on stock.fkseller=sellers.idseller left join sell on sell.fkseller=sellers.idsellers group sellers.nameseller the firebirdsql release in use 2.1 thanks in advance. the problem if have example 2 in sell , 2 in stock . first join produce 2 records, second join create 2*2 records. instead should union data , join once, or use select expression produce sums. using select expression: select sellers.nameseller, (select sum(stock.qty * stock.cost) stock stock.fkseller=sellers.idseller) stocks, (select sum(sell.qty * sell.price) sell sell.fkseller=seller...

javascript - jQuery data(...) not stored in the DOM? -

Image
if data-x in dom : <div id="blah" data-x="143">hello</div> and modify $('#blah').data('x', 13687) then seems data-x not modified in dom (use browser's inspect feature on snippet code below) : is normal behaviour? example: console.log($('#blah').data('x')); $('#blah').data('x', 13687) console.log($('#blah').data('x')); <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <div id="blah" data-x="143">hello</div> jquery's data() method does not set data attributes, stores data in internal object. html5 data attributes automatically pulled in jquery's data object, means initial value of data object reflects whatever given in attribute, changing value data() will not update attribute, internal data object jquery uses. so yes, it's normal ...

c# - asp.net mvc 5.1 mysql Entity Framework Controller Generation -

Image
i have asp.net mvc 5.1 solution 3 projects in shown image below: i have ninject, fakeiteasy, mysql nuget packages installed in project , using repository pattern in project have irepository generic interface, idbcontext interface , concrete repository generic class (all in accountmanager.domain). ninject , mysql setup, built solution , far until tried add controller using scaffolding options given entity framework , error saying: unable retrieve metadata 'accountmanager.domain.entities.bank' using same dbcompiledmodel create contexts against different types of database servers not supported. instead create separate dbcompiledmodel each type of server being used. i saw when head banging sqlite , ef code first. mean again? see perspective don't? i have been plugging away @ annoyance while , found simple. decorating context class mysqlefconfig so: [dbconfigurationtype(typeof(mysqlefconfiguration))] helps context make necessary adjustments migration...

php - ZF2 uncaught exception on concurrent emails exceeds limit with SMTP server -

zf2 throws uncaught exception when trying send multiple mail @ same time, using smtp server. after sending 5 emails throws exception: uncaught exception: "could not read host" zend\mail\protocol\abstractprotocol this comes after smtp server sends error: message submission rate client has exceeded configured limit since thrown when destructor called not able catch in script. suggestion how catch this, in script. there nothing zend framework 2 or other library. message mail service consuming pretty clear: you're exceeding rate limit . anyway, have several options; never send lot of e-mails in single while / loop since don't have cool paid e-mail service doesn't apply rate limit account. (paid or not every service yours applies rate limits prevent abusing. normal.) add try {} catch() {} block in script , when exceed limit, stop, wait while , try again. you may consider writing cronjob , cli script send x emails per minute. implem...

function pointers - how to change output mode to input mode (fields)in updating the database file using rpgle as400 -

i've written program in #rpgle along 2 records work screen in display file. first record display main-screen-of-company, takes input as: emp id indicators= f3 : exit f6 : accept . after pressing f6 , goes second record indicators= f3 : exit f12 : cancel f7 : modify f8 : delete f6 : accept & fields in output mode. when press f7 update fields, in o/p non editable mode should change editable mode. how that? try protecting field same indicator associated function key. a r rec001 text('record') cf07(07) field r b 10 3 n07 dspatr(pr)

How to display multiple images in jsp using a struts2? -

i getting images database , storing images in filepath( request.getsession().getservletcontext().getrealpath) . having images in filepath. then getting images filepath private file[] filelist; now trying display filelist in jsp: <s:iterator value="filelist"> <img src="<s:property />"/> </s:iterator> output in browser getting filepath of images(i can iterate) images not loading. if put <img> tag in <a> , click on link displaying "the address wasn't understood". if enter link slash "/" changing , image in displaying. <s:iterator value="filelist"> <a href="<s:property />"/> <img src="<s:property />"/> </a> </s:iterator> in firebug showing "could not load image". i may wrong in displaying image please how load image in jsp.