Posts

javascript - Disable Browser console -

i'm writing online game uses large amount of javascript, , cheating really easy if start fiddling variables in console or, worse still, checking elements of dom see hidden units are, etc. right now, detect when console opened , rewrite entire <body> element contain message explaining have close console , refresh page carry on playing. is there reliable way of closing console again, or disabling completely? a cheater can write javascript address bar; matter, host browser control within winforms program , modify on page without ever opening console. write nice little cheating app convenient buttons , friendly ui , distribute cheater friends. have not trust input user. run important stuff on server , allow client send ajax requests. otherwise cheating inevitable.

mysql - Unintended behavior: Subtraction between null values results in '0' -

Image
when either 1 of field null , want returned value null well. have tried reversing logic: is not null . still same results. mysql code: (case when ((`creative_stg_sample_tracking_raw`.`total_samples_received` not null) , (`creative_stg_sample_tracking_raw`.`total_samples_forecasted` not null)) (cast(`creative_stg_sample_tracking_raw`.`total_samples_received` signed) - cast(`creative_stg_sample_tracking_raw`.`total_samples_forecasted` signed)) else null end) `received_forecasted_dif` screenshot: your code should working, don't need case . whenever 1 of values null , expression should null : (cast(`creative_stg_sample_tracking_raw`.`total_samples_received` signed) - cast(`creative_stg_sample_tracking_raw`.`total_samples_forecasted` signed)) ) `received_forecasted_dif` i wonder if problem value 'null' rather null ...

c# - Return value of math.sqrt -

i have been try draw function of y^2=4*a*x have run problem. when use math.sqrt function find square root of value has 2 answer +or- positive value. i.e if found sqrt of 4 return +2 instead of + or -2. any appreciated. you can write own method return both values: public static ienumerable<double> sqrt(double d) { var result = math.sqrt(d); yield return result; yield return -result; }

python - Get output numbers to line up in columns? -

i'm making little program display primes. code (below) produces correct answer, i'm having trouble getting output "nice". import math n = int(input('list primes to: ')) maxdigits = math.ceil(math.log10(n)) #equal spacing, lesser digit stuff in range(3,n,2): d in range(2,int(math.sqrt(i))): if i%d==0: break else : print(str(i),end=' '*(maxdigits-len(str(i)))) the idea have many columns possible fit onto output screen, based on maximum number of digits prime have. right when run program displays numbers in long line, without newlines. results output looking this: it's ugly! burns eyes! http://img194.imageshack.us/img194/5522/2eyd.png which...isn't going for. if weren't fact numbers wrap on lines, , knew go next line if there isn't enough space, work fine. how can rid of annoying wrapping in program? more elegant (i.e. please don't tell me have count terminal width , divide maxdigits) bet...

.htaccess - Redirect all to index.php htaccess -

my apologies 10000000th question on topic, can't work way want it. i'm writing simple php mvc'ish framework. want framework able installed in directory. what php script : grabs request uri , breaks off segments. making segment 1 controller , segment 2 action. goes fine when this: http://www.domain.com/mvc/module/test/ it go specific module controller , method. have default controller, home controller, in folder home. now when acces folder directly http://www.domain.com/mvc/home/ display 403 forbidden, because folder exist, instead should go http://www.domain.com/mvc/index.php if have installed framework in different folder, lets folder framework has redirect http://www.domain.com/framework/index.php i redirect every folder , php file index.php, leaving else way is. my first problem encountered never redirects right folder, domain root folder. this tried : rewriteengine on rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f re...

java - Clicking on a ListView -

i have listview header , footer. added 2 items class of own extending arrayadapter class. in extended class, have overridden getview function because want view s not textview s appear in listview . on listview , have set onclicklistener . the problem onclicklistener started when click either on header or on footer, never when click on items. of course, view returned getview set clickable. what missing? do want different when each list element clicked? if so, should programmatically set onclicklistener each of 2 elements added. can post code?

MySQL max value for each condition -

i'd select max value of column specific type of data in table. for simplified example, let's have game girl , boy players. want able retrieve highest scores gender = girl , gender = boy single query. any way this? example 2 queries, data in app lot more complicated. thanks :) your example develop in simple way: select gender, max(score) players group gender i suppose have table players, store score , gender. if have other more complex situation, yuo must write here , can analyze case.