Posts

Showing posts from June, 2015

php - Wrong result with FOUND_ROWS() in mySQL -

i have total of 6 rows. when query (say select * table) , have limit 3 => found_rows() gives 3 => 3 rows retrieved limit 1, 3 => found_rows() gives 4 => 3 rows retrieved limit 2, 3 => found_rows() gives 5 => 3 rows retrieved limit 3, 3 => found_rows() gives 6 => 3 rows retrieved limit 4, 3 => found_rows() gives 6 => 2 rows retrieved any idea cause of weird behavior? sql query select `places`.*, `category`.*, count(places_reviews.place_id) num_reviews, (places_popularity.rating_1 + 2*places_popularity.rating_2 + 3*places_popularity.rating_3 + 4*places_popularity.rating_4 + 5*places_popularity.rating_5)/(places_popularity.rating_1 + places_popularity.rating_2 + places_popularity.rating_3 + places_popularity.rating_4 + places_popularity.rating_5) average_rating, found_rows() num_rows (`places`) join `category` on `places`.`category_id` = `category`.`category_id` left join `places_reviews` on `places_reviews`.`place_id` = `places`.`id` left j

wordpress - TinyMCE editors in meta boxes, not saving P tag -

for hell autop function seems give me when don't want it, have several custom meta boxes tinymce textareas. , aren't saving tags.. seem ok w/ saving other html markup. my html 1 of boxes looks like: <div class="customeditor"> <div class="custom_upload_buttons" class="hide-if-no-js"><?php do_action( 'media_buttons' ); ?></div> <?php $mb->the_field('below_content'); ?> <textarea rows="10" cols="50" name="<?php $mb->the_name(); ?>" rows="3"><?php $mb->the_value(); ?></textarea> </div> the naming , stuff handled wpalchemy, hence weird $mb->the_name() stuff function my_admin_print_footer_scripts() { ?> /* /* * multiple tinymce settings */ settings = { mode:"specific_textareas", width:"100%", theme:"advanced", skin:"wp_t

audio - C# (sharp) adding background music to my program -

can tell me posible add bacground music(that plays time while program on) program making c#. code examples nice. thankyou. first hit on bing search . http://www.codeproject.com/kb/audio-video/playwavfiles.aspx assuming, of course, mean winforms app. playing background music in web app pure evil .

MySQL string replace -

i have column containing urls (id, url): http://www.example.com/articles/updates/43 http://www.example.com/articles/updates/866 http://www.example.com/articles/updates/323 http://www.example.com/articles/updates/seo-url http://www.example.com/articles/updates/4?something=test i'd change word "updates" "news". possible script? update your_table set your_field = replace(your_field, 'articles/updates/', 'articles/news/') your_field '%articles/updates/%' http://www.electrictoolbox.com/mysql-find-replace-text/

Ruby questions about web layer layout -

i trying make url <a href="/formats/formats.html.erb">link title</a> within application. file need edit link url controller , view? also, still working way through tutorial: http://guides.rubyonrails.org/layouts_and_rendering.html and wondering when this: <%= stylesheet_link_tag "http://example.com/main.css" %> is supposed live in application.html.erb file or index.html.erb file? what file need edit link url controller , view? routes.rb see the rails guide is supposed live in application.html.erb file or index.html.erb file? the simple answer is: application.html.erb, inside head section. there ways of injecting view template stuff head, if you're starting out, stick application.html.erb.

javascript - HTML5 Local Storage stringify's and stores EACH object reference -

with following json: var myobj = {name: 'my obj', does: 'nothing'}; var myobjarr = [myobj, myobj, myobj]; when storing myobjarr local storage, myobj json wrtten 3 times, taking 3 times storage space, i.e: "[{"name":"my obj","does":"nothing"},{"name":"my obj","does":"nothing"},{"name":"my obj","does":"nothing"}]" obviously going present scalability issues. can recommend optimal solution? far i've had resort using id's, la relational databases. var objects = {0: {name: 'my obj', does: 'nothing'}}; var myobjarr = [{obj: 0}, {obj: 0}, {obj: 0}]; update - question how represent hierarchy in local storage when data stored key/value strings. resorting relational database concepts seems old-school. a more appropriate technology indexeddb used object store, isn't supported many browsers yet. edi

php - Twitter API simplexml_load_string stop working -

this morning php script, twitter oauth posting, stopped working. suspect twitter added rows returned string. can how debug this. thanks warning: simplexml_load_string() [function.simplexml-load-string]: entity: line 74: parser error : entity 'copy' not defined in /nfs/c05/h01/mnt/82363/domains/html/c/cron.m.php on line 429 warning: simplexml_load_string() [function.simplexml-load-string]: <li class="first">&copy; 2011 twitter</li> in /nfs/c05/h01/mnt/82363/domains/html/c/cron.m.php on line 429 warning: simplexml_load_string() [function.simplexml-load-string]: ^ in /nfs/c05/h01/mnt/82363/domains/html/c/cron.m.php on line 429 the xml contains html entities. &copy; not valid in xml. workaround pre-filter document before handing on simplexml: $xml = file_get_contents(...); $xml = strtr($xml, array_flip(array_diff( get_html_translation_table(html_entities), get_html_translation_table(html_specia

How to create a PDF and add the contents usnig iText library in android...? -

i using itext library create pdf documents. able create , add contents document programmetically "new paragraph("this new pdf")". question can add contents typing in document , save pdf using itext library? creating word documents...? suppose if want insert image in document, done picking image external storage using dialog box...? is possible using itext library in andriod...? these multiple questions. i'll try answering them all. seems 1 answer questions is, first try, study, learn itext about, ask questions but question can able add contents typing in document , save pdf using itext library? creating word documents...? no, have programmatic. itext not wysiwyg tool adobe acrobat or other gui-pdf editors. suppose if want insert image in document, done picking image external storage using dialog box... if create dialog box , code logic add pdf in itext way possible. is possible using itext library in android...?

Is there any way of inspecting an element and seeing from which PHP file is comming from? -

for instance, when i'm trying understand how wordpress theme coded, spend hours trying figure out php file generating element (for instance, div or link). is there way of detecting php file? you can use debug_backtrace() or debug_print_backtrace() dig deep , find out kinds of information, such when , functions called , files loaded. this useful finding out how wordpress theme coded . tell pretty everything.

javascript - Url parameters extraction -

var results = new regexp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href); could u please explain exactlly happening in above line of code. thanks in advance. you create variable name of results scoped execution context. you invoke regexp constructor thereby instantiating object , pass string used regex. have way because can't concatenate regex literals outside data. the regex says match of \ , ? or & followed name variable, , literal = , make capturing group of every character besides & or # , 0 or more times. you call exec() method on new regexp object, window.location.href (the current url) argument. the return of assigned results variable. the capturing group's contents (if successful) in results[1] . or you getting param name :)

jsp - how to display the data from database on a button click in java jsf -

<f:view> <h:form> <h:panelgrid> <f:facet name="header"> <h:outputtext value="student mark list"/> </f:facet> <h:column> <h:outputtext value="student number : "></h:outputtext> <h:inputtext value="#{stubean.stunumber}"/> </h:column> <h:column> <h:commandbutton id = "getstumarklist" value="get mark list" action="#{stubean.listofmarks}" > </h:commandbutton> </h:column> </h:panelgrid> <h:panelgrid bgcolor="#9ac8e6" width="100%"> <h:datatable id="datatable" value="#{stubean.markslist}" var="markslist">

matlab - How to use a parameter as a global variable in a .m file? -

to describe mean, give example here: function y = f(x,a) global y = f1(x); function y = f1(x) global y = x + a; here, want variable 'a' used global variable can called subfunction 'f1' compute $x+a$. (my purpose reduce transformation of parameters) but function not work, unless define new variable 'b' restore value of 'a'. the question is, how can make 'a' global variable directly, without defining new variable? i not recommend use global variables, since pass function f . the behavior want can obtained without global variables, using nested functions : function y = f(x,a) y = f1(x); function y = f1(x) y = x + a; end end

ios - Stock Graph in Iphone? -

i working graph application.in have implement stock graphs fatching datas via webservice.so suggest me impressive sdk or api graphs in iphon/ipad.i trying roambi dont think more useful.i used core plot library , categoty line graphs.but there other way instead of this?so please suggest me? did inside core plot framework see sample applications ship it? aaplot sample application stock charting application mimics style of apple's built-in stocks application (with few additions, volume charting , trading ranges): alt text http://www.sunsetlakesoftware.com/sites/default/files/aaplot.jpg core plot has theme called kcpstockstheme exact style. don't know how easier can that.

project management - codendi vs redmine vs Retrospectiva vs trac -

has tried codendi , redmine , retrospectiva , trac ? or able make comparison between four? whichone better related: performance easy use installation and others and better operating system implement each of application ? many :) i haven't tried coded or retrospectiva i've used both redmine , trac, , in opinion, redmine better because: easier installation multiple projects out of box support git , mercurial support remote repositories support ldap authentication built in web based administration many plugins available and better looking default theme if care that initially more familiar python ruby, tended towards trac first time. redmine more powerful, more features out of box, , greater community of plugins available.

linux - get process name, pid and port mapping from netstat command in SunOS -

i trying mapping of port number application running/using port in sunos $netstat -tlnp netstat: illegal option -- t it seems -t option illegal in sunos. how can mapping? i got script somewhere. log solaris system. open vi editor. go insert mode. copy , paste script. close file. give execute permission. run script -p or -p swithc. give output pid, process name , port. pcp script enables administrators see open tcp ports in use on solaris system. maps ports pids , vice versa. accepts wildcards , show @ glance open ports , corresponding pids. nice script gives fine out put. try it. example: #pcp -p port_number or #pcp -p process_id #!/usr/bin/ksh # # wildcards accepted -p , -p options. # # help, appreciated. i=0 while getopts :p:p:a opt ; case "${opt}" in p ) port="${optarg}";i=3;; p ) pid="${optarg}";i=3;; ) all=all;i=2;; esac done if [ $optind != $i ]; echo >&2 "usage: $0 [-p port] [-p pid] [-a] (wildc

assembly - NASM: Dividing large number with small one -

nasm manual says on div : for div r/m32, edx:eax divided given operand; quotient stored in eax , remainder in edx. what if edx:eax large number around 2 59 , divider 3 ? quotient cannot fit eax . let's not care remainder. have best practice doing division. thinking dividing upper , lower 32 bits in separate steps. think figure out ugly result, interested in one. quick check case when eax hold quotient avoiding complicated magic. solution : drhirsch's answer converted nasm syntax: ; divides edx:eax ebx, if result bigger 2^32. ; result in edx:eax, ecx,esi used spare registers mov ecx, eax ;save lower 32 bit mov eax, edx xor edx, edx ;now edx:eax contains 0:hi32 div ebx mov esi, eax ;hi 32 bit of result, save esi mov eax, ecx ;now edx:eax contains r:lo32, r remainder div ebx mov edx, esi ;restore hi32 this code untested. should calculate (d*2^32 + a)/b: ;this divides edx:eax ebx, if result bigger 2^32

how to identify li item using jquery -

i've list <ul> <li><a href="?page=4">one</li> //no 4 <li><a href="?page=7">two</li> //no 7 <li><a href="?page=14">three</li> //no 14 <li><a href="?page=72">four</li> //no 72 <li><a href="?page=201">five</li> //no 201 </ul> now want use ajax load pages instead of normal page load. how detect link user clicked using jquery. like $('id of element clicked').click(function()({ // load page using .ajax() }); in jquery code above, how id of element clicked ?? you fetch id href attribute of clicked anchor using regex: $('ul a').click(function() { var id = this.href.match(/([0-9]+)$/)[1]; // load page using .ajax() }); but better approach imho instead of using regex parse url use html5 data-* attributes: <ul> <li><a href="?page=4"

HTML Canvas As Overlayview In Google Maps That Is Fixed Relative to the Map Canvas -

i'm trying create html5 canvas overlayview size of map, position top:0; left:0; , draw stuff on it, , add map. whenever map zooms or pans want remove old canvas map , create new canvas draw on position 0,0 , add map. map never reposition top:0; left:0. can help? function customlayer(map){ this.latlngs = new array(); this.map_ = map; this.addmarker = function(position){ this.latlngs.push(position); } this.drawcanvas = function(){ this.setmap(this.map_); //google.maps.event.addlistener(this.map_, 'bounds_changed',this.redraw()); } } function defineoverlay() { customlayer.prototype = new google.maps.overlayview(); customlayer.prototype.onadd = function() { console.log("onadd()"); if(this.canvas){ var panes = this.getpanes(); panes.overlaylayer.appendchild(this.canvas); } } customlayer.prototype.remove = function() { console.log("onremove()"); if(this.canvas) this.canvas.parentnode.removechild(this.canvas

MIDLet managers for Android/Windows devices -

i seem bit @ loss status , development of midlet managers android or windows mobile devices. i know of jblend , jbed can't work out projects belong to. jblend installed on lg540 manufacturer not on galaxy s1 example. need find way give reliable set of instructions users these installed on device. is there central place download them from? is there road map projects (i.e android 2.3)? why aren't available market place? is midlet manager available on windows mobile 7 devices? some (eg. jbed) said found on android market, 3rd parties without legal rights, don't appear on market now. jbed : i found versions of jbed ripped off of firmwares of android phones. company doesn't have listed downloadable product, seems developed bigger companies, phone manufacturers, integrated in firmwares. seems reason why don't see info or new releases. jbed owned myriad group (formerly known esmertec) http://www.myriadgroup.com netmite app runner : app runn

.net - Roles management with no provider? -

in app need check roles loggind user determine if user see controls or not first use loginview template ms don't have users db neither roles db couldn't add role provider couldn't use role class check users\role as in case have session user info , roles has,and need perform check on roles set control enable user standard way "using .net built in class or code" if want use parts of asp.net membership/authentication/authorisation services you'll need implement custom role provider perform role membership checking. the first thing create class inherits system.web.security.roleprovider , in sounds methods you'll care implementing are: findusersinrole getrolesforuser getusersinrole isuserinrole so, you'll end similar to: using system; using system.collections.generic; using system.linq; using system.web; using system.web.security; public class mycustomroleprovider : roleprovider { public override string[] findusersinro

looking for a way to create Linq-to-SQL Master-Detail with where in Detail -

i have sql: select * order left outer join orderdetail (select count(*) orderdetail orderdetail.id=order.id , orderdetail.productname='book')>0 how can implement in linq thanks looks sql wrong start with. looks more correct: select * order left outer join orderdetail on (orderdetail.id=order.id , orderdetail.productname='book')

c# - JSON deserialise to an object with a private setter -

i'm having issue json , de-serialisation. i've got live production code uses message object pass information around 1 system another. id of message important used identify it. don't want setting id's , such made private setter. my problem comes when trying deserialise json object , id not set. (obviously because it's private) does 1 have suggestion best way proceed? i've tried using iserialisation , it's ignored. i've tried using datacontract fails because of external system getting data from. my option on table @ moment make id , timecreated fields have public setters. i have object such message { public message() { id = guid.newguid(); timecreated = datetime.now(); } guid id { get; private set; } datetime timecreated { get; private set; } string content {get; set;} } now i'm using following code: var message = new message() { content = "hi" }; javascriptserializer jss = new java

php - How to use cookies in Zend? -

how use zend_http_cookie set , read cookies? i trie set cookie this: $cookie = new zend_http_cookie('testcookie','testvalue','localhost.com') no cookie generated. how read cookies zend? thanks as far know there not "setcookie" class in zend framework. use "plain" php: setcookie('cookiename', 'value', 'lifetime', 'path', 'domain'); to read cookie, can use zend_controller_request_http(); example: $request = new zend_controller_request_http(); $mycookie = $request->getcookie('cookiename');

java - How to add pagination to data fetched from database in jsp -

i have jsp page diplays huge data in table format in jsp ..i want add pagination default 20 entries displayed in page , click next other details..please send me best links pagination you can use param maintain current slot of data example pageno=1 , should fetch 1-20, pageno=2 should fetch 20-40. , fetch data when required. there many such view available. 1 of displaytag. also there pagesorter jquery plugin

android path to my file -

i'm using complex method (not written me) in android app, takes string parameter "path" , opens , parses file path. problem this: when set path file on sdcard (like this: environment.getexternalstoragedirectory()+"/myfile.txt" ) works fine. don't want file available user tried set path assets folder in project copied file, , using path won't work.the path used file in assets folder wast this: file:///android_asset/myfile.txt why first path works fine , second nothing? thanks you have use assetmanager access files in assets folder.

html5 - Can I get access to users microphone in mobile browsers? -

the google voice webapp somehow uses microphone input have read here: http://gizmodo.com/5456815/google-voice-finally-heads-to-iphone-palm-pre-with-html5-webapp how can achieve besides using google chrome? seems possible in mobile safari. <input type="text" x-webkit-speech /> looking for. works in minimum range of browsers. hope can find more information.

ruby - How to preserve newlines with "to_lang" Google Translate -

i use to_lang translate text in rails 3 application. noticed converts newlines spaces. appropriate approach preserve newlines in original text? don't want split original text "\n" , translate parts, , combine them again, since increase number of requests. ideas? i've tested :debug => :request : {:key=>"--", :q=>"to prevent abuse, google places limits on api requests.\nusing valid oauth 2.0 token or api key allows exceed \nanonymous limits connecting requests project.", :target=>"ru"} and can see it's not gem fault. so, to_lang can translate arrays too. , if you'll write ["one", "two", "three"].to_russian 1 request google api. update: irb(main):001:0> str = "test1\ntest2\ntest3" => "test1\ntest2\ntest3" irb(main):002:0> arr = str.split("\n") => ["test1", "test2", "test3"] irb(main):003:0> str

python - When using setResultsName with listAllMatches true, some matched items are nested -

based on grammar: from pyparsing import * g = quotedstring.setparseaction( removequotes ) eg = suppress('-') + quotedstring.setparseaction( removequotes ) choice = or( [ g.setresultsname("out",listallmatches=true), eg.setresultsname("in",listallmatches=true) ] ) grammar = zeroormore( choice ) + suppress(restofline) = world.parsestring( ' "ali" -"baba" "holy cow" -"smoking beaute" ' ) print a.dump() i have discovered tokens satisfy eg nonterminal wrapped in list. difference g has leading `suppress('-')'. ['ali', 'baba', 'holy cow', 'smoking beaute'] - in: [['baba'], ['smoking beaute']] - out: ['ali', 'holy cow'] how make them behave same ? want achieve result below: ['ali', 'baba', 'holy cow', 'smoking beaute'] - in: ['baba', 'smoking beaute'] - out

jQuery validator to allow only basic characters -

i want allow basic characters a-z, a-z,0-9 , , basic special characters ~``!@#$%^&*()_+-=[]{};'\:"|,./<>? availalbe on standard english keyboard typed in text area. looking ! sample: $('#text_area_id').keyup(function() { $(this).val($(this).val().replace(/[^a-za-z0-9~`!@#$%^&*()_+-=\[\]{};'\\:"|,.\/<>?]/g,'')) });

sql server - collapse strings with same id into comma separated list -

based on googling came this: drop table #temp create table #temp ( id int, name nvarchar(max) ) insert #temp (id,name) values (1,'bla1') insert #temp (id,name) values (1,'bla2') insert #temp (id,name) values (3,'bla3') ;with cte1 ( select id, stuff((select ', ' + cast(t2.name nvarchar(max)) #temp t2 t1.id = t2.id xml path('')),1,1,'') name #temp t1 ) select id, name cte1 group id, name is best way things? thanks! christian this approach better sorts on id rather id,name ;with cte ( select distinct id #temp ) select id, stuff((select ', ' + cast(t2.name nvarchar(max)) #temp t2 t1.id = t2.id xml path('')),1,1,'') name cte t1 if have table containing distinct id fields better off using that. the approach using works correctly if data guaranteed not contain characters such < , > , &

actionscript 3 - Encrypting as3 flash .swf -

i'm trying protect as3 .swf flash file code decompilation. cannot spend $$$ on commercial compilers though. how can encrypt swf free? my brutally honest answer: don't try. if has skill make use of assets or code application, they're going have basic knowledge needed decompile swf , need. if want try, can suggest: http://www.kindisoft.com/ hope helps.. or @ least explains why shouldn't spend time trying.

c# - Get Version from Non Executing Executable File -

i know how version of executing application or dll. need find properties of non executing application. i have small program set file association main application. there no point in users of old versions running since application not accept arguments on start up. when file associator starts first checks see if can find main app. if can want check properties without executing it. if version earlier 1 can accept arguments want tell user update rather proceed set association. i have looked @ system.io.fileinfo not seem include version information. thanks you can use fileversioninfo.getversioninfo() : fileversioninfo vi = fileversioninfo.getversioninfo("myfile.dll"); string showversion = vi.fileversion; //showversion actual version no. this returns file/document metadata , can used unmanaged dlls or word documents well . you can use assembly: version v = assembly.reflectiononlyloadfrom("myfile.dll").getname().version; this contain .

php - how to use drop down list of a cgrid view in yii? -

hi, know should simple new php , yii. so, please, bear me. have table named thefriends has columns(thepals,address,phone numbers). admin page uses cgridview list these friends in usual format. want text boxes replaced drop down menus. know can done using following code in views/thefriends/admin.php 'columns'=>array( 'id', 'array'( 'name'='thepals', 'filter'=array(1=>'alice',2=>'jenna'), ) but see have populate values myself, instead want values prepopulated particular column.. please help.. use chtml::listdata object filter. instance, let's assume related thepals table has columns id , name . 'columns' => array( 'id', array( 'name' => 'thepals', 'filter' => chtml::listdata(thepals::model()->findall(),'id','name'), ... ),

jquery - How to remove spaces from a string using JavaScript? -

how remove spaces in string? instance: input : '/var/www/site/brand new document.docx' output : '/var/www/site/brandnewdocument.docx' thanks this? str = str.replace(/\s/g, ''); example var str = '/var/www/site/brand new document.docx'; document.write( str.replace(/\s/g, '') ); update: based on this question , this: str = str.replace(/\s+/g, ''); is better solution. produces same result, faster. the regex \s regex "whitespace", , g "global" flag, meaning match \s (whitespaces). a great explanation + can found here . as side note, replace content between single quotes want, can replace whitespace other string.

python - suds and choice tag -

how generate request method "choice" arguments? part of wsdl @ http://127.0.0.1/service?wsdl : <xs:complextype name="bya"> <xs:sequence> ... </xs:sequence> </xs:complextype> <xs:complextype name="byb"> <xs:sequence> ... </xs:sequence> </xs:complextype> <xs:complextype name="getmethodrequest"> <xs:choice> <xs:element name="bya" type="s0:bya" /> <xs:element name="byb" type="s0:byb" /> </xs:choice> </xs:complextype> when suds.client import client client = client("http://127.0.0.1/service?wsdl") print client i see getmethod() without arguments. how can call getmethod bya or byb? it's known bug in suds https://fedorahosted.org/suds/ticket/342

How to create an Page Control in android -

how create page control in android.... want move 1 page page, home screen in android device... displays current page 3 4 dots.... i've managed same doing like: int currentscreen = 1; final gesturedetector gesturedetector = new gesturedetector( new mygesturedetector()); findviewbyid(r.id.homescreen).setontouchlistener( new view.ontouchlistener() { public boolean ontouch(view v, motionevent event) { if (gesturedetector.ontouchevent(event)) { return true; } else if (event.getaction() == motionevent.action_up || event.getaction() == motionevent.action_cancel) { ...detect scroll , change var... as described here: horizontalscrollview within scrollview touch handling and here: android horizontal scrollview behave iphone (paging)

Remove Carriage Returns from char* (C++) -

i have defined resource file in visual studio 2008 c++ project. problem after obtaining resource data lockresource method resulting char buffer contains carriage returns , line feeds original data contained line feeds. instance if original line contains: 00 0a fc 80 00 00 27 10 00 0a fc 80 00 00 27 10 the resulting char* contains carriage returns (0d): 00 0d 0a fc 80 00 00 27 10 00 0d 0a fc 80 00 00 i tried following code rid of them results in both carriage return , line feed removed: for (int = 0; < sz; ++i) { // ignore carriage returns if (data[i] == '\n') continue; // ... } how rid of carriage returns leave new line characters? edit: to make more specific. writing char buffer file: std::ofstream outputfile(filename.c_str()); (int = 0; < sz; ++i) { // ignore carriage returns // if (data[i] == '\r') continue; leaves both cr , lf // if (data[i] == 0x0d) continue; leaves both cr , lf if (data[i]) == '\n')

php - Code that checks for required text in textboxes upon submit -

how can check if user filled textboxes upon submit? textboxes have different id , name. if user did not fill required password form not continued. thank you. you can using javascript or within script itself. if using javascript, check form fields against requirements before allowing form submit. however, may still need implement in script in case ofr reason have javascript turned off. basically, in script, check values of form when submit: if($_get['field_name']) !== 'the value expect') { // show form again errors } // continue hope helps.

php - Magento: how to filter order list by shipping method? -

i try create custom grid orders shipped shipping method (for example tnt). here method should filter: protected function _preparecollection() { $collection = mage::getresourcemodel($this->_getcollectionclass()); $this->setcollection($collection); return parent::_preparecollection(); } i'm going use addfieldtofilter(), don't know field name. me? how "shipping_method" or "shipping_description". fields "sales_flat_order"

sql - Oracle - column to all combination rows -

i have oracle table varchar(100) column, , need separate rows based on strings combinations inside column. string delimiter ' ' (space) , number of strings variable. this example: select 1 id, 'string_1 string_2 string_3 string_n' name dual the output need: id name -- ------ 1, 'string_1 string_2 string_3 string_n' 1, 'string_1 string_2 string_3' 1, 'string_1 string_2' 1, 'string_1' 1, 'string_2 string_3 string_n' 1, 'string_2 string_3' 1, 'string_2' 1, 'string_3 string_n' 1, 'string_3' 1, 'string_n' *this minimum output want, can handle possible combinations. sql> create table mytable (id,name) 2 3 select 1, 'string_1 string_2 string_3 string_n' dual union 4 select 2, null dual union 5 select 3, 'ma lo' dual 6 / table created. sql> t 2 ( select id 3 , name 4 , 5 mytable 6 model 7

windows - Generate Solution with dependencies for building VS 2010 with hundreds of projects -

we have few hundred visual studio project files need assemble solution building. have custom ruby script, uses rake, this. fragile, , allows few visual studio macros ( $(targetdir),$(targetname), etc...) through, , failing on rest. plus grammar of ruby rubs me perl: wrong way. so question is, given directory there tool recursively find all .vcxproj , .csproj files , generate solution file dependencies? when 'with dependencies' means projects need built before others. found other posts here on stack overflow pointed tool generates solution files: doesn't generate dependencies. therefore without dependencies solution creation tool useless. know of this? if not solution file, know of emit dependency list? p.s. , before asks: creating solution file manually out of question. have way many project files. so question is, given directory there tool recursively find all .vcxproj , .csproj files , generate solution file dependencies? no. what you

pointers - passing a HANDLE variable to an unmanaged .dll in C++/CLI -

i trying wrap unmanaged c++ dll talks video capture card in c++/cli can reference functions c# project have. having trouble getting 1st wrapped call work new c++/cli syntax. here have. here function declataion trying wrap. __declspec(dllimport) bool az_devicecreate(handle& hliveevent, dword* hencoderevent, dword* pdwencoderaddress, handle& haudioevent, dword& dwaudioaddress); here c++/cli .h file namespace capturelibrary { public ref class capturecard { public: handle m_hliveevent; dword *m_hencoderevent; handle m_haudioevent; public: capturecard(); bool createdevice(); void disposedevice(); }; } and .cpp namespace capturelibrary { capturecard::capturecard() { m_hliveevent = invalid_handle_value; m_hencoderevent = new dword[max_video_channel]; (byte i=0;i<max_video_channel;i++) { m_hencoderevent[i] = (dword)invalid_handle_value;

c# - How do you call a method by its "name"? -

what way call method name, "method1", if i've got object , it's type ? i want this: object o; type t; // @ point know, 'o' has // 't' it's type. // , know 't' has public method 'method1'. // so, want like: reflection.callmethodbyname(o, "method1"); is somehow possible? realize slow, it's inconvenient, unfortunately i've got no other ways implement in case. if concrete method name known @ runtime, can't use dynamic , need use this: t.getmethod("method1").invoke(o, null); this assumes, method1 has no parameters. if does, need use 1 of overloads of getmethod , pass parameters second parameter invoke .

api - gunzip in javascript -

an api returns large resultsets , wishing gzip in php wouldn't know how gunzip in javascript. there sort of library capable of in javascript? searching net , found stuff couldn't quite figure out how make use of it. so, if has ever dealt before, advise highly appreciated. (the api response worth 1mb) usually compression of http responses done either proxy or web server. should able configure apache you. see documentation mod_deflate more information. in terms of unzipping in javascript, non-issue. provided http response contains correct header information. (content-encoding: gzip) browser handle unzipping you.

regex - For each xml file in a directory, how to add its contents to another file at a certain place? -

i have fun , seemingly simple perl challenge stumping colleagues. care take crack? project move forward. iterate through each xmlfilexf in directoryd, , each one: in modifythisfilemtf, copy wordblockwb , paste after last wordblockwb. in modifythisfilemtf, replace replacemerm contents of current xmlfilexf. directoryd has xml files way, really, don't have discriminate on filetype. also, it's fine hardcode contents of wordblockwb if prefer. modifythisfilemtf.txt contents: myfunc { // begin wordblockwb prewords "msg"=replacemerm postwords // end wordblockwb return 0; } directoryd contents: xmlfilexf1.xml xmlfilexf2.xml ...6000 more xmlfilexf1.xml contents: <foo/> xmlfilexf2.xml contents: <bar/> desired output modifythisfilemtf.txt contents: myfunc { // begin wordblockwb prewords "msg"=<foo/> postwords // end wordblockwb // begin wordblockwb prewords "msg"=<bar/>

jquery datepicker onselect simple function -

the jquery datepicker plugin works, i'd have onselect triggering function opens page in new tab. the jquery datepicker plugin works, i'd have onselect triggering function opens page in new tab. $("#dp").datepicker({ beforeshowday: highlightdays, //works fine onselect: function(dates) { window.open('/en/calendar/' + dates, '_self'); }, }); var dates = [new date(2011, 4 - 1, 28), new date(2011, 5 - 1, 10),]; //does not work onselect: function(links) { window.open('/en/trip/' + links, '_self'); }, var links = [new link('link1'), new link('link2'),]; the js: $( "#toggledp" ).click(function() { $("#dp ").datepicker('show'); }); $("#dp").datepicker({ changemonth: true, changeyear: true, showon: 'button', showbuttonpanel: true, buttonimageonly: true, buttonimage: "0.gif", dateformat: 'yy-mm-dd', beforeshowday: highlightdays, onselect: function(

javascript - Why do windows opened fire the `onload` event only once? -

i've been searching answer problem—with no luck far. here's code: var onewwindow = window.open(slink,'_blank'); onewwindow.addeventlistener('load',function() { alert('page loaded'); }, false); when popup window/tab opens handler called, if browse inside popup window, handler never called. why? , there way make work? the base idea user opens popup window , starts browsing in popup, while code in parent window continues working , monitoring happening in popup. popup page page on same domain. after loading popup first time, attached onunload handler it, call handler in parent window , timer start. parent window's script work contents of popup. however, problem comes lag, if timer runs out , old page inside popup still there, incorrect data , whole script stops. unable attach onunload handler after that. the onload handler set window whole, not document within window, why isn't handler called? also, script run of greasemonkey. do

Passing parameters to WCF function from JavaScript -

i have wcf function takes complex type input parameter. how create , pass complex type (object properties) through call? thanks there 2 ways accomplish task. can use asp.net scriptmanager , have create javascript proxy wcf service or can use jquery's ajax functionality too. i've included links both examples below. using jquery/ajax: http://www.west-wind.com/weblog/posts/2008/apr/21/jquery-ajax-calls-to-a-wcf-rest-service using scriptmanager js proxy: http://blogs.msdn.com/b/kaevans/archive/2007/09/04/using-wcf-json-linq-and-ajax-passing-complex-types-to-wcf-services-with-json-encoding.aspx

c# - Why array implements IList? -

see definition of system.array class public abstract class array : ilist, ... theoretically, should able write bit , happy int[] list = new int[] {}; ilist ilist = (ilist)list; i should able call method ilist ilist.add(1); //exception here my question not why exception, rather why array implements ilist ? because array allows fast access index, , ilist / ilist<t> collection interfaces support this. perhaps real question "why there no interface constant collections indexers?" , have no answer. there no readonly interfaces collections either. , i'm missing more constant sized indexers interface. imo there should several more (generic) collection interfaces depending on features of collection. , names should have been different too, list indexer stupid imo. just enumeration ienumerable<t> readonly no indexer (.count, .contains,...) resizable no indexer, i.e. set (add, remove,...) current icollection<t> readonly indexer

mysql - File input to gnuplot through python -

i trying draw graph of data pull out of mysql database through python gnuplot , gnuplot.py. read latest 10 lines of data mysql database , store them in temp file supposed read gnuplot. can manual way setting through terminal, can't see how should load file gnuplot through python. if can show me easier way this, or way @ all, grateful. import mysqldb import gnuplot datafile = open('data', 'w+r') gp = gnuplot.gnuplot(persist=1) gp('set style data lines') gp('set term png') gp('set output "escan_graph.png"') gp('set datafile separator "|"') db = mysqldb.connect(host="localhost", user="root", passwd="password", db="zig") cursor = db.cursor() cursor.execute("select * escan_data") numrows = int(cursor.rowcount) #get count of total # , display 1 row @ time if numrows > 10: start = numrows-10 else: start = 0 x in range(start,numrows):

ms access - How to combine multiple column -

i wanted combine 11 columns of form single column. here query select dormdata.buildingid, buildingdetails.buildingname, contractors.item, actiondetails.actiontype, (dormdata.note1 + dormdata.note2 + dormdata.note3 + dormdata.note4 + dormdata.note5 + dormdata.note6 + dormdata.note7 + dormdata.note8 + dormdata.note9 + dormdata.note10 + dormdata.note11) notes actiondetails inner join (contractors inner join (buildingdetails inner join dormdata on buildingdetails.buildingid = dormdata.buildingid) on contractors.id = dormdata.itemid) on actiondetails.actionid = dormdata.actionid; but not getting required result. you need replace + &

arrays - binary search vs binary search tree -

what benefit of binary search tree on sorted array binary search? mathematical analysis not see difference, assume there must difference in low-level implementation overhead. analysis of average case run time shown below. sorted array binary search search: o(log(n)) insertion: o(log(n)) (we run binary search find insert element) deletion: o(log(n)) (we run binary search find element delete) binary search tree search: o(log(n)) insertion: o(log(n)) deletion: o(log(n)) binary search trees have worst case of o(n) operations listed above (if tree not balanced), seems worse sorted array binary search. also, not assuming have sort array beforehand (which cost o(nlog(n)), insert elements 1 one array, binary tree. benefit of bst can see supports other types of traversals inorder, preorder, postorder. your analysis wrong, both insertion , deletion o(n) sorted array, because have physically move data make space insertion or compress cover deleted item. oh , wor

How can I import a file while executing a content script in a chrome extension? -

i want execute javascript have background.html page set <html> <head> <script type="text/javascript" src="jquery.js"></script> </head> <body> <script type="text/javascript" src="jquery.js"></script> <script> chrome.browseraction.onclicked.addlistener(function(tab) { chrome.tabs.executescript(null, {file: "contentscript.js"}); }); </script> </body> </html> i use jquery in script, can't figure out how load. don't want content script go off every time user loads pages, when click extension's button. ideas? chrome.tabs.executescript method has third parameter callback function executes when script loaded, can use load more 1 script in order: chrome.browseraction.onclicked.addlistener(function(tab) { chrome.tabs.executescript(null, {file: "jquery.js"}, function() { chrome.

silverlight - AsyncCallback Error in a webfarm environment -

we getting ready in few weeks deploy new product brand new webservers , doing deployment testing in advance. (smart move? :-)) anyway, have 2 web servers (web01 , web02) , load balancers. stateless sessions setup machine keys setup on both web servers web01 stateless server. both http , https load balancers set 'not sticky' , 'sticky' hitting url web, not internally we can actively see web server have session @ given second, changing between servers. (should be? or should session more ‘static’ longer periods of time?) the app silverlight app. user logs in on web02 (we have lables on page can see server hitting) enters data. saves. take web02 offline. can see user on web01 error "an asynccallback threw , exception". if click ok user can continue if nothing happened. data there etc. should turn on tracing diagnose? have other suggestions? running fiddler , seeing 503 , 504 errors on web service can't tell server coming from. t

Picking HTTP status codes for errors from REST-ful services -

when client invokes rest-ful service, needs know if response came 'from me' or rather diagnosis containing web server awful happened. one theory that, if code called, should return http ok(=200), , errors i've got return should represented in data return. after all, it's code gets response, not naked browser. somewhat self-evidently, if i'm using rest generate html read directly browser, absolutely must return error code if there's error. in case care about, it's javascript or java interpreting entrails of response. another possibility there family of http status codes return high confidence it/they never generated problem in surrounding container. case? i use following: get 200 ok 400 bad request (when input criteria not correct) post 202 accepted (returned authorization method) 401 unauthorized (also returned authorization) 201 created (when creating new resource; set location header) 400 bad request (when data creating n

load - C# Draw when window is loaded -

i want draw ellipses when window loaded without clicking anything, how can it? code following : int kerx = random.next(10,281); int kery = random.next(10,281); mrpainter.fillellipse(brushes.black, kerx + 10, kery + 10, 20, 20); mrpainter.fillellipse(blue,65,65,20,20); mrpainter.fillellipse(red, 205, 65, 20, 20); mrpainter.fillellipse(yellow, 135, 215, 20, 20); assuming using winforms, insert code in formloaded event of main form.

Creating Ruby time object causing garbage collection problem -

i absolute newbie without computer science background. mechanical engineer trying implement way remotely monitor power output (and other output data) of inverters in solar power systems install. if exceedingly dumb, apologize in advance. i'm trying write little ruby program live in ror website's database folder. every 15 minutes (for long system online producing energy), want poll data our customers' inverters (via tcpsocket connection gateway connected customer inverter) , update website's database file new data. loop have looks this: last_min = time.new.min while(1) tsec = time.new.sec tmin = time.new.min if ( ( tsec == 0 ) && ( tmin - last_min == 1 ) ) # test using 1 minute # poll inverters, update database last_min = tmin end end when ran @ first, threw segmentation fault error. put gc.disable top , worked fine (until force quit after couple of min), see if garbage collection issue , seems first creation of time object trigger

C realloc inside a function -

here code: #include <stdio.h> #include <stdlib.h> #include <dirent.h> #include <string.h> #include <sys/stat.h> void mp3files(char** result, int* count, const char* path) { struct dirent *entry; dir *dp; dp = opendir(path); if (dp == null) { printf("error, directory or file \"%s\" not found.\n", path); return; } while ((entry = readdir(dp))) { if ((result = (char**) realloc(result, sizeof (char*) * ((*count) + 1))) == null) { printf("error"); return; } result[*count] = entry->d_name; (*count)++; } closedir(dp); } int main() { int* integer = malloc(sizeof (int)); *integer = 0; char** mp3filesresult = malloc(sizeof (char*)); mp3files(mp3filesresult, integer, "."); (int = 0; < *integer; i++) { printf("ok, count: %d \n", *integer); printf("

How can I compute elements from two different lists in python? -

i have 2 lists of ints, , want systematically operate objects. example have: a = [ a1, a2, a3, a4 ...] b = [ b1, b2, b3 ...] and want print this: a1+b1 a2 a2+b2 a3 a3+b3 a4 i think there " for loop" way, don't know how use 2 variables in " for loop". you use zip : >>> = ['a1', 'a2', 'a3', 'a4'] >>> b = ['b1', 'b2', 'b3'] >>> zip(a[:3], b, a[1:]) [('a1', 'b1', 'a2'), ('a2', 'b2', 'a3'), ('a3', 'b3', 'a4')] >>> a, b, c in zip(a[:3], b, a[1:]): ... print + '+' + b + ' ' + c ... a1+b1 a2 a2+b2 a3 a3+b3 a4

iphone - how do I set the value of an NSNumber variable (without creating a new object) in objective-c -

how set value of nsnumber variable (without creating new object) in objective-c? background i'm using core data , have managed object has nsnumber (dynamic property) passing (by reference) method update it not sure how update it? if allocate new nsnumber things don't work, guess makes sense it's got pointer different object not core data object (i guess) an nsnumber object isn't mutable. means way change property containing nsnumber give new nsnumber. want, have 3 options: 1. pass core data object method , have directly set property. - (void)updatenumberof:(mycoredataobject *)theobject { nsnumber *newnumber = ...; // create new number theobject.number = newnumber; } called [self updatenumberof:thecoredataobject]; 2. have update method return new nsnumber , update in caller. - (nsnumber *)updatenumber:(nsnumber *)oldnumber { nsnumber *newnumber = ...; // create new number return newnumber; } called using: nsnumber *the

mysql - sql query help on multiple count columns and group by -

i have following table students: id | status | school | name ---------------------------- 0 | fail | skool1 | dan 1 | fail | skool1 | steve 2 | pass | skool2 | joe 3 | fail | skool2 | aaron i want result gives me school | fail | pass --------------------- skool1 | 2 | 0 skool2 | 1 | 1 i have it's slow, select s.school, ( select count( * ) school name = s.name , status = 'fail' ) fail, ( select count( * ) school name = s.name , status = 'pass' ) pass, students s group s.school suggestions? something should work: select school, sum(case when status = 'fail' 1 else 0 end) [fail], sum(case when status = 'pass' 1 else 0 end) [pass] students group school order school edit forgot, write query way: select school, count(case when status = 'fail' 1 end) [fail], count(case when status = 'pass' 1 end) [pass] students group school order school i'm not s