Posts

Showing posts from September, 2015

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="...

concurrency - java Fork/Join clarification about stack usage -

i read implementation of fork/join framework introduced in java 7 , wanted check understand how magic works. as understand, when thread forks, creates subtasks in queue (which other thread may or may not steal). when thread attempts "join", checks queue existing tasks , recursively perform them, mean 'join' operation - 2 frames added thread call stack (one join , 1 new taken task invocation). as know jvm not support tail call optimization (that may serve in situation remove join method stack frame) believe while performing complicated operation lot of forks , joins thread may throw stackoverflowerror . am right or did find cool way prevent it? edit here scenario clarifying question: (for simplicity) have 1 thread in forkjoin pool. @ point in time - thread forks , calls join. while in join method thread discovers can perform forked task (as found in queue) invokes next task. task in turn forks , call join - while executing join method thread find forke...

iOS sqlite data from SQL server -

i need large data (~100mb) sql server app's sqlite once day wirelessly. app has json/restful webservice other things, figured isn't possible 100mb loaded memory via json object cause memory crash when try write json sqlite. i considering retrieving file url , saving locally. way data isn't loaded memory. the part fuzzy on best way data, ie download .sqlite compressed file or download text file prepared insert statements existing sqlite. pretty sure prior best choice, not db savy enough know what's possible on sql server. possible sql server select data subsets , create sqlite file? maybe needs scripted. one thing consider structrue of data on sql server. need subsets of data several tables, not entire tables. example: sql server houses 100 physical sites data, app @ site x today, load site x data. am on right track or did miss obvious solution?

Rails form_for additional field -

i need user enter url within form. however, url not column in database. error following form. i have form create video (new.html.haml) = form_for @video |f| .field = f.label :title = f.text_field :title .field = f.label :description = f.text_area :description .field = f.label :url = f.text_field :url .field provider %br = radio_button :video, :provider, 'vimeo' = f.label :provider, 'vimeo', :value => 'vimeo' %br = radio_button :video, :provider, 'youtube' = f.label :provider, 'youtube', :value => 'youtube' %br .actions = f.submit "add video" rails complains url not column in url unknown method or variable. what want do basically, need url video user adding,along title of video, description , provider. all fields have column in databse, url doesn't. i need format url , call methods on it. create new output storin databse. so url, provider_video_id , thumb databse colum...

admob - Fixed view through various activities in Android -

how implement fixed view through various activities in android 2.1 upwards? fixed mean view should retain state when activity changes. in particular, i'd have admob adview on top of every activity without reloading ad every time app starts new activity. i don't think possible using different activities. use 1 activity , split screens through multiple fragments inside activity , adding/removing them while keeping fixed view untouched.

ios - access view inside a storyboard -

Image
how 1 access, in code, view dragged object browser view in storyboard? for example, created uiview assigned viewcontroller class. dragged map view view. need start manipulating map view in code. how access it? i've tried things self.view.subview haven't gotten anywhere there. thanks. you should use outlets, first select storyboard file, go view->assistant editor->show assistant editor next select map view, press control on keyboard , drag right section of xcode show .h file, following appear write mapview inside , hit enter, create outlet use can use mapview access mkmapview

mysql - My PHP generated CSV file is saving as a PHP file -

i've learned how create csv files mysql data stackoverflow question. problem is, reason when call code, tries save file called index.php (which current page). inside index.php file data table there, separated commas. i'm guessing have small typo somewhere, after playing code cannot find it. can help. $result=mysql_query("select * tbl_email"); if(mysql_num_rows($result)) { header ("content-type: application/csv content-disposition:\"inline; filename=messages.csv\""); echo "ref #,company,name,email,message,date\n"; while($row = mysql_fetch_row($result)) { $companyname = mysql_query("select company tbl_users user_id ='$row[1]'"); $datname = mysql_fetch_array($companyname); echo"$row[7],$datname[company],$row[2],$row[4],$row[5],$row[6]\n"; } die(); } you need multiple header() calls rather 1 call supplies multiple headers on single line, , believe appropriate mime type csv te...

