Posts

sql - PostgreSQL reusing computation result in select query -

for example using sql can do: select (a+b) c table c < 5 , (c*c+t) > 100; is there way using postgres? this alternative might use: select foo.c ( select (a+b) c table ) foo foo.c < 5 , (foo.c*foo.c+t) > 100 from performance point of view, think it's not optimal solution (because of lack of clause of foo subquery, hence returning table records). don't know if postgresql query optimization there.

wordpress - How to make navigation a <select> list without a plugin? -

i have tried several solution this, none of them worked. managed make nav list <select><option> list, without names of pages, without indication of url any ideas how can make functional select list navigation without external plugin? (the ideal solution pages urls appear value in option can use javascript page navigation) if don't have custom script loader, add theme's functions.php: function addscripts() { if ( !is_admin() ) { wp_register_script('navscript', get_template_directory_uri() . "/js/navscript.js")); wp_enqueue_script('navscript'); } } add_action( 'wp_print_scripts', 'addscripts'); in wordpress dashboard, go appearance->my custom widgets, create new widget (give name, select html type), , add version of (leaving out div, can contain/style liking): <form> <select id="supernav"> <option value="">choose destina...

php - How is data replaced in memcached when it is full, and memcache performance? -

from memcached wiki: when table full, subsequent inserts cause older data purged in least used (lru) order. i have following questions: which data purged? 1 older insertion, or 1 least used? mean if accessed data d1 oldest insertion , cache full while replacing data replace d1 ? i using php interacting memcached. can have control on how data replaced in memcached? not want of data replaced until expires if cache full. data should not replaced instead other data can removed insertion. when data expired removed immediately? what impact of number of keys stored on memcached performance? what significance of -k option in memcached.conf ? not able understand "lock down paged memory" means. also, description in readme not sufficient. when memcached needs store new data in memory, , memory full, happen this: memcached searches a suitable* expired entry, , if 1 found, replaces data in entry. answers point 3) data not removed immediately, when new dat...

mutiple json string in android -

i have return json string. example have 1 json string: [{"locationvalue":"payroll - 9","locationid":"465","isselected":false}] and returned second json string: [{"cc2description":"denver - dn","cc2":"dn","isselected":false},{"cc2description":"las vegas - lv","cc2":"lv","isselected":false}] ans on. in android have written this: jsonarray jsonobject = new jsonarray(jsonstring.tostring()); for(int i=0;i<jsonobject.length();i++) { log.v("log", jsonobject.getstring(i)); } but can access 1 json array. want other json array also. you cannot decode multiple separate json structures in single call. json structure must complete proper javascript object or array on own, e.g. two arrays this: [1,2,3][4,5,6] is invalid, because it's 2 separate arrays smashed against each other. however, [[1,2,3...

android - EditText in ExpandableListView - Retaining focus when soft keyboard is opened -

Image
i have expandablelist multiple groups, , each group contains child of different type (different layouts). have several activities similar structure, different child views, , decided write custom adapter it. adapter works part, except couple of problems: typing text in child view next impossible. appears edittext loses focus after each character typed. have attached screenshot illustrate behaviour. when groups expanded / collapsed, after couple of times, text in textviews seem disappear, first letter of first word in each view appearing. somehow appears though layout parameters miscalculated somehow. here screenshots: and here code adapter: public class genericexpandablelistadapter extends baseexpandablelistadapter { private context context; private string[] groups; private view[] children; public static interface expandablelistitemclicklistener { public void onclick(view view, int groupid, int itemid); } public genericexpandablelistada...

android - List of files of saved to the internal storage -

my android application saving stats internal storage. each file name in format of "appname-currentdate" i wondering: when save internal storage, there specific folder assigned app, or files saved along files other applications in same directory. is there way know list of files saved application internal storage thank much. 1) depends on method use file handle. files stored in application specific directory, eg. /data/data/[your.package.name]/ . files in directory readable application. 2) use getfilesdir() method in activity file handle , use listfiles() on array of file representing files in application data folder. further reading: http://developer.android.com/guide/topics/data/data-storage.html

objective c - ios5 - "EXC_BAD_ACCESS" when clicking button -

