Posts

Showing posts from May, 2012

yui - How can I use a custom sortFunction with a Grails gui:datatable tag? -

yui - How can I use a custom sortFunction with a Grails gui:datatable tag? - i have datatable in grails several sortable columns. unfortunately, sort case-sensitive default, such "zed" shown before "alice". want add together custom case-insensitive sort function. i'll start sorting username column in manner. i have read sortoptions , sortfunction @ http://developer.yahoo.com/yui/datatable/ can't seem work. i added next javascript list.gsp: var caseinsensitivesortfunction = function(a, b, desc, field) { // see http://developer.yahoo.com/yui/datatable/ , 'sortfunction' // set function name sortfunction alternative // deal empty values if (!yahoo.lang.isvalue(a)) { homecoming (!yahoo.lang.isvalue(b)) ? 0 : 1; } else if (!yahoo.lang.isvalue(b)) { homecoming -1; } homecoming yahoo.util.sort.compare(string(a).tolowercase(), string(b).tolowercase(), desc); }; and here datatable definition...

c++ - Does STL sort support UTF8? -

c++ - Does STL sort support UTF8? - does stl sort function back upwards alphabetical sorting of names have utf-8 characters in them? names german/french language? that exclusively depends on how store utf-8 characters , how comparer looks like. sort function agnostic of elements sorts. but mean “… when stored in char array” , reply no since char s store individual bytes of given utf-8 character, instead of logical character. sort function sorts elements delimited iterators. sort works if iterators / elements refer aware of info contain. isn’t case array of char s encode utf-8. the “correct” solution here parse utf-8 input array of proper (normalised) unicode code points, sort those, , translate utf-8. c++ sorting stl utf-8

extjs4 - How to add an ExtJs component at a specific position (index)? -

extjs4 - How to add an ExtJs component at a specific position (index)? - i have toolbar components (textfields , buttons) , dynamically add together component (textfield, example) before other components. i tried tbbar.add(mycomponent); without success. any idea? you can utilize ext.container.abstractcontainer.insert : tbbar.insert(0, mycomponent); extjs extjs4 extjs3

java - I can't see my JPanel and its components in the JApplet -

java - I can't see my JPanel and its components in the JApplet - i want set jpanel in japplet , problem can't see :( i've overridden paintcomponent of jpanel in order have background image, can't see anything. when remove paintcomponenet method had overriden, , set color background of panel, seems jpanel fills japplet , still no component visible :-s i've tried different layouts. set panel in center of panel fills japplet nil changed, , still no component , no background image visible :( import java.awt.borderlayout; import java.awt.graphics; import javax.swing.imageicon; import javax.swing.japplet; import javax.swing.jlabel; import javax.swing.jpanel; import javax.swing.jscrollpane; import javax.swing.jtextarea; public class main extends japplet implements runnable{ private jtextarea display; private thread outputthread; jpanel boardpanel; private clientviewmanager view; @override public void init() { seek { javax.swing.swingu...

visual studio - How to use xcopy to only copy files if they are newer? -

visual studio - How to use xcopy to only copy files if they are newer? - i have many web applications in visual studio solution. all have same post build command: xcopy "$(targetdir)*.dll" "d:\project\bin" /i /d /y it useful avoid replacing newer files old ones (e.g. accidentally add together reference old version of dll). how can utilize xcopy replace old files newer dll files generated visual studio? from typing "help xcopy" @ command line: /d:m-d-y copies files changed on or after specified date. if no date given, copies files source time newer destination time. so using xcopy replace old files new ones. if that's not happening, may have swap positions of /i , /d switches. visual-studio xcopy post-build-event

iphone - Pushing a view controller from a tableview controller doesnt work -

iphone - Pushing a view controller from a tableview controller doesnt work - i have setup table view controller , connected sub view when click on rows new subview appears. followed few tutorials step step, reason, nil comes when click on rows (the row beingness selected though). here main view controller: @interface tableviewsviewcontroller : uiviewcontroller <uitableviewdelegate, uitableviewdatasource> { iboutlet uitableview *tblsimpletable; iboutlet uinavigationbar *navbar; nsarray *arrydata; nsmutablearray *listofitems; } @property (nonatomic, retain) iboutlet uitableview *tblsimpletable; @property (nonatomic, retain) iboutlet uinavigationbar *navbar; @property (nonatomic, retain) nsarray *arrydata; @property (nonatomic, retain) nsmutablearray *listofitems; .m (relevant portions) // customize appearance of table view cells. - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentif...

php - Convert spaces between PRE tags, via DOM parser -

php - Convert spaces between PRE tags, via DOM parser - regex original thought solution, although became apparent dom parser more appropriate... i'd convert spaces &nbsp; between pre tags within string of html text. example: <table atrr="zxzx"><tr> <td>adfa adfadfaf></td><td><br /> dfa dfa</td> </tr></table> <pre class="abc" id="abc"> abc 123 <span class="abc">abc 123</span> </pre> <pre>123 123</pre> into (note space in span tag attribute preserved): <table atrr="zxzx"><tr> <td>adfa adfadfaf></td><td><br /> dfa dfa</td> </tr></table> <pre class="abc" id="abc"> abc&nbsp;123 <span class="abc">abc&nbsp;123</span> </pre> <pre>123 123</pre> the result needs serialised string format, utili...

java - Database name Regex restriction -

java - Database name Regex restriction - i've create java regex disable creation of databases. (i'm next these restrictions: http://dev.mysql.com/doc/refman/5.0/en/identifiers.html) can help me build regex restriction [0-9,a-z,a-z$_] ? this snippet: pattern pattern = pattern.compile("[0-9a-za-z$_]"); matcher matcher = pattern.matcher("userdatabase"); system.out.println(matcher.matches()); you didn't specify quantifier. look match 1 character. try changing to: pattern pattern = pattern.compile("[0-9a-za-z$_]+"); the + indicates should expressions 1 or more times. java regex database

javascript - Disabling a checkbox until an iframe has scrolled -

javascript - Disabling a checkbox until an iframe has scrolled - i suspect not possible due browser security, have form @ end of iframe displaying our terms , conditions page. below checkbox agreeing these terms , conditions. other sites have seen require scroll downwards in terms , conditions before checkbox active suspect done textarea or scrollable div rather iframe. as such aware of how can spot when iframe has scrolled in javascript or jquery can enable checkbox 1 time has been scrolled. following code in embedded document should it. $(window).scroll(function () { if ($(document).height() <= $(window).height() + $(window).scrolltop()) $("#chk", window.parent.document).removeattr("disabled"); }); javascript jquery html

postgresql - SQL Count days till first of the month -

postgresql - SQL Count days till first of the month - how count days date till first of next month example: --start date 07-07-2011 how many days till: -- 1st of succeeding month of start date above 08-01-2011 expected result (in days): 25 so if counted day 25, running query gets me desired timestamp: select current_date + interval '25 days' results: 2011-08-01 00:00:00 just can't think of way number of days, suggestions? or start date, end date, number of days between? i don't have postgresql server handy, untested, try: select (date_trunc('month', current_date) + interval '1 month') - current_date sql postgresql datetime

eclipse - javax.xml.stream.FactoryFinder$ConfigurationError: Provider com.ctc.wstx.stax.WstxInputFactory not found -

eclipse - javax.xml.stream.FactoryFinder$ConfigurationError: Provider com.ctc.wstx.stax.WstxInputFactory not found - i trying develop gwt application calls existing (working) web service. using: - jax-ws ri 2.1.6 in jdk 6 - jdk 6 - glassfish v3 - eclipse 20110615-0604 i have tested 3 component applications independently , work fine: 1. gwt application - browser invoking gwt server side code. based on gwt sample, http://code.google.com/webtoolkit/gettingstarted.html#create 2. java application uses jax-ws proxy invoke web service. based on jax-ws hello world sample. used wsimport on wsdl generate proxy code. 3. pre-existing web service, have wsdl for. when merge top 2 pieces of code, create gwt application calls web service within gwt server side code, merged application fails exception below. suspect class conflict between standard gwt dependencies , standard jax-ws dependencies. i next exception: javax.servlet.servletcontext log: exception ...

How to preserve a child element's bind functions in jQuery/javascript -

How to preserve a child element's bind functions in jQuery/javascript - i have tags want bind function within jquery's datepicker. however, jquery automatically binds function parent ( .ui-datepicker-inline ) div's mouseover , mouseout events. i want override function in cases, when other event occurs, revert default functioning. tried binding mouseover it's parent div ( hasdatepicker ) , worked fine. when unbind parent, child's old bind function stops working well. why this? there way avoid that? don't care if kid keeps it's bind function, long parent's bind it's thing afterward. don't want lose kid functionality when unbind parent. i have jquery element datepicker element has original bind ( .ui-datepicker-inline ) far can tell jquery ui code. // binds function, occurring after datepicker's bound function, // , works fine. datepicker.parent().bind('mouseover', hoverweek) // hoverweek function(event) /* ... */ //...

php - algorithm to find places in sorted array -

php - algorithm to find places in sorted array - i have sorted array of keys , value like array ( [1] => array ( [value] => 65 ...... ) [0] => array ( [value] => 65 ) [5] => array ( [value] => 35 ) [4] => array ( [value] => 3 ) [2] => array ( [value] => 0 ) [3] => array ( [value] => 0 ) ) i search simple algorithm run on array , homecoming array of places : places['1'] = keys => array(1,0), value => 65 places['2'] = keys => array(5), value => 35 places['3'] = keys => array(4), value => 3 places['4'] = keys => array(2,3), value => 0 so in first place have key 1 + ...

iphone - Error uploading application to AppStore - error 19011 -

iphone - Error uploading application to AppStore - error 19011 - i'm trying upload updated iphone version. compile distribution provisional , error - "application failed codesign verification. signature invalid, or not signed apple submission certificate. (-19011)". i'm trying create same process previous version , works fine. guess it's not provisional. bundle id using in new application similar previous. changed projects structures , added features. there issue might related: application runs on device when i'm trying create archive error of not find .h files though in path. i appreciate if can assist. thanks, eyal apple's app store experiencing downtime lately: http://www.tuaw.com/2011/07/13/itunes-connect-down-for-maintenance-for-most-of-july-13/ iphone xcode4 submit

javascript - Creating a loop that fades out each article in succession. jQuery -

javascript - Creating a loop that fades out each article in succession. jQuery - so thought fade each image out bottom.. it's going have backwardly traverse array. however, can't seem figure out @ moment. thought pause after running fadeout() function, thought set time out work, firebug gives me error: useless settimeout phone call (missing quotes around argument?) line 262. went far not utilize $.each loop , utilize (i=0 loop <script type="text/javascript"> //bottom nav functions $(document).ready(function(){ $('#bottomnav a:eq(0)').click(function(){ var arti = $('#aholder article'); var amt = arti.length; var = 0; (i=0;i<amt;i++){ $('#aholder article:eq('+i+')').fadeout(); settimeout(300); } }); }); </script> something should do: var = $('#aholder article').length, interval = se...

sql - Rails : Using jquery tokeninput (railscast #258) to create new entries -

sql - Rails : Using jquery tokeninput (railscast #258) to create new entries - i have been able implement add-on of new artist entries not included in ryan bates railscast #258 http://railscasts.com/episodes/258-token-fields so in other words, user can come in artist name autocomplete using jquery tokinput. however, i'd autocomplete results display artist names created individual user. does create sense? improve , more understandable illustration collection.rb, users create posts , specify 'collection' post belong to, should able add together posts collections created themselves. this post form artist_tokens virtual attribute: <%= form_for @post, :validate => true, :html => {:multipart => true} |f| %> <%= render 'shared/error_messages', :object => f.object %> <div class="field"> <%= f.label :title, 'title:' %><br /> <%= f.text_field :title %><br /> ...

Adding event handler using javascript doesnt work in IE -

Adding event handler using javascript doesnt work in IE - i trying add together event handler on page through javascript. tried follows, var span=document.getelementbyid("wd67"); span.setattribute("onchange","alert('hello');"); but though event handler attribute gets added, doesn't fire when page viewed in ie, in firefox works properly. how ie recognize it? don't utilize attributes that. best way add together event handlers using addeventlistener (all modern browsers) or attachevent (ie<9). furthermore, utilize handler function reference (wrap alert('hello') in function). a crossbrowser function add together handlers elements: function addhandler(obj,htype,fn){ if (obj.addeventlistener){ obj.addeventlistener(htype, fn); } else { obj.attachevent('on'+htype,fn); } } // usage var myspan=document.getelementbyid("wd67"); addhandler(myspan,'change',functio...

java - Customize eclipse new class template -

java - Customize eclipse new class template - i want eclipse set next comments when ever create new class. how create template this? // =========================================================== // constants // =========================================================== // =========================================================== // fields // =========================================================== // =========================================================== // constructors // =========================================================== // =========================================================== // getter & setter // =========================================================== // =========================================================== // methods for/from superclass/interfaces // =========================================================== // =========================================================== // methods // ====================================...

c++ - Counting overhead due to packing in C (gcc/g++) -

c++ - Counting overhead due to packing in C (gcc/g++) - i'd count/sum overhead in object file due packing (and, ideally, have gcc minimize me). for example, consider next construction (32 bit x86, gcc): struct { uint8_t a_char; uint32_t an_integer uint8_t another_letter; }; while actual info takes 6 bytes, construction takes 12 bytes in memory because both chars followed 3 padding bytes. reordering construction follows: struct b { uint32_t an_integer uint8_t a_char; uint8_t another_letter; }; the construction have sizeof(struct b) == 8 (still 4 bytes of overhead). (1) ideally, i'd gcc rearrange struct a struct b , save me space, version (4.2) doesn't seem optimization level. (2) alternatively, given struct a , i'd (automatically) either number 6 (total amount of overhead) or 4 (minimal amount of overhead, if members ordered "ideally"). purpose of determine whether or not manually reordering structures...

database - SQL IS NULL logic error -

database - SQL IS NULL logic error - i'm new forum i'm not sure if it's post twice same questions seems lastly question sort of died out , kind of have new question, here is i wanted programme if combo box empty, mean select (or imagine ignore where clause start out with). reply found throughout net utilize param = @param or @param null . however, when , want display data, shows column row names (meaning got right table) no data. i'm not sure why, read method sort of if statement. here's code simplified jut problem da.selectcommand = new oledbcommand("select * testquery customername = @customername or @customername null)", cs); da.selectcommand.parameters.add("@customername", oledbtype.varchar).value = combo_customerview.text.tostring(); da = info adapter. i'm using visual studio 2010 , ado.net oledb (access). works when have info on client when theres none, problem described above. sorta help helpful... thanks sql...

ruby on rails 3 - can't get my scaffold up -

ruby on rails 3 - can't get my scaffold up - i'm switching rails2 rails 3 nice results until now... rails new application -d mysql cd application application$ rails g scaffold questiontf questionconcept:string question:text answer:boolean ←[31mcould not find gem 'rails (= 3.0.9)' in of gem sources listed in yo ur gemfile.←[0m ←[33mrun `bundle install` install missing gems.←[0m running bundle install or bundle install rails did not work. @ anyrate, see in gem list. >gem list *** local gems *** abstract (1.0.0) actionmailer (3.0.9) actionpack (3.0.9) activemodel (3.0.9) activerecord (3.0.9) activeresource (3.0.9) activesupport (3.0.9) arel (2.0.10) builder (2.1.2) bundler (1.0.15) erubis (2.6.6) i18n (0.5.0) mail service (2.2.19) mime-types (1.16) polyglot (0.3.1) rack (1.2.3) rack-mount (0.6.14) rack-test (0.5.7) rails (3.0.9) railties (3.0.9) rake (0.9.2) rdoc (3.8) sqlite3 (1.3.3 x86-mingw32) thor (0.14.6) treetop (1.4.9) tzinfo (0.3.29) any h...

mysql - How can optimize this VIEW Statement? -

mysql - How can optimize this VIEW Statement? - i have view slow. don't view statements there lot of joins , union . here view statement. create view newview select t2.* table1 t1 bring together table2 t2 on t1.column1 = t2.column1 , t1.column2 = t2.column2 t1.column3 !='string' union select t1.*, 'add string lastly column' table1 t1 left bring together table2 t2 on t1.column1 = t2.column1 , t1.column2 = t2.column2 t2.column1 null or t1.column3 ='string' order column 4 basically thought if record exists in table1 , table2 , record table2 should overlay record table1 . how can optimize this? i have primary key id int not null auto_increment primary key in both tables not sure how can integrate view. want view have primary key or composite key. cannot utilize other columns columns can have null , duplicate values. you can bring together , compare, using outer join, utilize coalesce prefer t2 t1. to retain unique key, , as...

localization - Default CultureInfo.NumberFormat.NumberGroupSeparator for Poland is "space"? -

localization - Default CultureInfo.NumberFormat.NumberGroupSeparator for Poland is "space"? - our polish users didn't seem utilize convention far can see on materials have. under impression of our continental european users (da-dk, pl-pl, nl-nl) formatting n.nnn.nnn,nn , our british isles users (en-gb, en-ie) formatting n,nnn,nnn.nn. but reports in our tests polish users started coming out spaces, , looked odd me, , seems due space in cultureinfo.numberformat.numbergroupseparator, , don't think set there. any poles out there want comment on convention? it space. not in polish, illustration in french (iirc). , of course, in case thousands separator. definitely, when write one thousand 2 hundred 30 4 point (sic!) 50 6 like: 1 234,56 and yes, valid representation of polish number format. although 1234,56 good. real challenge reading big numbers, hundred thousands. localization internationalization number-formatting

php - HTML Tidy removes comments with conditions -

php - HTML Tidy removes comments with conditions - i making utilize of html tidy , i've had @ config options here. i've made utilize of option: $config = array( 'hide-comments' => 1 ); however, removes comments such this: <!-- test --> and this: <!--[if ie 6]>special instructions ie 6 here<![endif]--> should removing latter, know still comment serves purpose - maybe should utilize option? i'm pretty sure there no alternative it.. after html comment. recommend find alternative, or maintain html comments.. can't heavy. php html tidy

php - break array as a string -

php - break array as a string - i have array:- array ( [6] => 1 [6(hl)] => 3 [5] => 1 [7(hl)] => 2 ) how break , echo this:- 2(6), 3(6(hl)), 1(5), 2(7(hl)) i have seek utilize implode break string, result get:- 2, 3, 1, 2 any thought on this? thanks advance. assume array $arr : $output = ''; foreach($arr $k => $v) { $output .= $v . '(' . $k . ')' . ', '; } $output = substr($output, 0, strlen($output)-2); echo $output; php arrays

Where is __LP64__ defined for default builds of C++ applications on OSX 10.6? -

Where is __LP64__ defined for default builds of C++ applications on OSX 10.6? - i building 3rd-party library in 32-bit mode on osx 10.6 (the library xerces 2.8). have determined preprocessor definition __lp64__ set. however, far can see not beingness set within configuration files of 3rd-party project, , doing global search through files (via finder) #define __lp64__ not reveal me beingness defined system. i building library via make @ command line (xcode not involved). i know __lp64__ defined - , purpose is, given building project in 32-bit mode. it's defined automatically compiler rather in header. if it's set, you're building 64-bit targets. (a header could define if compiler hasn't already, though shouldn't. if think case, add together #define __lp64__ code, , @ error during preprocessing determine location of previous define.) c++ osx make gnu-make

c++ - Producer/Consumer design - Share queue variable across threads in Qt -

c++ - Producer/Consumer design - Share queue variable across threads in Qt - i have tried create concurrent queue class, in producer-consumer pattern. i based class off http://www.justsoftwaresolutions.co.uk/threading/implementing-a-thread-safe-queue-using-condition-variables.html in main thread, called next 2 methods using qt::concurrent qfuturewatcher<void> *loadwatcher; loadwatcher = new qfuturewatcher<void>(); qstring filename("myfile"); qfuture<void> future = qtconcurrent::run(this, &eraserbatch::loadtiles,filename); loadwatcher->setfuture(future); qfuturewatcher<bool> *procwatcher; procwatcher = new qfuturewatcher<bool>(); qfuture<bool> procfuture = qtconcurrent::run(this, &eraserbatch::processtile); procwatcher->setfuture(procfuture); so loadtiles producer, , processtile consumer. in loadtiles, have loop loading tiles so: for(int =0; < nxblocks; i++) { for(int j = 0; j < nyblocks; j++) ...

serialization - How to serialize nested Model in Rails? -

serialization - How to serialize nested Model in Rails? - i'm having extremely hard time figuring out how serialize nested attributes of model in rails. have recipetemplate store existing recipe in it's template_data attribute. recipe has nested attributes 2 levels deep. this on rails 3.1.0.rc4 class recipetemplate < activerecord::base serialize :template_data, recipe ... end class recipe < activerecord::base has_many :ingredients accepts_nested_attributes_for :ingredients ... end ingredients in recipe has nested attributes (subingredients). if set template_data object so: recipe.includes(:ingredients => [:sub_ingredients]).find(1) i'll typeerror "can't dump anonymous class class" makes sense, since doesn't know how serialize ingredients or subingredients. how can serialize nested attributes in model can use: serialize :template_data, recipe or have serialize info in other manner , perform type safety chec...

database - node-mysql connection pooling -

database - node-mysql connection pooling - i using node-mysql module (https://github.com/felixge/node-mysql) or (http://utahjs.com/2010/09/22/nodejs-and-mysql-introduction/) . is api handling connection pooling well? i mean every user request calling client.connect() query mysql , release connection: client.end() . is right way, or should connect/disconnect 1 time in code. i learning document: https://github.com/felixge/node-mysql/blob/master/readme.md update: feb 2013 - pool back upwards has been added node-mysql, see docs example using built-in pool: var pool = require('mysql').createpool(opts); pool.getconnection(function(err, conn) { conn.query('select 1+1', function(err, res) { conn.release(); }); }); pre 2013 solutions: you can utilize node-pool or mysql-pool or utilize own simple round-robin pool function pool(num_conns) { this.pool = []; for(var i=0; < num_conns; ++i) this.pool.push(createconnec...

css - Google's crazy ID and class naming conventions -

css - Google's crazy ID and class naming conventions - i playing around firebug , editing gmail's css file, , wanted edit button, div id button :rj . css not allow colons in —and starting as—id , class names. guess advanced trickery. i'm not sure if it's consistent each user, fwiw, id "search mail" button @ top of page. does know doing , how doing it? ids used quite strict on allowed, not much classes. html5, however, has lessened lot of restrictions on id values. here's article on what's allowed ids , classes in html5: http://mathiasbynens.be/notes/html5-id-class it's plenty create head hurt. edit: to address more of question why google using seemingly random id, i'm sure ids , classes using create perfect sense programmers. css gmail

cassandra - phpcassa fail connect to server -

cassandra - phpcassa fail connect to server - i install cassandra on ubuntu, set in conf file listen_address: 200.166.107.170 rpc_address: 213.186.117.170 rpc_port: 9160 then seek run php code other machine cassandraconn::add_node('200.166.107.170', 9160); $users = new cassandracf('keyspace1', 'users'); $users->insert('1', array('email' => 'hoan.tonthat@gmail.com', 'password' => 'test')); and result have this fatal error: uncaught exception 'exception' message 'could not connect cassandra server' in c:\inetpub\wwwroot\phpcassa.php:85 stack trace: #0 c:\inetpub\wwwroot\phpcassa.php(283): cassandraconn::get_client() #1 c:\inetpub\wwwroot\cassandra_test.php(31): cassandracf->insert('1', array) #2 {main} thrown in c:\inetpub\wwwroot\phpcassa.php on line 85 what can cause of error? thanks ensure using version of phpcassa distributed thobbs: https://github.c...

.net - Why does the exception thrown from Socket.Receive report an exception in my program when the server closed the connection? -

.net - Why does the exception thrown from Socket.Receive report an exception in my program when the server closed the connection? - i have connection closing in server (another executable) using socket.close() . in client on socket.beginreceive(byte[] buffer, int32 offset, int32 size, socketflags socketflags, asynccallback callback, object state) phone call throws socketexception stating an established connection aborted software in host machine this gives me impression closing connection thread has blocked on socket.receive() or socket.endreceive() . have done incorrectly here? have tested shutdown() before close() recommendation gracefuly closing socket on server side documented ? think graceful close should not cause client study connection aborted, should happen if connection reset (tcp rst). .net sockets

PHP import CSV with utf-8 accents -

PHP import CSV with utf-8 accents - i having issues importing csv file contains (french) names accents in them... when ever imported accent not display example félix turns fŽlix the file created hand , imported php. i have tried both utf8_encode() , utf8_decode() , nether function convert chars can viewed properly. my question how can render properly... convert char-set.. etc i believe text encoded in cp850 based on other questions i've seen on here. using fgetcvs() contents. please, seek iconv() function php csv utf-8 import

Parsing XML attributes within a namespace tag (PHP) -

Parsing XML attributes within a namespace tag (PHP) - i'm using php , curl xml, i'm having problems accessing specific type of attributes. say xml document this: <item> <title>example title</title> <link>http://www.google.com</link> <description>sample desc here.</description> <media:content xmlns:media="http://mediaurl.com/" url="http://www.exampleurl.com/" type="image/jpeg" medium="image" height="226" width="571"> </media:content> </item> i want access url attribute within tag, can't seem around namespace problem. currently, i've tried using: $promos = $item->getelementbytagnamens("media", "content"); foreach ($promos $promo) { $promoimage = $promo->getattribute("url"); break; } echo $promoimage; see http://www.php.net/manual/en/domdocument.getelementsbyta...

how to loop down in python list (countdown) -

how to loop down in python list (countdown) - how loop downwards in python list? for example loop: l = [1,2,3] item in l print item #-->1,2,3 loop down: l = [1,2,3] ??? print item #-->3,2,1 thank you another solution: for item in l[::-1]: print item python loops

jquery - Javascript higher & lower variable conditionals odd console output -

jquery - Javascript higher & lower variable conditionals odd console output - here simple code takes id values of " .somedivs " , puts them global variables sorted conditional statements, console. below can see getting weird results , no matter combination of conditionals utilize can't work right. seems basic, i'm thinking i'm violating law of js or i'm missing obvious. $(document).ready(function(){ $('.somedivs').mousedown(function(){ first = $(this).attr("id"); }).mouseup(function(){ sec = $(this).attr("id"); if(window.first > window.second){ var higher = window.first; var lower = window.second; var process = 1; }else if(window.second > window.first){ var higher = window.second; var lower = window.first; var process = 2; }else if(window.first === window.second){ var higher = window.first; var lower = window...

apache - cannot remove index.php in CodeIgniter application -

apache - cannot remove index.php in CodeIgniter application - i'm deploying web application made in our live server im having troubles in figuring out how remove index.php. have read several blogs regarding how remove index.php in codeigniter application. i have tried settings on .htaccess rewriteengine on rewritebase / rewritecond %{request_uri} ^system.* rewriterule ^(.*)$ /index.php?/$1 [l] rewritecond %{request_uri} ^application.* rewriterule ^(.*)$ /index.php?/$1 [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ index.php?/$1 [l] and on config.php $config['index_page'] = ''; $config['uri_protocol'] = 'request_uri'; but still can't figure out how remove it. need edit in apache httpd.conf? thanks! can seek removing ? nowadays after index.php in .htaccess: change: rewriterule ^(.*)$ index.php?/$1 [l] to: rewriterule ^(.*)$ /index.php/$1 [l] php apache c...

python - k-fold Cross Validation for determining k in k-means? -

python - k-fold Cross Validation for determining k in k-means? - in document clustering process, info pre-processing step, first applied singular vector decomposition obtain u , s , vt , choosing suitable number of eigen values truncated vt , gives me document-document correlation read here. performing clustering on columns of matrix vt cluster similar documents , chose k-means , initial results looked acceptable me (with k = 10 clusters) wanted dig bit deeper on choosing k value itself. determine number of clusters k in k-means, suggested @ cross-validation. before implementing wanted figure out if there built-in way accomplish using numpy or scipy. currently, way performing kmeans utilize function scipy. import numpy, scipy # preprocess info , compute svd u, s, vt = svd(a) # tfidf representation of original term-document matrix # obtain document-document correlations vt # 50 threshold obtained after examining scree plot of s docvectors = numpy.transpose(self.vt...

iphone - touch events on UIimageView which is on UIwindow -

iphone - touch events on UIimageView which is on UIwindow - i m using uiimageview on top of uiwindow. want handle touch event imageview, m not able it. when utilize uiimageview on uiview, can utilize touchbegan, touchended how handle when on uiwindow instead of uiview. thanks.. if want handle tap, have set, imageview.userinteractionenabled = yes; by default uiimageview has userinteractionenabled property set no. , can add together tap gesture recognizer it, uitapgesturerecognizer *tgr = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(anymethod)]; [imageview addgesturerecognizer:tgr]; [tgr release]; if want move image, can utilize uipangesturerecognizer. iphone objective-c ios uitouch uiwindow

html - syntax error near unexpected token `<' from Applescript to Python -

html - syntax error near unexpected token `<' from Applescript to Python - i using next command pass string python applescript string mytext contains html body of email starting <... applescript display dialog (do shell script "/users/mymac/documents/'microsoft user data'/'outlook script menu items'/ test.py" & mytext) python #!/usr/bin/env python import sys import string def main(): print sys.argv[1:] if __name__ == "__main__": main() how can rectify error? you don't want pass html argument python script. instead, like: display dialog (do shell script "/users/mymac/documents/'microsoft user data'/'outlook script menu items'/ test.py < webpage.html") print sys.stdin.read() python html runtime applescript

.net - SQL - Can I base a table primary key on more than one field, requiring the uniqueness of first OR second value? -

.net - SQL - Can I base a table primary key on more than one field, requiring the uniqueness of first OR second value? - let have product catalog. table has next fields: companyid , productid . want table primary key based on 2 fields, record unique when pair of companyid , productid fields have unique values. clear: record of cid = 1 , pid = 10 can coexist record of cid = 2 , pid = 10 (two companies may wish have product tagged same identifier, right?), can record of cid = 1 , pid = 9. of course of study 2 records both cid=1 , pid=10 values can not coexist. not want introduce column unique record identifier, because want these rules applied without creating c# layer checking integrity. hope understandable, tried clear somehow can't find words describe it. yes, primary key on 2 column want. seek out. .net sql database primary-key constraints

html - How-to mix fixed and percentage heights/width using css without javascript -

html - How-to mix fixed and percentage heights/width using css without javascript - i want accomplish layout this: ----------------------------------------------------------- | | | fixed height | | | |----------------------------------------------------------| | | s | | takes rest available screen height | c | | fluid height, not fixed, | r | | dependent on screen height | o | | | l | | | l | | | b | | | | | | r | --------------------------------...

php - Recursive function to calculate totals from bottom up in array -

php - Recursive function to calculate totals from bottom up in array - i have array looks this: array ( [0] => array ( [id] => 5 [title] => books [total_links] => 3 [subcategories] => array ( [0] => array ( [id] => 6 [title] => jeffrey archer [total_links] => 1 [subcategories] => array ( [0] => array ( [id] => 8 [title] => political [total_links] => 2 [subcategories] => array ( ...

c# - How do I list current files in a document library? -

c# - How do I list current files in a document library? - i have document library list of file names , set them string[] array. can give me sample code of how like? assuming need server side object model (for webpart or statndalone tool run on server). please @ spdocumentlibrary class has sample listing names of items in document library - http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spdocumentlibrary.aspx. c# asp.net sharepoint

uinavigationcontroller - UIBarbutton that stays on navigation bar through out the app -

uinavigationcontroller - UIBarbutton that stays on navigation bar through out the app - i trying create app in which, need navigation bar button on right corner of app time. on clicking on stopwatch appear. possible have such button? mean without repeating or rewriting code in every single viewcontroller ? ya, possible. have write code in global method , need phone call method in each view controller. uinavigationcontroller uinavigationbar uibarbuttonitem

ruby - Mapping many-to-one in YAML -

ruby - Mapping many-to-one in YAML - i'm trying introduce many-to-one kind of mapping within yaml configuration file rake. that is, have like: - server: address and i'd have like: - server: {1, 3, 5: address1; 2, 8, 12: address2} of course, not right syntax. this because need different address according given id. config['server'][3] # should homecoming 'address1' config['server'][5] # should homecoming 'address1' config['server'][12] # , should homecoming 'address2' is feasibile in way? thank in advance it should work way: create file in config called server_config.yml: common: &common common_stuff_foo: foo common_stuff_bar: bar server: 1: <<: *common adress: adress_for_server1 2: <<: *common adress: adress_for_server2 ... #some other servers 12: <<: *common adress: adress_for_server12 put file config/initializers config_...

php - Swiftmailer throwing error on SetBody -

php - Swiftmailer throwing error on SetBody - i having error using swiftmailer libs. $message_body = "body of message"; $transport = send_mail_transport(); //create mailer using created transport $mailer = swift_mailer::newinstance($transport); //create message $message = swift_message::newinstance(); $message->setbody('$message_body'); //displays $message_body in mail service client $message->setbody($message_body); //throws parse error in browser $message->setbody('body of message'); //works well. displays body of message in mail service client //what problem intent values variables? thanks ok. figured out changed $message->setbody("$message_body"); interestingly not documented in manual. php swiftmailer

PHP mysql_connect vs Ubuntu mysql terminal use -

PHP mysql_connect vs Ubuntu mysql terminal use - i'm using php in order connect mysql next way: $link = mysql_connect('...host...', '...username...', '...password...'); if (!$link) { die('could not connect: ' . mysql_error()); } echo 'connected successfully'; and connects fine. when trying terminal this mysql -h ...host... -u ....username... -p ...password... i give password , take result this: error 2003 (hy000): can't connect mysql server on '...host...' (111) any ideas how can solved? try sudo mysql -h ....etc. i'm running linuxmint , had utilize either su or sudo. think default have root come in terminal. ubuntu root inaccessible, feature don't ubuntu. php mysql ubuntu mysql-connect

iphone - Position a bar button item in a toolbar -

iphone - Position a bar button item in a toolbar - i have tool bar @ top , bottom of application , need create buttons set toolbars. ones designing application space placed between buttons on toolbar. aside manually coding in position alter buttons, there improve way accomplish through interface builder? you can add together bar button of type uibarbuttonsystemitemflexibalespace in place want space. uibarbuttonitem *barbutton1 = ... uibarbuttonitem *barbutton2 = ... uibarbuttonitem *flexiblespacebarbutton = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemflexiblespace target:nil action:nil]; toolbar.items = [nsarray arraywithobjects:barbutton1, flexiblespacebarbutton, barbutton2, nil]; iphone objective-c ios xcode uitoolbar...

C++ Subpattern Matching -

C++ Subpattern Matching - can please show me illustration using regex (regex.h) in c/c++ search and/or extracting subpattern in regex. in javascript, this, var str = "the string contains 123 dots , 344 chars"; var r = /the string contains ([0-9].*?) dots , ([0-9].*?) chars/; var res = r.exec(str); var dots = res[1]; var chars = res[2]; alert('dots ' + dots + ' , chars ' + chars); how can using regex.h in c/c++ (not boost or other libraries) ?? thanks, there no regex.h in standard c or standard c++, i'm assuming mean posix regular look library. c example: char const *str = "the string contains 123 dots , 344 chars"; char const *re_str = "the string contains ([0-9].*?) dots , ([0-9].*?) chars"; regex_t compiled; regmatch_t *groups; regcomp(&compiled, re_str, reg_extended); ngroups = compiled.re_nsub + 1; groups = malloc(ngroups * sizeof(regmatch_t)); regexec(&compiled, str, ngroups, groups, 0); (size...

Make a "pull up to get more" for a list on the Android -

Make a "pull up to get more" for a list on the Android - i used pull refresh johannilsson in order pull downwards list update it. trying create same concept pull up list bottom in order trigger getting more items server (the server calling returns limited amount of items each time). thought simple inversion after 2 days of trying invert pull downwards ready pull out hair. has ever done point me to? android android-widget

c# - how to insert rows into gridview -

c# - how to insert rows into gridview - sir, want have insert link functionality insert rows gridview have auto generate edit , delete in gridview in asp.net,. how it?can u provide me links. hope have understood question , solution might help you.. solution: <asp:gridview id="gridview1" runat="server" allowpaging="true" allowsorting="true" autogeneratecolumns="false" pagesize="2" autogeneratedeletebutton="true" autogenerateeditbutton="true" datakeynames="theid" datasourceid="sqldatasource1" > <pagersettings mode=numericfirstlast /> <columns> <asp:templatefield> <itemtemplate> <asp:hyperlink id="hyperlink1" runat="server" navigateurl="default2.aspx">hyperlink</asp:hyperlink> </itemtemplate> </asp:templatefield> <asp:boundfield datafield="theid...

php - Is there anything that can be put after the "ORDER BY" clause that can pose a security risk? -

php - Is there anything that can be put after the "ORDER BY" clause that can pose a security risk? - basically, want this: mysql_query("select ... ... order $_get[order]") they can create sql error putting non-sense in there, mysql_query allows execute 1 query, can't set 1; drop table ... . is there harm malicious user do, other creating syntax error? if so, how can sanitize query? there's lot of logic built on $_get['order'] variable beingness in sql-like syntax, don't want alter format. to clarify, $_get['order'] won't single field/column. might last_name desc, first_name asc . yes, sql injection attacks can utilize unescaped order clause vector. there's explanation of how can exploited , how avoid problem here: http://josephkeeler.com/2009/05/php-security-sql-injection-in-order-by/ that blog post recommends using white list validate order parameter against, safest approach. to respond...

jquery - JSON File Extension -

jquery - JSON File Extension - i've been saving json files .txt extension , worked jquery ajax calls. when alter extension .json , in jquery ajax phone call -- jquery.ajax() -- specify datatype: "json", contenttype: "application/json; charset=utf-8", the files no longer work. why so? shouldn't json files have extension .json? i'm using iis server. json { "rows": [ {"row":[ {"cells": [ {"data": "edit"}, {"data": "030194"} ]} ]}, {"row":[ {"cells": [ {"data": "add"}, {"data": "030194"} ]} ]} ]} jquery jquery.ajax ({ type: "get", url: "localhost/abc.json", datatype: "json", contenttype: ...

syntax - What is a regular language? -

syntax - What is a regular language? - i'm trying understand concept of languages levels (regular, context free, context sensitive, etc..). i can easily, explanations find load of symbols , talk 'sets'. have 2 questions: can describe in words regular language , how languages @ different languages differ? where people larn understand stuff? understand it, formal mathematics? had couple of courses @ uni used , barely understood tutors assumed knew it. can larn , why people 'expected' know in many sources? it's there's gap in education. here's example: any language belonging set regular language on alphabet. how can language 'over' anything? in context of computer science, word concatenation of symbols. used symbols called alphabet. example, words formed out of alphabet {0,1,2,3,4,5,6,7,8,9} 1 , 2 , 12 , 543 , 1000 , , 002 . a language subset of possible words. example, might want define language captures elite mi6...

Perl scripts that has the same function as Unix Command "history"? -

Perl scripts that has the same function as Unix Command "history"? - is possible write perl script grab history of unix commands? means write perl scripts has same function unix command "history"? i tried utilize tcsh history history not contain latest unix commands. latest available after close current xterm. there way solve without closing xterm? i saw in other post prompt_command='history -a', how utilize it? t.t thanks. have seen term::readline::gnu http://search.cpan.org/search?mode=all&query=term+readlin+gnu on cpan? so has readline tag , other implementations. perl unix