MySQL and PHP regarding how to store information properly -

i need direction please. reading on mysql learned config db , keep running optimally need make db follows. example have db members: holds~ 1-primary_id, 2-email, 3-password, 4-address_id, , 5-phone_id. ok know need make new db named db: address , db: phone db address: holds~ 1-address_id(unique), 2-street, 3-city, 4-state, 5-zip finally db: phone db phone: holds~ 1-phone_id(unique), 2-area code, 3-phone question #1: efficient way setup database? && correct? question #2: when using php insert record html form. how ensure address inputted in form assigned db address , correct address_id recorded in db members? && same phone_id in db phone , db members? thanks help! what should mysql_query statement like? mysql_query("insert members (email, password, address, phone, timestamp) values('$email', 'sha($pass)', '$address', '$phone', now())"); how assign address address db , phone phone db? need use separate ...

jquery - Angular.js: $http.post to different partial page -

i have parent page , 1 partial pages. have form in parent index.html, need take these values , pass backend, , return json object need bind partial page. advanced search , values returned has displayed in grid. i haven't seen example of this. can 1 point me in right direction. thanks krishna

google app engine - Spring Security: SecurityContextHolder.getContext().getAuthentication() returns null on Wicket Page -

i using spring mvc(for rest), spring security 3 , apache wicket (ui) on google app engine. working fine except having trouble in getting authentication on wicket page through securitycontextholder after login. i have google'd issue, none seems working me. suspect wrong web xml. can please help. thanks. i using tutorials spring security on google app engine http://blog.springsource.org/2010/08/02/spring-security-in-google-app-engine/ here web.xml <?xml version="1.0" encoding="utf-8"?> <web-app> <display-name>mtp portal</display-name> <context-param> <param-name>contextconfiglocation</param-name> <param-value> /web-inf/mtp-web-servlet.xml, /web-inf/mtp-web-security-context.xml </param-value> </context-param> <filter> <filter-name>springsecurityfilterchain</filter-name> <filter-class>org.springframework.web.filter.delegatingfilterpr...

java - can not run servlet in cpanel+ tomcat -

i use tomcat + cpanel . jsps , tags correct run can not run servlet . my web.xml content : <servlet> <servlet-name>servlet1</servlet-name> <servlet-class>pack1.servlet1</servlet-class> </servlet> <servlet-mapping> <servlet-name>servlet1</servlet-name> <url-pattern>/servlet1</url-pattern> </servlet-mapping> when request www.mydomain.com/servlet1 error (404) : not found requested url /servlet1 not found on server. additionally, 404 not found error encountered while trying use errordocument handle request. please me. the cpanel suggests you're using 3rd party host. lot of cheapass 3rd party hosts have due system limitations different rules deploying servlets. should reading developer guide/documentation/faq how deploy servlets on host. example, 3rd party hosts require specific folder or package structure, or require specific url structure. go...

Rails specify load order of javascript files? -

in application.js file, have: //= require jquery //= require jquery_ujs //= require underscore //= require backbone //= require_tree . // //= require .//community_app // //= require_tree ../templates/ //= require_tree .//models //= require_tree .//collections //= require_tree .//views //= require_tree .//routers but generated html doesn't obey order: <head> <title>communityapp</title> <link href="/assets/application.css?body=1" media="all" rel="stylesheet" type="text/css" /> <link href="/assets/communities.css?body=1" media="all" rel="stylesheet" type="text/css" /> <link href="/assets/home.css?body=1" media="all" rel="stylesheet" type="text/css" /> <script src="/assets/jquery.js?body=1" type="text/javascript"></script> <script src="/assets/jquery_ujs.js?body=1" type=...

Is there a table to query for Oracle Reserved Words? -

is there table can query of oracle reserved words? example, can query user_tab_cols or all_tab_cols handy to-date table information. there view called v$reserved_words

Entity Framework, one-to-many, several columns -