Image
i total beginner objective c. currently try display view in main window. view contains button. reason clicking button xcode throws error. hopefully can me understand doing wrong. - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions{ self.window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]]; // override point customization after application launch. self.window.backgroundcolor = [uicolor whitecolor]; btnview *btn = [[btnview alloc] init]; [self.window addsubview:btn.view]; [self.window makekeyandvisible]; return yes; } the viewcontroller of button view has action recognizing touch event h file: - (ibaction)touched:(id)sender; and in m file - (ibaction)touched:(id)sender { //actions ... } by touching button following error: whats wrong? m file: h file: i assume have arc enabled project. when return didfinishlaunchingwithoptions: ob...

php - Dynamic content with Jekyll -

i thinking of using jekyll blogging engine upcoming project. however, need small part of website dynamic, using sort of sever-side language (ruby, php, node.js, etc.) i want posts static expect jekyll, @ bottom of page have piece of content needs rotate randomly on each page load. don't want use javascript this. is possible within jekyll? you can use server side includes . might need configure server or change extension of generated files .shtml. jekyll should generate need insert dynamic content: <!--#include virtual="dynamic.rb" --> dynamic.rb should produce valid html display.

c - Get column type per row -

i have table few rows. datatypes not set in table structure , rows integers while blobs. how figure out what's what? i'm using c api . sqlite3_column_type gives me same datatype rows, isn't correct. sqlite3_column_type function gives actual type of data. beware when value other sqlite3_column_* functions, sqlite converts data has , type changes reflect that. ask types before doing else row. there logic converts values when inserting them. data expect? check typeof sql function (the sqlite3_column_type c function , typeof sql function should return same value).

linux - the dynamic array in C -

recently found annoyed deal array in c language. have realloc() increase size. , there no standard data structure vector in c++ or arraylist in java have got known in linux kernel, there data structure, such kfifo, use kfifo_in(), kfifo_out() function. means user define kfifo *pointer; record array, , variable not contain info type contained in structure. user have remember when try use dynamic array kfifo pointer. think may little confusing. there better way deal problem? what's common solution in linux c programing? realloc not bad, long not spread on code, , use reasonable strategy grow dynamic array. rolling own dynamic arrays in c matter of implementing handful of easy functions. numerous short articles walk through exercise - here one example. article defines struct represents dynamic array, along used , allocated size. provides functions initializing, growing, , de-allocating array represented structure. there no explicit initialization function in ...

Check for installed packages in R -

based on answer question: elegant way check missing packages , install them? i'm using following code make sure packages installed when upgrade r, or set other users: list.of.packages <- c("rodbc", "reshape2", "plyr") new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"package"])] if(length(new.packages)) install.packages(new.packages) i've placed in .first function in .rprofile, when start r gives following error , continues starting up: error in match(x, table, nomatch = 0l) : not find function "installed.packages" if run code after prompt works fine. ideas why? thanks! it appears reading ?startup that: next, if function .first found on search path, executed .first(). finally, function .first.sys() in base package run. calls require attach default packages specified options("defaultpackages"). now, installed.packages in utils package, typi...

Syncfusion gridDataControl pagination - version 9.0.1.20 -

i'm using older version of syncfusion, version 9.0.1.20. wondering if version provides pagination support griddatacontrol? or added version after 10? also, wondering if there's work-around achieve pagination(ondemandpaging) in griddatacontrol version of syncfusion i'm using. thanks! paging support added in 9.3.0.61 version if want display data without sorting , filtering, can try below workaround, “create griddatacontrol , change itemsource of griddatacontrol based on page navigation. can load itemsource in ondemand”

c - unbalanced nested for loops in openmp -

