Posts

Showing posts from May, 2015

Frame-rate not constant android game -

at university last spring studied android , last assignment develop game. not give details game used class extends surfaceview gamepanel , put game-loop in background-thread. game took 1 month hard work finish outcome - launched on android market , have more , more downloads. there 1 rather big drawback , follows here: to highest rate in assignment 1 had make game frame-rate must constant. , because got highest degree , teachers satisfied source code thought there no bugfix. - thing frame-rate not constant. , more strange: graphical objects moves across screen - moves slower faster cpu is. i have 3 phones of different models shows 3 different speeds: samsung galaxy mini (processor clock speed 1 ghz) here objects move fast samsung galaxy s3 (processor clock speed 1.8 ghz) here objects move @ medium speed samsung galaxy s4 (processor clock speed 2.3 ghz) here objects move slow so briefly - more powerful smartphone in context of processor slower graphical objects move on s

javascript - JS - multiple eventlisteners and dynamic arguments in one line of code -

i'm trying head around adding multiple eventlisteners dynamic arguments in 1 line of code. more specific want input[name='txtname'] call function when blur or keyup detected. want both events call same function "e" main argument (e includes element fires event). how have be: $("input[name='txtname']").blur.keyup.callthisfunctionwitharguments(e,20,40); this code have @ moment, think can shorter: $("input[name='txtname']").blur(function(e){callotherfunction(e,20,40)}); $("input[name='txtname']").keyup(function(e){callotherfunction(e,20,40)}); thanks in advance it may helpful you. $("input[name='txtname']").bind('blur keyup', function(e){ callotherfunction(e,20,40); });

php - Hide Fatal Error in Wordpress -

i need hiding fatal errors wordpress site display. i tried using following in wp-config.php didn't work: error_reporting(0); @ini_set('display_errors', 0); i still see fatal error being displayed. i have in wp-config.php define('wp_debug', false); currently have error_log in wordpress root. want know errors are, don't want them displayed end users, because expose cp username. try inserting in index.php error_reporting(0); ini_set('display_errors', 0); or in .htaccess # supress php errors php_flag display_startup_errors off php_flag display_errors off php_flag html_errors off php_value docref_root 0 php_value docref_ext 0 or fix them :)

html - no flash content Scale in projector screen -

i have flash animation screen dimension of 1024px 768px. flash having vector graphics. want fit animation in full-screen when publish exe. able fscommand. getting issue when run exe file flash content doesn't scale according screen. shows white area around animation content. is there possibility can make flash content area fit full-screen when publish exe. thanks. stage.scalemode = stagescalemode.exact_fit; also see other scaling options: http://help.adobe.com/en_us/flashplatform/reference/actionscript/3/flash/display/stagescalemode.html

regex - Equation Expansion -

i've requirement i've simplify equation. i've input like, a + b *((c+d)(e+f))+x and i've simplify equation a + bce + bcf + bde + bdf + x make note that, there no numerical values assigned. i've simplify string equation , result in form of equation variables shown above. currently, made stack kind of structure keep pushing in every character until encounter "+". once do, dump variables bottom top , remove elements stack until previous opening bracket ( on stack. until closing bracket @ remove until opening bracket previous 1 got closed. however, trouble arises when i've (a+b)(e+f) . unable come logic that. clueless on how i'll handling redundant brackets, ((a+b)) can on issue?

php - logics extracting right dates from mysql -

a little problem dates management in mysql. have table of event dates called event_dates : id, date (type date), fk_event and table called event (id, event_name, event_body, status) i check if now() minor smallest date, greater greatest date , if smallest the first 2 cases ok, how can tell mysql third option? means " if now()>smallest && now()<greatest select next date bigger today ". how i? sure easy accomplish, honestly, cannot figure out after 3 hours of searching , trying. all. could you? or maybe misunderstood problem?? select if( now() < (select min(date) event_dates) , now() > (select max(date) event_dates), (select date event_dates date > now() order date asc limit 1), '-1' );

c - Convert pointer address to char array and make it little-endian -

in c, if have a: char *ptr; and if, let's say, ptr points address 0xbfc70753 , how can convert array of char end array of char addr contain: char addr[4] = "\x53\x07\xc7\xbf" that is, convert address pointed @ ptr array of char , make little-endian. (kali linux, 32 bit, intel) if on little-endian machine, nice way it: void foo(uint32_t* adr, uint32_t value){*adr = value;} int main(int argc, char** argc) { char *ptr = ... char adr[4]; foo((uint32_t*)adr,(uint32_t)ptr); } the idea 32-bit unsigned integers in little-endian, when copy them char array, each byte goes place want.

java - Primefaces updates -