if have main table, lets orders, , sub table of items , items table has fields item number has nullable (optional) field color applied items. how update items table, @ same time orders table, using entity framework? here code example of have far. 2 problems, i'm entering 1 of items and, research indicates, can't add field items table? foreach (guid c in allitems) { items.orderitemid = guid.newguid(); itemsorderid = order.orderid; items.itemid = c; if (itemid = itemthatletsyouchoseacolorid) { items.itemcolorid = colorid; } else { items.itemcolorid = null; } } context.orders.addobject(orders); context.items.addobject(items); context.savechanges(); my orders table gets record inserted, , items gets 1 record inserted. i'm missing basic here, i'm afraid. btw, entity framework 4.0, which. believe, not require use of entitykey. you're adding object items collection 1 ti...

emacs - Unit testing Clojure on the fly in a separate frame -

i watching amazing "emacs rocks" video , noticed developers using 2 windows side side 1 window emacs , other window used (nearly) run unit tests. video here (it's looking imo): http://www.youtube.com/watch?v=zxt-c_n82_w how can same when working clojure? what i'd see on screen be: the .clj file i'm editing in buffer one repl one other window (an emacs frame?) see results of unit tests (the unit tests being defined either inside each .clj file test or in separate .clj files, don't care) ideally i'd have results of unit tests shown in emacs frame regular terminal (as long there's @ least color support). is doing similar? don't mind shell scripting or elisp'ing or else long allows similar setup unit tests clojure code. if add lein autotest plugin ctrl-x 2 split pane horizontally ctrl-x 3 split top panel code , test clojure-jack-in put repl in bottom buffer m-x ansi-term in 1 of top panels decent terminal run l...

php - How to preg_match_all() + extract + replace + delete? -

i'm not experienced preg_match_all , similar , looking simple way following: consider text: $string = 'this text written on [set_stamp]1341066037[/set_stamp] , 1 on [set_stamp]1340903119[/set_stamp].'; what need do: get data (here timestamps) between tags [set_stamp] , [/set_stamp] replace captured timestamps corresponding date like: date('y-m-d h:i:s', $timestamp) remove [set_stamp] , [/set_stamp] tags the final output similar this: "this text written on 2012-07-12 14:26 , 1 on 2012-07-11 17:10." you can use preg_replace_callback() following regex: #\[set_stamp\](.+)\[/set_stamp\]#iu example code: $string = 'this text written on [set_stamp]1341066037[/set_stamp] , 1 on [set_stamp]1340903119[/set_stamp].'; echo preg_replace_callback('#\[set_stamp\](.+)\[/set_stamp\]#iu', function($m) { return date('y-m-d h:i', $m[1]); }, $string); the output of code is: this text written on 2012-...

Jquery dialog open/close -

i'm trying create model dialog in jquery. button open dialog. opens closes it. never tell close when click button opens , closes. idea why? <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script> <script src="http://code.jquery.com/ui/1.8.21/jquery-ui.min.js" type="text/javascript"></script> <script src="http://jquery-ui. googlecode.com/svn/tags/latest/external/jquery. bgiframe-2.1.2.js" type="text/javascript"></script> <script src="http://jquery-ui. googlecode.com/svn/tags/latest/ui/minified/i18n/jquery-ui-i18n.min.js" type="text/javascript"></script> <asp:button id="rejctbutto...

How to scale images for cocos2d game to iPhone/iPad (with and without Retina) -

i'm working on game in cocos2d (1.0.1), artist sent me psd project files, 3200x1800 resolution 300ppi. i'm supposed make ipad , iphone , without retina display. realised don't know nothing graphics. best way prepare images iphone , ipad (both hd , sd). should scale 480x320? should use apps texture packer? how without loss? easiest way make graphics both ipad retina display , iphone retina display , use texture packer scale them automagically non-retina size each type of device. as workflow iphone becomes: create retina graphics 640x960 display. use texture packer create textures retina version , use texture packer scale retina texture down lower-resolution device there. look @ how use resulting images , plists in cocos2d. in regards #3 there tutorials here: http://www.codeandweb.com/texturepacker/tutorials/#cocos2d cocos2d @ handling point conversions between retina , non-retina versions of game. once tell use retina graphics if available can prog...

