Posts

sql - mysql query to three tables, want to use JOIN instead subquery -

i want use join instead subquery find trade id not exist on trade_log filtered ip , current date mysql syntax below. select plug.id a, plug.url b, trade.id c plug, trade trade.id = plug.trade_id , trade.id not in (select trade_log.trade_id trade_log trade_log.ip = '".$ip."' , trade_log.log_date = curdate()) , trade.status = 1 , plug.status = 1 order plug.weight desc limit 1 please me... use: select p.id a, p.url b, t.id c plug p join trade t on t.id = p.trade_id , t.status = 1 left join trade_log tl on tl.trade_id = t.id , tl.ip = mysql_real_escape_string($ip) , tl.log_date = curdate() p.status = 1 , tl.ip null order p.weight desc limit 1

Google App Engine (Python)- Strange behaviour of REMOTE_ADDR -

in order make registration process on website easy, allow users enter email address send verification code or alternatively can solve captcha. the problem in order prevent robots registering accounts (with fake emails) limit number of registrations allowed per ip address , if limit exceeded trigger warning in logs. however ... seems happening using os.environ['remote_addr'] check remote address -- seems triggering warnings on addresses owned google (66.249.65.xxx). possible happening after change version (but not confirmed). know how/why might happening? shouldn't remote_addr return address of client computer (and in cases this)? i curious if there behind scenes re-directions going on, , if normal event or if happens when new version installed (perhaps when new version installed original server proxies user new server, therefore creating illusion ip address internal ip?) i believe have figured out reason seeing many warnings google server ip addresses. se...

increment - increase number when I press arrow key on keyboard with javascript -

i have textbox has numeric value. want keep increasing numeric value while im pressing , holding of arrow keys. know how if pressing 1 time. increased 1 only. if want keep increasing value while i'm holding arrow keys. how that? thanks there's small jquery plugin doing this: https://github.com/nakupanda/number-updown usages: $('#simplest').updown(); $('#step').updown({ step: 10, shiftstep: 100 }); $('#minmax').updown({ min: -10, max: 10 }); $('#minmaxcircle').updown({ min: -10, max: 10, circle: true }); view live demo here: http://jsfiddle.net/xctah/embedded/result/ keyboard , mousewheel events supporte

python - Updating a graphs coordinates in matplotlib -

i have below code plot sphere, it's proportions defined prop , i'd when button pressed prop 's value changes 5 , graph adjusted accordingly. how go this? i know tkinter has .configure() , allows 1 adjust widget settings. i'm looking similar can reconfigure plot. #!/usr/bin/env python import matplotlib matplotlib.use('tkagg') mpl_toolkits.mplot3d import axes3d,axes3d import matplotlib.pyplot plt matplotlib import cm import numpy np numpy import arange, sin, pi matplotlib.backends.backend_tkagg import figurecanvastkagg, navigationtoolbar2tkagg matplotlib.figure import figure matplotlib.ticker import linearlocator, fixedlocator, formatstrformatter import tkinter import sys class e(tkinter.tk): def __init__(self,parent): tkinter.tk.__init__(self,parent) self.parent = parent self.protocol("wm_delete_window", self.dest) self.main() def main(self): self.fig = plt.figure() self.fig = plt.f...

Entity Framework Code First Doesn't Generate Database -

i created db context class , added connection string in web.config file instructed in scott guthrie's code first development entity framework 4 . running test method. received several database errors running tests, when cleaned classes test succeeded, still had no database in app_data folder. i added database.createifnotexists() dbcontext constructor, still no sdf file. know doing wrong? for database automatically created, connection string name has named dbcontext subclass name (with namespace). eg. db class this: namespace mynamespace { public class foodb : dbcontext { public dbset<xxx> abc{ get; set; } } } your connection string should so: <connectionstrings> <add name="mynamespace.foodb" connectionstring="data source=|datadirectory|mynamespace.foodb.sdf" providername="system.data.sqlserverce.4.0"/> </connectionstrings>

accessing a backgrounded applications stdin/stdout with php -

i want php execute unix application in background, , have access stdin/stdout similar how subprocess can in python ...is possible? if how? you can exectute external program http://php.net/manual/en/function.exec.php you can execture apart of php's cli interface 3 "streams" can interact in more or less same way file resource returned fopen(). streams identified strings: php://stdin (read) php://stdout (write) php://stderr (write) with php 4.3.0+ cli binary, these 3 streams automatically available, identified constants stdin, stdout , stderr respectively. here's how can use stdout fix above script behaves correctly on windows: <?php $i = 0; while ( $i < 10 ) { // write output fwrite(stdout, $i."\n"); sleep(1); $i++; } ?> http://articles.sitepoint.com/article/php-command-line-1 pk

temporary files vs malloc (in C) -

i have program generates variable amount of data has store use later. when should choose use mallod+realloc , when should choose use temporary files? use temporary files if size of data larger virtual address space size of target system (2-3 gb on 32-bit hosts) or if it's @ least big enough put serious resource strain on system. otherwise use malloc . if go route of temporary files, use tmpfile function create them, since on systems never have names in filesystem , have no chance of getting left around if program terminates abnormally. people not temp file cruft microsoft office products tend leave on place. ;-)