hello i'am having problems updates, have composite component nested in few components , want update of them, proper way ? second can update div? code example: <div id="outer"> <p:commandbutton id="button"/> <div id="inner"> <h:form id="form"> <mycomponents:test whattoupdate="form panel button outer label">//here problem </h:form> </div> </div> <div id="outer2"> <h:form id="form"> <p:panelgroup id="panel"> <p:label id="label" value="value"/> </p:panelgroup> </h:form> </div> instead of divs use p:outputpanel : <p:outputpanel id="outer"> <p:commandbutton id="button" update="inner"/> <p:outputpanel id="inner"> <h:form id=&quo

javascript - Ajax error in module: the object's state must be OPENED -

i trying add ajax method module without using jquery first time. keep getting following error on method .jax() says uncaught invalidstateerror: failed execute 'send' on 'xmlhttprequest': object's state must opened. i not sure how resolve that. here's module , simple html. var test = (function (el) { function innertest () { this.el = el; //capital letters indicate constant should not change. this.para = 'p' this.init(); }; innertest.prototype.init = function () { .createchildren() .runit() .jax(); }; innertest.prototype.createchildren = function () { this.para = this.el.queryselectorall(this.para); return this; }; innertest.prototype.runit = function () { var len = this.para.length; (var = 0, item; item = this.para[i]; i++) { //test if browser supports classlist method else use classname add class. if (item.classlist) { item.clas

javascript - Extending dojo after build or run multiple instances -

i have webapp written in dojo , need start using arcgis javascript api , problem writted in dojo. is possible run multiple instances of dojo on same page (ie. 1 app , 1 api) or incorporate custom dijits arcgis api (although can built version)? if how? i read similar dojo tutorial. i never tried looks fit need. http://dojotoolkit.org/documentation/tutorials/1.9/modules_advanced/ reading content under title: "using portable modules" tell possible load different version of dojo (which means more 1) in same page.

html - Retina bug ? Containing div does not expand 1000px width div -

i release webpage. thought, why not see how works on ipad retina. page did not good. problem can reproduced visiting link ipad retina http://www.banksalg.no/retinabug.php if @ border on right side, can see stops around 20-30 px right side of screen. green color in border body background color. if make div s smaller 1000px, example 900px acts should. you can see error on ipad retina. error not visible using "how website looks on retina screen" application/emulator. for me seems ipad cannot handle 1000px width. should when resolution 2048px. @ least 1024 px width should possible. does have solution? you haven't set viewport. default, safari on ios sets logical viewport width of 980px (per the docs ). add: <meta name="viewport" content="initial-scale=1.0"> to document's head use full logical device width.

rest - How to use Curl to invoke a Temboo API? -

how can use curl invoke temboo api? want list of temboo apis. below curl example given on temboo rest api webpage. i'm not sure how change correct access. curl -k --basic -u user@temboo.com:test1234 --header "accept: application/xml" --header "content-type: application/xml" --header "x-temboo-domain: /myorg/master" https://myorg.temboolive.com:443/temboo-api/1.0/choreos changes: change user@temboo.com:test1234 email address , password on file @ temboo. e.g. toto@totomail.com:totopassword change instances of myorg temboo account name. e.g. toto. curl -k --basic -u toto@totomail.com:totopassword --header "accept: application/xml" --header "content-type: application/xml" --header "x-temboo-domain: /toto/master" https://toto.temboolive.com:443/temboo-api/1.0/choreos

jquery - How to use .promise( ) on a .on( ) event listener? -

i have .on() listener 'fetch' event. there easy way can fire event when finishes? this.on('fetch', function() { log('fetch event started!!'); }); // fetch event ended??? i have been playing around .promise() not getting results. update - here code tapping fetch event collection can show/hide loading icons , other work. var tweetlist = backbone.collection.extend({ model: tweetmodel, // used collection.sort() comparator: function (item) { return item.get("createddate"); }, initialize: function(models, options) { this.on('fetch', function() { console.log('fetch event started!!'); }); }, fetch: function(options) { this.trigger('fetch', this, options); return backbone.collection.prototype.fetch.call(this

SQLite error: java.lang.IllegalArgumentException: column '_id' does not exist -

help me please, deal mistake. this logcat: 01-31 15:20:34.768: w/dalvikvm(2166): threadid=1: thread exiting uncaught exception (group=0x40a13300) 01-31 15:20:34.878: e/androidruntime(2166): fatal exception: main 01-31 15:20:34.878: e/androidruntime(2166): java.lang.illegalargumentexception: column '_id' not exist 01-31 15:20:34.878: e/androidruntime(2166): @ android.database.abstractcursor.getcolumnindexorthrow(abstractcursor.java:302) 01-31 15:20:34.878: e/androidruntime(2166): @ android.widget.cursoradapter.swapcursor(cursoradapter.java:338) 01-31 15:20:34.878: e/androidruntime(2166): @ android.widget.simplecursoradapter.swapcursor(simplecursoradapter.java:346) 01-31 15:20:34.878: e/androidruntime(2166): @ ru.zloyel.manager_sutochnoy_arendy_1.kvartitymain.onloadfinished(kvartitymain.java:178) 01-31 15:20:34.878: e/androidruntime(2166): @ ru.zloyel.manager_sutochnoy_arendy_1.kvartitymain.onloadfinished(kvartitymain.jav

Displaying javafx 2 linechart values on hover -

Image
i have been using this example project, , works nice. my question: possible offset hovered node such not overlay underlying data point. example centers hovered node right on "normal" node. kind of gets in way on chart lot of data points. a simple solution set custom translation displayed label . following code extracted example . private label createdatathresholdlabel(int priorvalue, int value) { final label label = new label(value + ""); label.settranslatey(-25); //move label 25 pixels label.getstyleclass().addall("default-color0", "chart-line-symbol", "chart-series-line"); label.setstyle("-fx-font-size: 20; -fx-font-weight: bold;"); if (priorvalue == 0) { label.settextfill(color.darkgray); } else if (value > priorvalue) { label.settextfill(color.forestgreen); } else {

c++ - Doxygen Doesn't expand macros -

this seems trivial task , yet not able doxygen expand macro. i've used version 1.6.3, 1.7.4, 1.7.6 , 1.8.6. i've done plenty of searches on google, still failed miserably. i've got c++ file contains following lines (copied off doxygen documentation): #define const_string const char * static const_string version = "2.xx"; i've followed documentation , set: enable_preprocessing = yes macro_expansion = yes then added following: expand_only_predef = yes expand_as_defined = const_string then skip_function_macros = yes (previously no) all got code generation was: 1 #define const_string const char * 2 static const_string version = "2.xx"; what have done wrong? advice appreciated. what makes think have done wrong? you should seeing version in "variables" section of documentation page source file. if you've enabled source code output, variable version should hyperlink variable document

How to use limit correctly in Codeigniter Framework PHP -

in project want show 3 rows, use limit('3') , when result greater 3, content not showing. if limit increase 3 5 or 6 items again start show. how fixed problem, if item count more, shows 3? here database code, written model : public function select_all_contenta() { $this->db->select('*'); $this->db->from('content'); $this->db->order_by('date_add','desc'); $this->db->limit('3'); $query_result=$this->db->get(); $allcontent_infoa=$query_result->result(); return $allcontent_infoa; } public function select_all_contenta() { $this->db->from('content'); $this->db->order_by('date_add','desc'); $this->db->limit('3'); $query_result = $this->db->get(); $allcontent_infoa = $query_result->result_array(); return $allcontent_infoa; }

javascript - How can I find out the user's city, age and gender? -

i have google analytics code on page, , somehow finds out user's gender, age , location. can access data when user opens page, , show "hey, that's google knows you: age, gender , city"? i use analytics.js , in case it's important. probably analytics.js has functions in , can access using javascript? or data found out other way? google doesn't provide data individual users. it's available on aggregate basis in analytics reports. apply thresholds reports individuals can't identified.

c# - Populate select box from database using MVC -

i creating website using asp.net , mvc. need populate select box values database , wondering how go doing this? there many different ways it, do. in service class, db select & return selectlist object public selectlist getasselectlist() { var depts = d in getall() select new { id = d.id, name = d.name }; return new selectlist(depts, "id", "name"); } then in model, assign selectlist property: model.suppliers = _supplierservice.getasselectlist(); return view(model); and view: @html.dropdownlistfor(model => model.deliverystoreid, model.deliverystores)

java - What are the benefits of HQL? -

the benefits of orm can map database tables java objects. if use hql write custom statements what's point? may write normal sql queries , use resultsets? well, because impossible (or hard) write queries using other alternatives. need fallback hql alternative. hql has, disadvantage, fact write strings it. highly recommended other strategies. but, sometimes, fastest way implement it. i read post, extensively discussed hql already: jpa , hibernate - criteria vs. jpql or hql

c# - Intermittent application hang on startup in Windows Store App -

i developing windows store application. currently, getting intermittent hangs described in this blog post . issue appears not enough space given remainder-defined column widths , textblock s attempting format (possibly due ellipsis processing). app tends hang indefinitely when happens. the question have less related how solve issue (as seems described in blog post), instead how find issues. have 1 regularly (approximately 1 in 5 or ten start-ups) on hub page, i've been looking through there (as it's notable instance of issue), it's true heisenbug in never seems happen when debugging (or when it). so, how find offending code? there pattern need ( columnwidth="*" ?). there simpler way solve this, such changing base style remove 1 of possibly offending properties listed in blog post? it seems possible being caused issue, seems likely/plausible of right (as hubs have similar situation being described there). also, there way track when happens in wild? msft

How to assing values to 2 dimensional array with data from database in asp.net using c#? -

suppose sql database studentinfo , table name registration id----------name---------------email---------------------------phoneno 1 munasunghe amilamunasinghe@yahoo.com 0717069425 2 liyanarachchi hareshliya6@gmail.com 0756706352 protected void page_load(object sender, eventargs e) { string query = "select id, name, email, phoneno registration"; sqlcommand cmd1 = new sqlcommand(query); datatable dt1 = getdata(cmd1); int rowcount = dt1.rows.count; /* want assing dt1 datatable data 2 dimensional array*/ } the function getdata used data database. private datatable getdata(sqlcommand cmd) { datatable dt = new datatable(); string strconnstring = system.configuration.configurationmanager.connectionstrings["constring"].connectionstring; sqlconnection con = new sqlconnection(strconnstring); sqldataadapter sda = new sqldataadapter(); cmd.comma

Encrypting in PHP (mcrypt), Decrypting in Ruby (OpenSSL::Cipher) -

i'm working on cross language project wrapping ruby/sinatra api in php consumed team. none of information exposed api sensitive, prefer not accessible casual observer guessing url. private function generatesliceidtoken($key){ $currentepoch = time(); $ivsize = mcrypt_get_iv_size(mcrypt_rijndael_128, mcrypt_mode_cbc); $iv = mcrypt_create_iv($ivsize, mcrypt_rand); $encryptedbytes = mcrypt_encrypt( mcrypt_rijndael_128, $key, $currentepoch.**passcode**, mcrypt_mode_cbc, $iv ); $ivandencryptedbytes = $iv . $encryptedbytes; return urlencode(urlencode(base64_encode($ivandencryptedbytes))); the code above encrypts password , time stamp using mcrypt's rijndael implementation , encodes send off ruby api if identifier.validate_token base64.decode64(uri.unescape( uri.unescape(params[:token]))) sinatra grabs , decodes it def validate_token(token) cipher = openssl::cipher::aes.new(128, 'cbc') cipher.dec

android - Adding dynamic content in Linear Layout -

i'm working on android app, when user taps on icon, layout defined (for now) in main layout slides information. the problem have icons of different types, when 1 clicks on 1 type of icon or another, information in pop should different (there different objects different structures behind icons). what possibilities have? programmatic way not seem elegant enough. there templating frameworks in android? please provide examples, too. you sub-class icons (that means types shown each icon), having each 1 it's own fragment sub-class, can use different layout on fragment. here more info fragments

c# - Alternative to Google Drive SDK with less dependencies -

i'd use google drive api in c# desktop application. however, i've found official google sdk on nuget have more dependencies i'm comfortable (adding vs2010 project adds 10 additional nuget packages). fear these dependencies clash other dependencies solution grows. is there alternative approach utilizes less dependencies? can utilize different oauth 2.0 library or must use google's oauth sdk? there special google's oauth 2.0 implementation hinder ability use alternative oauth 2.0 library? is there alternative approach utilizes less dependencies? you write own api using httpclient combined drive api . api uses simple get/post/put/delete/patch http methods change files in google drive . can utilize different oauth 2.0 library or must use google's oauth sdk? depends. if wrote own, can use (or write) oauth client. http methods must include oauth information in requests, writing own gives type of access. if looking actual produc

forms - Dispose all elements on application C# -

i'm working on c# project load images , stuff them. there's button closes current project user working on. is there way dispose elements @ once without doing application.restart();? should go element element , disposing/setting null etc? thanks! there 2 types of resources need think of 1.) "managed" stuff basic variables, ui elements etc. these disposed expected when close form , don't have pay attention them. 2.) resources need disposed, database access objects, stream readers, timers, etc etc. if operations this, make sure dispose them before closing form, or else may , of time continue working in background , app won't close properly. learn how dispose objects in c#, instance http://www.codeproject.com/articles/15360/implementing-idisposable-and-the-dispose-pattern-p http://lostechies.com/chrispatterson/2012/11/29/idisposable-done-right/

amazon s3 - Rails AWS-SDK: Set Expiration Date for Objects -

in rails app, allow users upload images directly s3, creates temporary file gets automatically deleted after image record saved in database. instead of automatically deleting image after record saved, i'd set expiration date file on s3 automatically gets deleted after period (say 24 hours). i've seen documentation on how set expiration date on bucket ( http://docs.aws.amazon.com/awsrubysdk/latest/aws/s3/bucketlifecycleconfiguration.html ), want folder within bucket have files automatically removed. does have suggestions how it? s3 = aws::s3.new(:access_key_id => env['aws_access_key_id'], :secret_access_key => env['aws_access_key']) foldername = @image.s3_filepath.split("/")[5] folder_path = 'uploads/' + foldername s3.buckets[env['aws_bucket']].objects.with_prefix(folder_path).each( #set expiration date header here) you set lifecycle configuration on bucket itself, not each individual object. using rest api yo

php - Getting charset of page and convert it -

creating preview url in post message, on fb. on post url in textarea preview url shown below. title, description, image, etc. had problem charset encoding of different pages. page in utf-8, , if preview url not in utf-8, incorrect text shown on page. needed charset of url, convert utf-8 , needed info , show on page. actually stackoverflowed )) didn't find method this. finally did this, , works nice. please check if right , shorter way it. $post_url='http://website.domain'; /// headers //////////////////////////////////////////////////////////// function get_headers_curl($url) { $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_header, true); curl_setopt($ch, curlopt_nobody, true); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_timeout, 15); $r = curl_exec($ch); return $r; } $the_header = get_headers_curl($post_url); /// check r

ios - Handle Core Data Fetching Object Which No Longer Exists -

background info: i have application accesses user's email account , fetches account data: emails, folders etc. process includes several steps, last of save or update newly fetched information core data. whole process start finish may take couple of seconds. here problem: user opens application, fetching of new or updated account data process begins. user decides delete current account fetching occurring. a call sent cancel open fetch requests current account, however, fetch requests completed , core data trying save new data. while trying access "existing" core data objects in order update them, objects deleted , crash occurs. specifically, error looks like: coredata: annotation: logically false fetch request <nsfetchrequest: 0x13ce1430> (entity: thread; predicate: (threadid == 1457719230395529203 , folder == <folder: 0xc1994c0> (entity: folder; id: 0xc2ccb20 <x-coredata://a0837e88-30eb-46e8-a9bc-d6699ec7f160/folder/p10> ; data: &

c - Inline asm with sideeffects -

i want use inline asm armv7 clang 3.4, in order write low level code accesses cpus control registers. test, wrote program reads register, conditionally fiddles bits, , writes new value. however, when @ produced machine code entire bit-fiddling has been optimized away. apparently have not used right asm constraints tell clang result of writing register depends on being written. (i used simple "volatile" modifier). how should write inline asm code clang generates correct asm? here code test.c typedef unsigned int uint32_t; // code reads , writes id_pfr1 register uint32_t read_id_pfr1() { uint32_t a; asm volatile ("mrc p15, 0, %0, c0, c1, 1" : : "r"(a) : ); return a; } void write_id_pfr1(uint32_t a) { asm volatile ("mcr p15, 0, %0, c0, c1, 1" :"=r"(a) : : ); } // regular c code modifies register uint32_t foo(uint32_t b) { uint32_t a; = read_id_pfr1(); write_id_pfr1(b); return a+b; } void bit_fid

c# - How to prevent project from generating from template? -

i creating multiproject visual studio template. created vsix package project , wizard class library. added projects assets in source.extension.vsixmanifest file of vsix project. in wizard class library added windows form, collect user inputs. need to, based on user inputs, add generated solution template additional projects. solution vstemplate file looks that: <?xml version="1.0" encoding="utf-8"?> <vstemplate version="3.0.0" type="projectgroup" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" xmlns:sdk="http://schemas.microsoft.com/developer/vstemplate-sdkextension/2010"> <templatedata> ... </templatedata> <templatecontent> <projectcollection> <solutionfolder name="app"> <projecttemplatelink projectname="$safeprojectname$.core"> core\core.vstemplate </projecttemplatelink>

mysql - PHP conversion against injection for numerical parameters -

i know ultimate way use mysqli_real_escape_string function. pretty long , numerical values use $value + 0 statement. secure enough? yes is. don't forget use "real" new version of mysqli_escape_string ;) btw, should use prepared statement mysqli: you can read more on: http://www.php.net/manual/en/mysqli.quickstart.prepared-statements.php this avoid using mysqli_real_escape_string

java - Best way to store array persistently in Android without using SQLite -

i have array in android application store when application closed , later restore when application opened again. know 1 stores larger amounts of data in android in sqlite database. have arrays i'd store. therefore know best method doing is. best means following me: good performance easy, non-complicated code able t store multi-dimensional arrays , arraylists the following possibilities i've come with: json xml metaprogramming store array in text file initialize , read using metaprogramming. it's not easy, doable in java. though of course in not exhaustive list. best way store array in java according criteria above? i know not typical q/a quenstion think have provided clear criteria , examples, doesn't violate stackoverflow "question rules" there 4 basic methods data storage in android. internal storage - private folder can write files to. can write small file there, , read back. external storage - same internal, except oth

ios - Xcode bots server continuous integration hangs on "Getting sources..." -

i setup copy of osx server , correctly configured xcode. able create bot , run few integrations failed because didn't import correct developer certificates. running integration seems stuck @ "getting sources.." while xcode showing being queued. ideas? there lot of reasons might happening , depends on version control system using. both git , svn issue might root ssl certificates. need add root certificates keychain ssl configuration. see this post details. if problem isn't ssl certificate related timeout issue fetching source repository if large. check integration logs details.

mysql - PHP for loop update database images -

i using loop validate page in php using move_uploaded_file move uploaded file + add image path database. below code. if(empty($_files) === false) { for($i=1; $i<=$items; $i++) { $allowed = array('jpg', 'jpeg', 'gif', 'png'); if (empty($_files['photo{$i}']['name']) === true) { echo '<div class="alert alert-danger">please choose file.</div>'; } else { if (in_array(strtolower(end(explode('.', $_files['photo{$i}']['name']))), $allowed) === false) { echo '<div class="alert alert-danger">[photo '.$i.'] format <strong>not</strong> acceptable. '; echo 'accepted formats: '. implode(', ', $allowed).'</div>'; } elseif($_files["photo{$i}"]['size'] > 1048576) { echo '<div class="alert-danger">[photo '.$i.'] image big. maxi

sql subselect - Sqlite query - Where In (subquery) -

goal: i'm working on windows phone app allows save birthdays. windows phone doesn't allow save more 50 reminders, i'm trying is: i want list of next 50 birthdays-days. list has distinct, because if example next 50 birthdays fall on same day, don't want create 50 reminders 1 day, want create 1 reminder 50 birthdays. this part of query create next birthday (if birthday passed, create birthday next year) case when strftime('%m-%d', bday) < strftime('%m-%d', 'now') strftime('2015-%m-%d', bday) else strftime('2014-%m-%d', bday) end bday so full query, doesn't work ...: select id, type, details, case when strftime('%m-%d', bday) < strftime('%m-%d', 'now') strftime('2015-%m-%d', bday) else strftime('2014-%m-%d', bday) end bday birthday bday in (select distinct case when strftime('%m-%d'

Add 'standard' JSON fields to serialized objects in REST API -

motivated this: google json style guide , want insert bit of custom serialization logic rest api. i'm using webapi 2 , json.net. goal wrap 'payload' of response in 'data' field of main json response, described in style guide, include apiversion field in every response, , sort of thing. of course controller actions return straight poco's, , want modify container they're sent inside of, not pocos themselves, so: { "id": "111", "apiversion": "1.0", "data": { "kind": "monkey", "name": "manny", "age": "3" }, "error": null } ...that type of thing. envision inserting little bits of standard data every response before goes on wire. what's best way accomplish this? tia. i believe can use actionfilterattribute achieve kind of behaviour. first need create class represent wrapped response (all properties s

php - PDO prepare NOT IN or <> multi language -

for few hours struggling make work. ok have 2 languages in first case in url no variable ?lang= base language , function checks language variable lang,do, if variable in url exists,and whatever value is, set global variable $lang "en" else null. got in database have column lang , need data out of it. public variable if true means need subjects pulic , in database column "visible" value 2. if not visible value 1. get public items visible don't have value "en" in row lang get public items visible if lang != null (if in row lang value "en" get items if public == false && lang == null rows got visible 2 , lang column empty get items if public == false && lang != null items if in column lang value "en". that's need. mysteriously not working. code. function get_all_subjects($public = true,$lang = null){ $db = connect_db(); $query = "select * "; $query .= "from subjects "; if($public &am

ios - Why does my NSTimer selector never fire? Is it because it's in GLKitViewController instead of UIViewController? -

at state in program, call method body: self.timestarteddisplayingtime = [nsdate date]; self.stopbutton.enabled = yes; [nstimer scheduledtimerwithtimeinterval:0.01 target:self selector:@selector(updateelapsedtime:) userinfo:nil repeats:yes]; i've verified method indeed called. however, corresponding selector's body: nstimeinterval elapsedtimedisplayingecg = [self.timestarteddisplayingecg timeintervalsincedate:[nsdate date]]; self.elapsedtimevaluelabel.text = [nsstring stringwithformat:@"%f", elapsedtimedisplayingecg]; is never called. i've put breakpoint on , it's never reached. why exactly? it's in glkitviewcontroller instead if that's relevant. your timer gets thrown away right after creating it. need retain somewhere. define property @property (strong) nstimer *mytimer; and assign timer this: self.mytimer = [nstimer scheduledtimer scheduledtimerwithtimeinterval:0.01 target:self selector:@selector(updateelapsedtime:)

jQuery Mobile Listview in Dialog won't initialize -

i dynamically creating dialog contains listview , appending body when user navigates specific data-role=page . after appending dialog body call $('#mydialog').dialog(); $('#mylist', '#mydialog').listview(); when call listview() function following error: uncaught typeerror: cannot read property 'jquery19105852627926506102' of undefined the way have been able initialize listview during pageshow event of dialog, user sees listview items without styling until listview() function complete. is there way can initialize listview inside dialog before dialog has been shown? update: same error if use `$('#mydialog').trigger('create'). dialogs treated same way pages are. when appending page/dialog dynamically dom, dont need call kind of enhancement , initialized, widgets within, prior showing them. all need append dialog <body> or $.mobile.pagecontainer , open dialog using $.mobile.changepage() . $.mobile.p

jQuery Listener for Responsive Content -

i'm building responsive site , when browser greater 500px wide, .bio content hidden, when it's on phone, shows. good thing is, works on when page loaded within dimensions. if firefox window 400px , resize window 900, bio still visible. if load page @ 900px, bio hidden, should be. how make jquery fire again when window size changes? $(function(){ if($(window).width() > 500){ $('.speakers li').hover(function(){ $(this).find('.hide').toggle(); }); }else{ $('.speakers li .bio').removeclass('hide'); } }); figured out css using media queries, suggested mackieee. what prevented me using media queries in beginning content being hidden display:none. in case, :hover not available since there's nothing hover over. opacity trick. i guess, absolute positioning, swap z-index if needed click link under transparent div. .ease {-webkit-transition:all 0.15s ease; -moz-transition:all

android - Confusion regarding number of alarms needed to be set[Solved] -

i have following data in sqllite postgresql database , showing in tablularlayout on android widget.it's timetable college students. a http://www.4shared.com/download/1w7tyicfce/random3.png i did set onclicklistener textviews individually,which means each , every subject name you're seeing clickable in app. upon clicking on subject name i.e textview ,a page shows following. a http://www.4shared.com/download/ii8dtkvjba/setalarm.png till have written code setting single alarm not multiple.hence selecting 1 checkbox only.however gonna set multiple alarms such if 1 selects 4 checkboxes 4 alarms single subject must triggering accordingly. question 1.while setting alarms each subject individually,should set 4 pendingintents 4 checkbox selected time , trigger alarms selected in checkboxes ?and should use same requestcode pendingintent.getbroadcast or should use 4 different requestcodes ?right have 1 pendingintent .when save , set alarm button clicked 1 al

java - Menu with table layout in LibGDX won't load -

i'm using table layout option menu in game. when launch screen there's black screen. see : package com.me.mygdxgame; import com.badlogic.gdx.gdx; import com.badlogic.gdx.screen; import com.badlogic.gdx.files.filehandle; import com.badlogic.gdx.graphics.gl20; import com.badlogic.gdx.scenes.scene2d.actor; import com.badlogic.gdx.scenes.scene2d.stage; import com.badlogic.gdx.scenes.scene2d.ui.checkbox; import com.badlogic.gdx.scenes.scene2d.ui.label; import com.badlogic.gdx.scenes.scene2d.ui.skin; import com.badlogic.gdx.scenes.scene2d.ui.table; import com.badlogic.gdx.scenes.scene2d.utils.changelistener; import com.badlogic.gdx.scenes.scene2d.utils.clicklistener; public class bluetoothoptionscreen implements screen{ final stage stage; skin skin; boolean hote = false; table table; public bluetoothoptionscreen() { system.out.println("option screen, commencement de l'initialisation"); this.stage = new stage(gdx.graphics.ge

Hadoop / Hive upgrade performance -

we testing hive , hadoop digging in our data , installed while hadoop 1.2.1 , hive 0.11 (was stable version) test server 4 cores , 16gb of ram. now wanted know if switching hive 0.12 , hadoop 2.2 worth trouble of upgrading server in terms of performance on queries? a query looks this: select i, day(time), count(distint value), count(*) table lateral view explode(column) tab group i, day(time); so bit of in query used couldn't find decent info on performance gain when upgrading. any insight on matter nice :) cheers since query doesn't contain "where" predicate, cannot enjoy predicate pushdown storage layer introduced in 0.12, if data in orc format. thus, although among 0.12 improvements faster plan generation , optimization count, educated guess, believe, should performance improvement not dramatic.

angularjs - Set scope to child of current scope within template in Angular -

say i've got template this: <div id="player" ng-show="player.is_visible"> <p ng-class="player.foo_class">...</p> <p ng-class="player.bar_class">...</p> <p ng-class="player.baz_class">...</p> <div> how can narrow scope inside #player this? <div id="player" ng-show="player.is_visible" ng-inner-scope="player"> <p ng-class="foo_class">...</p> <p ng-class="bar_class">...</p> <p ng-class="baz_class">...</p> <div>

ssh keys - Passwordless login to a specific directory by SSH -

i know how login without password remote host ssh. way can access folder remote host. there way give access specific folders ssh? i used ssh-keygen generate public-private key pairs , added public key ~/.ssh/authorized_keys in remote server. you want sftponly. little involved set up, have running 2 dozen sftp clients. performs chroot when user connects , prevents ssh access -- name. https://www.allthingsdigital.nl/2013/05/12/setting-up-an-sftp-only-account-with-openssh/ note can't allow user have write access in dir log into, can bind mount other directories , give them r/w access them.

Android lock screen rotation -

i know can set screen layout portrait or landscape in activity's xml tag in manifest prevent screen rotation. i have app shall run on phone , on tablet. on tablet want have landscape , on phone want have portrait mode. how can configuration? (and of course when device rotates screen shall not). for check whether tab or not, can use simple method: public boolean istablet(context context){ boolean xlarge = ((context.getresources().getconfiguration().screenlayout & configuration.screenlayout_size_mask) == 4); boolean large = ((context.getresources().getconfiguration().screenlayout & configuration.screenlayout_size_mask) == configuration.screenlayout_size_large); return (xlarge || large); } or public static boolean istablet(context context) { return (context.getresources().getconfiguration().screenlayout & configuration.screenlayout_size_mask) >= configuration.screenlayout_size_large; } both helpful you. for more

mysql - Many null values in one table vs three tables -

i have 3 tables common fields - users , guests , admins . the last 2 tables have of users fields. here's example: users id|username|password|email|city|country|phone|birthday|status guests id|city|country|phone|birthday admins id|username|password|status i'm wondering if it's better to: a)use 1 table many null values b)use 3 tables the question less "one table many null versus 3 tables" data structure. real question how other tables in data structure refer these entities. this classic situation, have "one-of" relationships , need represent them in sql. there "right" way, , have four tables: "users" (i can't think of name) encompass , have unique id referenced other tables "normal", "admins", "guests" each of have 1-0/1 relationship "users" this allows other tables refer of 3 types of users, or users in general. important maintaining proper rel

asp.net - Is it possible to do identity insert/update in SubSonic 2.0 -

unfortunately i'm stuck using undocumented/obsolete library (subsonic 2.0). i'm trying simple identity insert can't seem work. here's psuedo-code version of i'm trying do: subsonicexampleobject o = new select() .from(subsonicexampleobject.schema) .where(subsonicexampleobject.idcolumn) .isequalto(124124) .executesingle<subsonicexampleobject>(); if(o == null) { o = new subsonicexampleobject(); o.id = 124124; o.save(); } i've tried adding code above , below statement, no success: new inlinequery() .execute("set identity_insert " + subsonicexampleobject.schema + " on"); [code above] new inlinequery() .execute("set identity_insert " + subsonicexampleobject.schema + " off"); regardless of do, subsonic seems ignoring id value, , setting based on next identity value. if knows ho

algorithm - O(n log n) vs O(n) -- practical differences in time complexity -

n log n > n -- pseudo-linear relationship. if n=1 billion , log n ~ 30; so n log n 30 billion , 30 x n , order of n . wondering if time complexity difference between n log n , n significant in real life. eg: quick select on finding kth element in unsorted array o(n) using quickselect algorithm. if sort array , find kth element, o(n log n) . sort array 1 trillion elements, 60 times slower if quicksort , index it . me sounds not big difference, need opinion of experts here. the main purpose of big-o notation let estimates ones did in post, , decide if spending effort coding typically more advanced algorithm worth additional cpu cycles going buy code improvement. depending on circumstances, may different answer, when data set relatively small: if running on mobile device, , algorithm represents significant portion of execution time, cutting down use of cpu translates extending battery life if running in all-or-nothing competitive environment, such high-f

css - How can I truncate text in a div or cell as the browser resizes -

i have row consisting of icon/text/timestamp in header section of html page. want have icon , timestamp of row remain @ fixed width, , when browser resizes, want reduce size of text div (table-cell) having ellipsis appear. while can ellipsis appear fixed width, want width of text div (table-cell) 100% until browser gets smaller, want text div smaller , ellipsis appear div shrinks. i solve problem media queries, or directive resize dynamically, hoping html/css solve it. is possible? here sample: http://jsfiddle.net/em83b/ <div style="display: table; table-layout: fixed;"> <div style="display: table-cell; background: pink; min-width: 60px;"> aaa </div> <div style="display: table-cell; background: yellow; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; min-width: 300px; max-width: 600px;"> text want have truncated browser resizes </div> <div style="display:

javascript - Bootstrap 3 interactive remote modal -

i've php web application manage conversation between 2 users, recorded in mysql database. conversation handled controller php, stores messages in database, , invokes php template. in template i've modal this: <div class="modal fade" id="mymodal" tabindex="-1" role="dialog" aria-labelledby="mymodallabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <h4 class="modal-title">data review</h4> </div> <div class="modal-body"> <! -- content here --> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-di

osx - How to run Python script on terminal -

i want run python script in terminal don't know how? have saved file called gameover.py in /user/luca/documents/python. you need python installed on system. can run in terminal in correct directory: python gameover.py

python - Why file read is faster on reading again? -

size = 1<<16 def justread(file): open(file, 'rb') f: while f.read(size): pass the first time run function on 700mb file took 19 secs. when repeated reading same file again time took dropped 0.5secs. repeated many files , results similar. going on here? the operating system caches file in memory upon first read, , second time read memory instead of hard disk. of course memory faster.

php - Accessing response (output) headers in ZF2 -

Image
trying output image protected area using zf2. in action function output image data call to: readfile($path); in browser output recognized text , displayed starting jpeg markers 'ÿØÿà...bla bla bla'. i'm assuming because zend returned 'text' content type in http header. so tried change content type header php command header('content-type: image/jpeg'); when following error: warning: cannot modify header information - headers sent (output started @ /zend/module/application/src/application/controller/imagescontroller.php:84) i looked extensively , found lots of documentation this seems can like: $this->getresponse()->setheader('content-type', 'image/jpeg'); when message: fatal error: call undefined method zend\http\phpenvironment\response::setheader() in /zend/module/application/src/application/controller/imagescontroller.php on line 39 looking through response object structure don't see link between zend\ht