MySql grant user permission -

i want create new user in mysql. not want new user existing databases [i want grant select privilege him], can , new database creates. firstly, there way grant permission per database owner? if possible, ideal thing looking for. , if not, how restrict particular user accessing [only select privilege] specific database only, allowing him wants remaining ones? from mysql grant documentation : create user 'jeffrey'@'localhost' identified 'mypass'; grant select on *.* 'jeffrey'@'localhost'; grant on db1.* 'jeffrey'@'localhost'; the first command creates user. second grants select on databases , tables. third command grants access tables in db1. is there else specific looking do?

flash builder - Flex AS3 asynchronous sprite (MovieClip) animation -

i'm using starling framework under flex as3 project. i've sprite named bird , use altas animation. my problem is, there 2 bird in screen , both of them flaps @ same time. want flap asynchronous. how can this, can give start frame number each of them ? thanks.. public class bird extends sprite { private var bird_mc:movieclip; public function bird(startframe:number = 0) { super(); this.addeventlistener(starling.events.event.added_to_stage, onaddedtostage); } private function onaddedtostage(event:event):void { this.removeeventlistener(event.added_to_stage, onaddedtostage); createbird_mc(); } private function createbird_mc():void { bird_mc = new movieclip(assets.getatlas().gettextures("bird_"), 16); bird_mc.x = math.ceil(-bird_mc.width/2); bird_mc.y = math.ceil(-bird_mc.height/2); starling.core.starling.juggler.add(bird_mc); this.addchild(bird_mc); ...

Android layer-list spritesheet -

Image
i have created sprite sheet (single image contains multiple images) 4 different icons. create layer-list uses different parts of images make single image, example: <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:drawable="@drawable/spritesheet"/> <item android:drawable="@drawable/spritesheet"/> <item android:drawable="@drawable/spritesheet"/> <item android:drawable="@drawable/spritesheet"/> </layer-list> for example sprite sheet this: and final result this: i have tried different options available here can't find solution. why don't use parts of picture? @drawable/layers.xml, example: <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:drawable="@drawable/part1"/> <item android:drawable="@drawable/part2"/> <item an...

dns - Nginx server_name isn't applying to rewrite subdirectories. -

i'm trying use nginx redirect main page (www.domain.com) subdirectory (www.domain.com/store). have redirect working, whenever use domain name redirect me ip address (www.ip.com/store). server nginx config. thank in advance help! server { listen 80 default_server; server_name *.domain.com; location / { index index.php index.html index.htm; } location = / { rewrite ^/store permanent; } root /usr/local/www/nginx; } you missed space. rewrite ^/store permanent; try match '/store' @ beginning of uri path (thanks ^) , if matches, rewrite 'permanent'. since inside location = / , never succeed. instead, need: rewrite ^ /store permanent;

excel VBA to Automatically select Yes when prompted during mail merge -

i'd system automated users possible. right now, have code runs when user clicks button. code takes data intention of applying word document via mail merge. everything works intended except there's message pops saying opening document run following sql command: select * 'tags$' data database placed in document. want continue? i need keep simple possible without risking users selecting "no" because they're confused. how can vba automatically proceed , accept data placement, had selected "yes"? i tried using following code block alerts in hopes default "yes" , proceed, didn't work. application.displayalerts = false this have sub runmailmerge() application.screenupdating = false dim wdoutputname, wdinputname string wdoutputname = thisworkbook.path & "\nametags - " _ & format(date, "d mmm yyyy") wdinputname = thisworkbook.path & "\nametags....

PHP Logic - How to handle score ties? -

i'm trying distribute prizes based on scores. i'm having trouble logic when comes tie's . can give me logic pointers on handling tie between 3 or more people? update: goal -- make array of people have tied (only them) know position people in. i have few sample phases can skim through: example 1 - works 0 ties <?php function give_prize($a, $b) {return;} $prize = array(500, 250, 75); $user = array( 'user1' => 650, 'user2' => 500, 'user3' => 200, 'user4' => 100, ); $prize_count = count($prize); ($i = 0; $i < $prize_count; $i++) { give_prize($user[$i], $prize[$i]); } example 2 - works 1 tie (is way?) <?php ($i = 0; $i < $prize_count; $i++) { if (isset($user[$i+1])) { if ($user[$i] == $user[$i++]) { // tie breaker code } } } but in tie of 3 or 4 people? should follow above , more if checks? i start grouping users score , sort...

android - Get a reference to same view in multiple inflated layouts -

i tried find answer question, , thought code work wanted but.. it's not. problem: have "parent" linearlayout add several nested inflated "child" linearlayout's. works. each child layout has 2 views, custom chipview , textview. after inflate each child want able modify chipview , textview of each child "whenever want" during activity. i created simple project play with, can manage access chipview , textview of first inflated child layout. subsequent ones inserted correctly in parent apparently can't variable reference them. i doing earlier creating chipview's @ runtime , worked flawlessly, wanted more elegant approach xml can control separately. in activity have button creates children , 1 should call method in current chipview (i.e. last inflated or 1 click on). activity: public class sandboxactivity extends activity { private button okbtn; private button add; private edittext count; private chipsview chips; ...

php - Looping through an array to create class properties -

i trying create class properties each element in array. array created @ point, i'm creating here demonstration purposes. i'm not familiar classes , objects. me out? class myclass { $days['first'] = "mon"; $days['second'] = "tue"; $days['third'] = "wed"; foreach ($days $k => $v) { public $k = $v; } } $obj = new myclass; echo $obj->first; // mon i keep getting "parse error: syntax error, unexpected t_variable, expecting t_function". use constructor set properties dynamically using $this->$key array passed in parameter, so: class myclass { function __construct( $dates) { foreach( $dates $k => $v) $this->$k = $v; } } // can put __construct() function $days = array(); $days['first'] = "mon"; $days['second'] = "tue"; $days['third'] = "wed"; $obj = new myclass( $days); echo $...

ruby on rails - updating the robots -

ok want add this user-agent: * disallow: / to robots.txt in enviroments other production...any idea on best want this. should remove public folder , create routes/views i using rails 3.0.14 prior asset pipeline...any suggestions here's real working code project (it's nginx config, not robots.txt, idea should clear). task :nginx_config conf = <<-conf server { listen 80; client_max_body_size 2m; server_name #{domain_name}; -- snip -- } conf put conf, "/etc/nginx/sites-available/#{application}_#{rails_env}" end so, basically, create content of file in string , put desired path. make capistrano upload content through sftp.

algorithm - Placing a point to minimise distance from the farthest point -

i have question, given set of points , how place point constraint distance farthest point small possible?. this in reference this problem. not know how proceed. pointers anyone? thanks check out page. describes several methods this. http://www.personal.kent.edu/~rmuhamma/compgeometry/mycg/cg-applets/center/centercli.htm in case link above ever dies, here's relevant part describes straight-forward method: an o(n2)-time algorithm draw circle @ center, c, such points of given set lie within circle. clearly, circle can made smaller (or else have solution). make circle smaller finding point farthest center of circler, , drawing new circle same center , passing through point a. these 2 steps produce smaller enclosing circle. reason new circle smaller new circle still contains points of given set, except passes through farthest point, x, rather enclosing it. if circle passes through 2 or more points, proceed step 4. otherwise, make circle smaller moving cen...

mysql - How to calculate date using interval from table -

i have table start_date , end_date , interval. update end_date value of start_date , interval. create table date_test ( start_date date, end_date date, date_interval varchar(45) ); the values using date_interval - interval 1 week , + interval 1 month . i like: update date_test set end_date = date( concat( start_date, " ", date_interval)); but warning: 1292 truncated incorrect date value: '2012-01-01 - interval 1 week' how can force date evaluated before updating? jonathan leffler said : nearly; there's crucial difference between manual page , question, though. manual discusses date_add(date_value, interval '1' day) etc, whereas question having 'string' value second parameter. fear question need function convert string interval type. there doesn't appear 'to_interval' function in mysql. here function take date first parameter , string interval second parameter. simply...

C# form from DLL loaded by native C++ -

this question arising thread: native c++ use c# dll via proxy c++ managed dll in nutshell, i'm loading (my) c# extension native process via dll. extension needs show form user can control it. i'm using standard .net forms, no 3rd party librarys or anything, , form not showing up. worse yet, hangs target process. it's not using cpu, feeling waiting function return, never does. also of interest "initialize method" message box pops up, not "test" message box. i've tested can think of (stathread, threads, disablethreadlibrarycalls, plus different code locations), every way sunday. i'm inclined think it's obscure detail of win32 interop, can't find seem cause these symptoms. can 1 of experts take @ code , point out issue is? /// <summary> /// provides entry points native code /// </summary> internal static class unmanagedexports { [unmanagedfunctionpointer(system.runtime.interopservices.callingconvention.stdcall)] ...

http status code 404 - Is there a way of getting 404 error page set up on the app engine? -

i have set website , want set 404 error page. there way of doing can't seem access .htaccess file? thanks in advance, scott python? https://developers.google.com/appengine/docs/python/config/appconfig#custom_error_responses java? https://developers.google.com/appengine/docs/java/config/appconfig#custom_error_responses see google app engine , 404 error

Calling back to a main file from a dofile in lua -

say have 2 files: one called mainfile.lua: function altdofile(name) dofile(debug.getinfo(1).source:sub(debug.getinfo(1).source:find(".*\\")):sub(2)..name) end altdofile("libs/caller.lua") function callback() print "called back" end docallback() the other called caller.lua, located in libs folder: function docallback() print "performing call back" _g["callback"]() end the output of running first file then: "performing call back" then nothing more, i'm missing line! why callback never getting executed? intended behavior, , how around it? the fact function getting called string important, can't changed. update: have tested further, , _g["callback"] resolve function (type()) still not called why not use dofile ? it seems purpose of altdofile replace running script's filename script want call thereby creating absolute path. in case path caller.lua relati...

Can I target older linux with newer gcc/clang? C++ -

right compile c++ software on old version of linux (sled 10) using provided gcc , can run on newer versions have newer glibc. problem is, old gcc doesn't support c++11 , i'd use new features. now have ideas, i'm sure others have same need. what's worked you? ideas: build on newer system, static link newer glibc. (not possible, right?) build on newer system, compile , link against older glibc. build on older system using updated gcc, link against older glibc. build on newer system, dynamic link newer glibc, set rpath , provide our glibc installer. as bonus, software support plugins , has sdk. i'd prefer customers compile against libraries without huge hassle. thanks in advance. ideas welcome, proven solutions preferred. build newer gcc. either install new compiler on old machine or comile on new machine , install necessary dynamic libraries on old machine. note multiple versions of libc (and libstdc++) supported on single machine since ...

i am not able to find btn_default_pressed in android 4.1 Api -

Image
i not able find btn_default_pressed in android 4.1 api. can tell me situated in android api. you can find under path android sdk-->platforms-->android-16-->data-->res-->drawable-mdpi--> btn_default_pressed.9

jQuery-Ajax autoComplete for Spring MVC not responding -

i trying use autocomplete of ajax in spring mvc application. had refered this . there issues in it. please guide me.. my script like.. <script> $(function() { $( "#bname" ).autocomplete({ source: function( request, response ) { $.ajax({ url: "getbatchnames.jav", datatype: "json", data: { term: request.term }, success: function( data ) { response( $.map( data.batchnamelist, function( item ) { return { label: item.pinmasterbatchname, value: item.pinmasterbatchname }; })); } }); }, minlength: 1, open: function() { $( ).removeclass( "ui-corner-all" ).addclass( "ui-corner-top...

Using custom fonts with css font-face, different on different browsers -

Image
let me give examples: firefox 13: chrome (latest): as can see, in firefox font appears smoother, , in chrome choppier. i'm curious why happening , steps can take out experience users. i'm using .otf font: helveticaneueltpro-ltcn.otf and using following css rules apply custom font: @font-face { font-family: "helvetica neue ltpro"; src: url("/public/assets/fonts/helveticaneueltpro-ltcn.otf"); } { color: #665548; display: block; font-family: "helvetica neue ltpro"; font-size: 15px; padding: 17px; } what recommend use out font differences? or better yet, what's practice way use "web safe" fonts? such thing exist? unfortunately can't take font, convert , have work in browsers. i'd love if can't. your best bet getting results use font delivery service such typekit or fontdeck provide fonts have been designed delivery across browsers...

objective c - iPhone Saving Images -

i have custom cell thumbnail image, user can select photo albums. know saving images core data result in poor performance, , should use file system. anyone recommend tutorials on this. should store in core data, if not storing image there. i storing larger image well, not thumbnail. uiimage*image = [uiimage imagenamed:@"the image wish save.jpg"]; //build path image on filesystem nsarray *dirpath = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *docsdir = [dirpath objectatindex:0]; nsstring* photoname = @"imagename.jpg"; nsstring *photopath = [docsdir stringbyappendingpathcomponent:photoname]; //get imagedata uiimage float imagecompression = 0.5; nsdata *imagedata = uiimagejpegrepresentation(image, imagecompression); //save image if(![imagedata writetofile:path atomically:yes]){ return false; } //store imagepath model photomodal.filepathimage = photopath; tips: avoid duplicat...

derived types - Why explicit derivation of Show/Read in Haskell? -

we can't read somevalue :: somedatatype or show somevalue every type because deriving (show, read) has written in data declarations. there case, other mistake, don't want our type serializable? why show separated read? there case, other mistake, want show data , not read it? if not, why not have single data type serializable ? just now, i'm using the key datatype of gloss library derives show , not read , don't understand. it's shame because wanted put configuration of controls in file , read it, player can change controls , have own configuration. had wrappers key, specialkey , mousebutton, not big deal useless. data key' = char' char | specialkey' specialkey | mousebutton' mousebutton deriving (eq, ord, show, read) convertkey x = case x of char' c -> char c specialkey' sk -> specialkey sk mousebutton' mb -> mousebutton mb why show separate read i don't know why originally, feel shou...

debugging - Debug iOS Safari html layout on Windows -

my asp.net mvc web site markup looks "wrong" in ios (both ipad , iphone). in desktop safari chrome, ie, etc. use , embedded developer tools in browser locate problems. is there way debug ios safari (via emulator) windows. have mac xcode @ hand, if provides ways facilitate process. on mac can open ios simulator (previously iphone simulator). if have xcode have simulator. open simulator, open safari , navigate page there, in normal browser. since mobile safari doesn't have capable html/css inspector firebug lite might work.

Having problems pinning Eclipse Juno/Luna/Mars shortcut to windows 7 taskbar -

i can't seem pin shortcut juno. i've never had problem earlier versions of eclipse. i've tried approach how make eclipse behave in windows 7 taskbar? didn't me. what happen when run eclipse.exe new shiny juno icon shown in taskbar, when it's done loading , choose workspace icon switches "java ee ide"-icon , pinning icon doesn't work. anyone experience same problem? i having same problem, new eclipse juno icon @ first , old eclipse ide ee icon in windows taskbar. did search png files in eclipse plugin folder , there try identify new icons , old ones. i found old ones coming eclipse-juno\plugins\org.eclipse.epp.package.jee_1.5.0.20120131-1544 on computer , new ones located in eclipse-juno\plugins\org.eclipse.platform_4.2.0.v201206081400. in epp jee folder created backup javaee-ide_x16, _x32 , _48 png files , copied org.eclipse.platform folder icons eclipse_16, _32 , _48 png files epp jee folder , renamed them javaee-ide_x16, _x32 ...