i've been trying parallelize algorithm unbalanced nested loops using openmp. can't post original code it's secret project of unheard government here's toy example: for (i = 0; < 100; i++) { #pragma omp parallel private(j, k) (j = 0; j < 1000000; j++) { (k = 0; k < 2; k++) { temp = * j * k; /* dummy operation (don't mind race) */ } if (i % 2 == 0) temp = 0; /* can't use openmp collapse */ } } currently example working slower in multiple threads ( ~1 sec in single thread ~2.4 sec in 2 threads etc.). things note: outer loop needs done in order (dependent on previous step) (as far know, openmp handles inner loops threads don't created/destroyed @ each step, right?) typical index numbers given in example (100, 1000000, 2) dummy operation consists of few operations there conditional operations outside inner loop collapse not option (doesn't seem increase performance anyways) lo...

java - JPA Function Dependency of a table -

in 'country' table column 'countryname' referenced 'city' , 'state' table , need check database tables referenced column via jpa given countryname. is possible without use of nativequery. tried via nativequery need either namedquery or query.

ruby on rails - Generic way of using content_tag for multiple elements of the same kind -

i want generate html like, <label for='field'> label text <span class='span1'> text 1 </span> <span class='span2'> text 2 </span> ... </label> i want call helper such as, label_for 'field', :label => 'label text', :type1 => 'some text 1', :type2 => 'some text 2' for tried like, content_tag(:label, opts[:label], :for => field_name) ['span1', 'span2'].map { |i| content_tag(:span, opts[i], :class => i) if opts[i] }.compact.joins('+').html_safe } end but not work (of course). ['span1', 'span2'] array fixed , user has option of choosing display many spans needed. how can solve problem? why not this? def special_label_for(field_name, label_text, span_array) content_tag "label", :for => field_name concat label_text span_array.each_with_index |span_content, index| con...

php - Can't make a simple call to a web-service with NuSoap -

this first time working web-services , nusoap (and soap overall). i'm trying simple call function using nusoap, , simple looks, can't make work. this code: <?php require_once('nusoap/lib/nusoap.php'); $url = "http://server10logic.com/wsamib-0.1/services/comprobanteoperacion?wsdl"; try { $client = new nusoap_client($url); $result = $client->call('listcomprobanteoperacion'); } catch (soapfault $e) { echo 'error0'.$e->getmessage() . "\n"; } echo '<pre>';print_r($result); ?> the result of code can seen here: http://dev.etic.com.mx/bmv/test.php any welcome. if need more information let me know. thanks in advance while creating client, add second boolean parameter, true , tells library working wsdl file. $client = new nusoap_client($url, true);

mysql - Run SHOW TABLES with only part of table name -

i want select tables on database no tables. tables part of name "tt". example: table list: ( users , tt_content , contact , tt_sub ) i want select tt_content , tt_sub . how can this? show tables 'tt%'; ought it.

How event driven systems work? -

this question bugs me. how event handling systems works? what understand there must loop waits message or activates portion of code. know wrong idea need understand how works (abstractly)? if there diagrams can explain ! if asking events in c# suppose implementation of publisher/subscriber or observer patterns. http://en.wikipedia.org/wiki/publish%e2%80%93subscribe_pattern http://en.wikipedia.org/wiki/observer_pattern in short, there no waiting, subscriber gives publisher code (via delegate) invoke when publisher fires event.

java - Escaping quotes -

i'm trying save string database, need quotes part of string: string password = "\"foo\""; i expecting value in database "foo" (quotes included) slash stored. should slash escape character , not saved when compiled? however slash stored. not in string you've posted isn't. string you've posted has 5 characters in it: " f o o " it may whatever you're using view showing quotes escaped it's clear they're not delimiting string. you can prove so: public class showstring { public static final void main(string[] args) { string password = "\"foo\""; int index, len; (index = 0, len = password.length(); index < len; ++index) { system.out.println("[" + index + "]: " + password.charat(index)); } } } output: [0]: " [1]: f [2]: o [3]: o [4]: "

xslt - SharePoint 2010 Custom XSL View Rendering with Jquery and Ratings Field -

i'm developing sharepoint 2010 internet facing web site faq capabilities. i've got custom list containing id, title (rennamed "question"), answer , fileds rating. i writing xsl stylesheet in order customize list view rendering in following way: faq items should displayed accordion, jquery each faq rated users. so, wrote xsl : <xsl:stylesheet xmlns:x="http://www.w3.org/2001/xmlschema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt js" xmlns:ddwrt="http://schemas.microsoft.com/webparts/v2/dataview/runtime" xmlns:asp="http://schemas.microsoft.com/aspnet/20" xmlns:__designer="http://schemas.microsoft.com/webparts/v2/dataview/designer" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:sharepoint="microsoft.sharepoint.webcontrols" xmlns:js="...