Search Results

Search found 26 results on 2 pages for 'pez cuckow'.

Page 1/2 | 1 2  | Next Page >

  • PHP mySQL count number of fields not empty

    - by Pez Cuckow
    I have a database of users where they can send messages to other users (up to four) and the ID of the message they sent is in their user row. e.g. Name, Email, Msg1, Msg2, Msg3, Msg4 Pez, [email protected], 1, 55, 42, 5 //Send 4 messages Steve, [email protected], 0, 0, 0, 0 //Send 0 messages Leon, [email protected], 3, 0, 3, 5 //Send 3 messages How in a MySQL query can I get the amount of those message rows that are not empty or not equal to 0, allowing me to order by that? So it would return Pez - 4 Mesasges Leon - 3 Messages Steve - 0 Messages Im my mind something like order by count(!empty(msg1)+!empty(msg2)+!empty(msg3)+!empty(msg4)) Many thanks,

    Read the article

  • Beeping Hard Disk - Seagate 250GB Momentus 5400.6

    - by Pez Cuckow
    I have been trying to repair a laptop that simply beeps instead of booting. After taking it apart I have now realised that it is the hard disk beeping. I know that may sound strange but I guarantee that is what it is! (Currently powered on it's own with a Sata Mains lead). The beeping is slightly faster than one per second there is a link to this recording. This recording was made resting the mic on the hard disk while it was sat on a table on it's own, there are no speakers anywhere near, the sound is coming from the hard disk. Does anyone know what this beep means? Is the hard drive just dead, or is it fixable and the data recoverable? Many thanks,

    Read the article

  • Server Bash Line Wrapping Over Text & In Wrong Place

    - by Pez Cuckow
    This is quite a hard problem to explain, when connecting to one of my servers using the bash shell, under any user the line wrapping is broken and has all sorts of problems. Once of which I detail in screenshots below: Other problems I experience include nano getting very confused about which line and or letter I am on, as shown by typing the same message into nano: These problems only occur when connecting as I previously mentioned to one of my servers which runs CentOs. Do you know why this is occurring and what I can do to fix it? On other servers the message works fine! Thanks for your time, Output of requested commands: Server that doesn't work properly: Working server: Could it perhaps be the custom prompt on the non working server? In .bashrc PS1='\e[1;32m\u@\h\e[m:\e[1;34m\w\e[m$ ' Commenting this out appeared to resolve the problem. Google says line wrapping errors can occur if you don't conform to these rules use the \[ escape to begin a sequence of non-printing characters, and the \] escape to signal the end of such a sequence I am not sure where this would fit in on my prompt?

    Read the article

  • CUPS causes printer to click and doesn't print

    - by Pez Cuckow
    I'm suffering a strange problem with my Cannon iP4850 when trying to use CUPS on a Raspberry Pi (this is not RPi specific, please do not vote to move it). When I plug the printer into my Laptop (OSX) or my Desktop W7 it identifies as a iP4800 and prints perfectly. So I plug it into the Pi (running debian), set it up in CUPS enable sharing and can now see the iP4800 series shared on the network. However if I print to it (using AirPrint etc...); the file gets to CUPS safely (shows in the queue) but when it tries to print the printer clicks (like a loud thunk) 3/4 times and then gives in, with a double amber flashing light. In cups it shows as job completed. Do you know why using the pi and cups would cause what appears to be a hardware fault and what I can do to fix the problem or to provide further debug info? Thanks for your time! Description: Canon iP4800 series Location: Lounge Driver: Canon PIXMA iP4800 - CUPS+Gutenprint v5.2.9 (color, 2-sided printing) Connection: usb://Canon/iP4800%20series?serial=2239B2 Note: I've tried deleting and re-adding the printer to the Laptop, Desktop and PI and the results are always the same Log for plugging in printer and printing (attempting to) something until the printer turned off again pi@pezpi /var/log $ dmesg [ 7284.176336] usb 1-1.2: new high speed USB device number 8 using dwc_otg [ 7284.279703] usb 1-1.2: New USB device found, idVendor=04a9, idProduct=10d5 [ 7284.279750] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ 7284.279771] usb 1-1.2: Product: iP4800 series [ 7284.279786] usb 1-1.2: Manufacturer: Canon [ 7284.279800] usb 1-1.2: SerialNumber: 2239B2 Setting cups to verbose: Change loglevel in cupsd.conf to debug (or debug2) pi@pezpi /var/log $ sudo vim /etc/cups/cupsd.conf pi@pezpi /var/log $ sudo /etc/init.d/cups restart [ ok ] Restarting Common Unix Printing System: cupsd. pi@pezpi /var/log $ Log from $ /var/log/cups/error_log is at http://pastebin.com/7VZMRMrG (too large to post here) The log contains - in order (deleted the log and then did the beneath) Restarting the cups server Attempting to print a test page x2 Printing from 192.168.1.90 via AirPrint Printing from 192.168.1.90 via Network Print Turning the printer off and on again

    Read the article

  • Playing iPad to iPad Wifi games over PPTP VPN

    - by Pez Cuckow
    I'm trying to use a VPN to play iPad to iPad Wifi (Local) games over the internet. Normally you open the game on both iPad's, connect to the same Wifi point and they can "see" and speak to each other. I figure using a VPN I can put them both on the same network (either both on the VPN or one on the "real" network and one on the VPN). On my router I've set up PPTP VPN with the ip range 192.168.1.2-50, where the PC's on the real local network are assigned 192.168.1.100+ When I connect one of the iPads to the VPN, using an external WiFi network (BT Openzone) I can ping it as expected (from any machine on the local network). However the iPad's cannot "see" each other and none of the Wifi-Wifi games work. I've also tried connecting both iPad's to the same VPN, with the result the same. All machines on the local network (and those on the VPN) can ping the iPad's but none of the Wifi to Wifi games work. I've set both iPads to send all trafic over the VPN and if I check their external IP's they match that of the real network. Does anyone know how to fix this? And/or what is causing it? Or what further debug information I can provide? Note: I don't feel this is iPad specific so would prefer if this isn't moved to a Apple SuperUser equivalent

    Read the article

  • Beeping Hard Disk - Seagate 250GB Momentus 5400.6

    - by Pez Cuckow
    I have been trying to repair a laptop that simply beeps instead of booting. After taking it apart I have now realised that it is the hard disk beeping. I know that sound strange but I guarantee that is what it is! (Currently powered on it's own with a Sata Mains lead). The beeping is slightly faster than one per second there is a link to a recording below: http://www.pezcuckow.com/files/BeepingHardDisk.m4a This recording was made resting the mic on the hard disk while it was sat on a table on it's own, there are no speakers anywhere near, the sound is coming from the hard disk. Does anyone know what this beep means? Is the hard drive just dead, or is it fixable and the data recoverable? Many thanks,

    Read the article

  • Symbolic Links Between User Accounts

    - by Pez Cuckow
    I have been using a cron job to duplicate a folder into another users account every day and someone suggested using symbolic links instead although I cannot get them to work. In summary user GAMER generates log files that they want to access via HTTP, however I only have a web-server in the user account SERVER, in the past I would copy the logs folder from GAMERS account into SERVER/public_html/. and then chmod the files so the server could access them. Trying to use symbolic links I set up a link from root (as only root can access both accounts) I used: ln -s /home/GAMER/game/logs/ /home/SERVER/public_html/logs However it seems that only root can use this link, I tried chmoding the link, all the files in the gamers /game/logs/*, /game/logs itself to 777 as well as changing chown and chgrp to server the files still cannot be read. When viewed from servers account my shell shows the link and where it is to hi-lighted in black with red text. Am I doing something wrong? Please enlighten me! /home/GAMER/game/ (chmod & chgrp) drwxrwxrwx 3 SERVER SERVER 4096 2011-01-07 15:46 logs /home/SERVER/public_html (chmod -h & chgrp -h) lrwxrwxrwx 1 server server 41 2011-01-07 19:53 logs -> /home/GAMER/game/logs/

    Read the article

  • Open a screen session inside a certain user on boot Ubuntu Server Linux

    - by Pez Cuckow
    I currently have a private server which I test my web apps on which runs Ubuntu Server 10.04 I also host a few game servers (rather than having wasted CPU time :-D) for some of my friends. These game servers I run in the game user account and each one has it's own screen session (so friends can ssh in and reboot the game server etc...). For example screen -R l4d2 runs ./start in the L4D2 folder. However if I reboot the server (which I have to do occasionally) all these sessions close and I have to manually create all the screen sessions and run the required games within them. Is there a way to set these screen sessions as Daemons or services or just boot on server start so they restart themselves on server reboot? I hope I have made my question easy to understand but feel free to ask questions! Many thanks,

    Read the article

  • Cron Job that Boots Screen at Start

    - by Pez Cuckow
    I am trying to set up a number of processes that start during boot (servers for games) with the below command as the cron item: @reboot /usr/bin/screen -fa -d -m -S NAME COMMAND However if the server crashes for what ever reason screen closes and the server doesn't get a chance to run it's auto restart (as far as I understand; screen sees no processes in the socket and so closes). Is there a way that I can get around this so screen will sit there even if nothing is running in it?

    Read the article

  • Recommend a UK based VPS host equivalent to Dreamhost [closed]

    - by Pez Cuckow
    I appreciate this question could be considered subjective and argumentative so can people make recommendations rather than arguing about the best. I believe the "correct" answer is the one closest to what I am looking for. Basically I live in the UK but have been using the US based Dreamhost for about 6 years now, and my web projects are getting to the scale where the websites need to the UK based to cope with the demand and load. I originally had shared hosting with Dreamhost but upgraded to a VPS a while ago, getting 512mb of RAM, unlimited disk space, bandwidth and domains for $30. Their control panel is a custom easy to use build that they have created in house and offers features very similar to other web panels (as far as I am aware). So basically my question boils down to, is there anywhere that offers an equivalent package? In all honesty as long as I have over 50gb HDD space and unlimited domains it doesn't really matter? Are there any VPS providers you would recommend as reliable? I promise to check every link posted, many thanks for your time!

    Read the article

  • Squeeze/Lenny compilation : Library Link error

    - by PEZ
    I've got a problem here : I have a C++ Library ("DataTsBroad") and a C++ Test app ("DataTsBroadTest"), to test it. Actually, the Lib and the Test app are both compiled an a Debian Lenny. Now, i want to continue to compile my Test app on a Debian Lenny (customer constraint), but i would compile my lib on a Squeeze or a Wheezy to work on the last Debian releases. So, i successfully compiled my Lib on a Squeeze, But, after, when i try to compile my Test app with this Lib on the Lenny, it fails ! There is a Link Error : Linking CXX executable DataTsBroadTest /home/nis/pezierg/test/ProductMak/Export/DataTsBroad/L64/Release/libDataTsBroad64.so: undefined reference to `std::ctype::_M_widen_init() const@GLIBCXX_3.4.11' collect2: ld returned 1 exit status make[2]: *** [DataTsBroadTest] Error 1 make[1]: *** [CMakeFiles/DataTsBroadTest.dir/all] Error 2 make: * [all] Error 2 The problem is certainly due to ostream C++ Lib, I tried to comment all it's uses in my Lib and it works. But how can i really fix the problem ?

    Read the article

  • Seamless jQuery Marquee?

    - by Pez Cuckow
    Is it possible to create a 100% seamless marquee in jQuery (or just javascript but jQuery prefered)? I've made a simple marquee that moves left until it is off the screen then simply jumps (when out of view) to the right and starts again. However I would love it to not have the wait. The only way I could think of doing this would be to duplicate the text and put it after the first text, then swap them round again. However I have no idea how to implement this in jQuery. Any ideas?

    Read the article

  • More efficent way to do this?

    - by Pez Cuckow
    I have a if function that works out how much of a users profile is completed however the way I include below was the best I could think of, however it seems really inefficient. What is the better way to do this? if($user['first_name']!==""&&$user['last_name']!==""&&$user['pemail']!==""&&$user['dob']!==""&&$user['ambitions']!==""&&$user['memories']!==""&&$user['thoughts']!==""&&$user['message_1']!=="0"&&$user['message_2']!=="0"&&$user['message_3']!=="0"&&$user['v1']!=="0"&&$user['v2']!=="0"&&$user['v3']!=="0"&&$user['v4']!=="0"&&$user['v5']!=="0"&&$user['v6']!=="0"&&$user['v7']!=="0"&&$user['v8']!=="0"&&$user['v9']!=="0"&&$user['image_1']!==""&&$user['image_2']!==""&&$user['image_3']!=="") { $completed = 4; } elseif($user['first_name']!==""&&$user['last_name']!==""&&$user['pemail']!==""&&$user['dob']!==""&&$user['ambitions']!==""&&$user['memories']!==""&&$user['thoughts']!==""&&$user['v1']!=="0"&&$user['v2']!=="0"&&$user['v3']!=="0"&&$user['v4']!=="0"&&$user['v5']!=="0"&&$user['v6']!=="0"&&$user['v7']!=="0"&&$user['v8']!=="0"&&$user['v9']!=="0"&&$user['image_1']!==""&&$user['image_2']!==""&&$user['image_3']!=="") { $completed = 3; } elseif($user['first_name']!==""&&$user['last_name']!==""&&$user['pemail']!==""&&$user['dob']!==""&&$user['ambitions']!==""&&$user['memories']!==""&&$user['thoughts']!==""&&$user['message_1']!=="0"&&$user['message_2']!=="0"&&$user['message_3']!=="0"&&$user['image_1']!==""&&$user['image_2']!==""&&$user['image_3']!=="") { $completed = 2; } elseif($user['first_name']!==""&&$user['last_name']!==""&&$user['pemail']!==""&&$user['dob']!==""&&$user['ambitions']!==""&&$user['memories']!==""&&$user['thoughts']!==""&&$user['image_1']!==""&&$user['image_2']!==""&&$user['image_3']!=="") { $completed = 1; } else { $completed = 0; }

    Read the article

  • PHP If/Else - More efficent way to do this?

    - by Pez Cuckow
    I have a if function that works out how much of a users profile is completed however the way I include below was the best I could think of, however it seems really inefficient. What is the better way to do this? if($user['first_name']!==""&&$user['last_name']!==""&&$user['pemail']!==""&&$user['dob']!==""&&$user['ambitions']!==""&&$user['memories']!==""&&$user['thoughts']!==""&&$user['message_1']!=="0"&&$user['message_2']!=="0"&&$user['message_3']!=="0"&&$user['v1']!=="0"&&$user['v2']!=="0"&&$user['v3']!=="0"&&$user['v4']!=="0"&&$user['v5']!=="0"&&$user['v6']!=="0"&&$user['v7']!=="0"&&$user['v8']!=="0"&&$user['v9']!=="0"&&$user['image_1']!==""&&$user['image_2']!==""&&$user['image_3']!=="") { $completed = 4; } elseif($user['first_name']!==""&&$user['last_name']!==""&&$user['pemail']!==""&&$user['dob']!==""&&$user['ambitions']!==""&&$user['memories']!==""&&$user['thoughts']!==""&&$user['v1']!=="0"&&$user['v2']!=="0"&&$user['v3']!=="0"&&$user['v4']!=="0"&&$user['v5']!=="0"&&$user['v6']!=="0"&&$user['v7']!=="0"&&$user['v8']!=="0"&&$user['v9']!=="0"&&$user['image_1']!==""&&$user['image_2']!==""&&$user['image_3']!=="") { $completed = 3; } elseif($user['first_name']!==""&&$user['last_name']!==""&&$user['pemail']!==""&&$user['dob']!==""&&$user['ambitions']!==""&&$user['memories']!==""&&$user['thoughts']!==""&&$user['message_1']!=="0"&&$user['message_2']!=="0"&&$user['message_3']!=="0"&&$user['image_1']!==""&&$user['image_2']!==""&&$user['image_3']!=="") { $completed = 2; } elseif($user['first_name']!==""&&$user['last_name']!==""&&$user['pemail']!==""&&$user['dob']!==""&&$user['ambitions']!==""&&$user['memories']!==""&&$user['thoughts']!==""&&$user['image_1']!==""&&$user['image_2']!==""&&$user['image_3']!=="") { $completed = 1; } else { $completed = 0; }

    Read the article

  • Increase efficiency of a loop with jQuery

    - by Pez Cuckow
    I have a game coded in jQuery where bots are moved around the screen. The below code is a loop that runs every 20ms, currently if you have over 15 bots you start to notice the browser lagging (simply because of all the advanced collision detection going on). Is there any way to reduce the lag, can I make it any more efficient? P.s. sorrry for just posting a block of code, I can't see a way to make my point clear enough without! $.playground().registerCallback(function(){ //Movement Loop if(!pause) { for (var i in bots) { //bots - color, dir, x, y, z, spawned?, spawnerid, prevd var self = $('#b' + i); var current = bots[i]; if(bots[i][5]==1) { var xspeed = 0, yspeed = 0; if(current[1]==0) { yspeed = -D_SPEED; } else if(current[1]==1) { xspeed = D_SPEED; } else if(current[1]==2) { yspeed = D_SPEED; } else if(current[1]==3) { xspeed = -D_SPEED; } var x = current[2] + xspeed; var y = current[3] + yspeed; var z = current[3] + 120; if(current[2]>0&&x>PLAYGROUND_WIDTH||current[2]<0&&x<-GRID_SIZE|| current[3]>0&&y>PLAYGROUND_HEIGHT||current[3]<0&&y<-GRID_SIZE) { remove_bot(i, self); } else { if(current[7]!=current[1]) { self.setAnimation(colors[current[0]][current[1]]); bots[i][7] = current[1]; } if(self.css({"left": ""+(x)+"px", "top": ""+(y)+"px", "z-index": z})) { bots[i][2] = x; bots[i][3] = y; bots[i][4] = z; bots[i][8]++; } } } } $("#debug").html(dump(arrows)); $(".bot").each(function(){ var b_id = $(this).attr("id").substr(1); var collision = false; var c_bot = bots[b_id]; var b_x = c_bot[2]; var b_y = c_bot[3]; var b_d = c_bot[1]; $(this).collision(".arrow,#arrows").each(function(){ //Many thanks to Selim Arsever for this fix! var a_id = $(this).attr("id").substr(1); var piece = arrows[a_id]; var a_v = piece[0]; if(a_v==1) { var a_x = piece[2]; var a_y = piece[3]; var d_x = b_x-a_x; var d_y = b_y-a_y; if(d_x>=4&&d_x<=5&&d_y>=1&&d_y<=2) { //bots - color, dir, x, y, z, spawned?, spawnerid, prevd bots[b_id][7] = c_bot[1]; bots[b_id][1] = piece[1]; collision = true; } } }); if(!collision) { $(this).collision(".wall,#level").each(function(){ var w_id = $(this).attr("id").substr(1); var piece = pieces[w_id]; var w_x = piece[1]; var w_y = piece[2]; d_x = b_x-w_x; d_y = b_y-w_y; if(b_d==0&&d_x>=4&&d_x<=5&&d_y>=27&&d_y<=28) { kill_bot(b_id); collision = true; } //4 // 33 if(b_d==1&&d_x>=-12&&d_x<=-11&&d_y>=21&&d_y<=22) { kill_bot(b_id); collision = true; } //-14 // 21 if(b_d==2&&d_x>=4&&d_x<=5&&d_y>=-9&&d_y<=-8) { kill_bot(b_id); collision = true; } //4 // -9 if(b_d==3&&d_x>=22&&d_x<=23&&d_y>=20&&d_y<=21) { kill_bot(b_id); collision = true; } //22 // 21 }); } if(!collision&&c_bot[8]>GRID_MOVE) { $(this).collision(".spawn,#level").each(function(){ var s_id = $(this).attr("id").substr(1); var piece = pieces[s_id]; var s_x = piece[1]; var s_y = piece[2]; d_x = b_x-s_x; d_y = b_y-s_y; if(b_d==0&&d_x>=4&&d_x<=5&&d_y>=19&&d_y<=20) { kill_bot(b_id); collision = true; } //4 // 33 if(b_d==1&&d_x>=-14&&d_x<=-13&&d_y>=11&&d_y<=12) { kill_bot(b_id); collision = true; } //-14 // 21 if(b_d==2&&d_x>=4&&d_x<=5&&d_y>=-11&&d_y<=-10) { kill_bot(b_id); collision = true; } //4 // -9 if(b_d==3&&d_x>=22&&d_x<=23&&d_y>=11&&d_y<=12) { kill_bot(b_id); collision = true; } //22 // 21*/ }); } if(!collision) { $(this).collision(".exit,#level").each(function(){ var e_id = $(this).attr("id").substr(1); var piece = pieces[e_id]; var e_x = piece[1]; var e_y = piece[2]; d_x = b_x-e_x; d_y = b_y-e_y; if(d_x>=4&&d_x<=5&&d_y>=1&&d_y<=2) { current_bots++; bots[b_id] = false; $("#current_bots").html(current_bots); $("#b" + b_id).setAnimation(exit[2], function(node){$(node).fadeOut(200)}); } }); } if(!collision) { $(this).collision(".bot,#level").each(function(){ var bd_id = $(this).attr("id").substr(1); if(bd_id!=b_id) { var piece = bots[bd_id]; var bd_x = piece[2]; var bd_y = piece[3]; d_x = b_x-bd_x; d_y = b_y-bd_y; if(d_x>=0&&d_x<=2&&d_y>=0&&d_y<=2) { kill_bot(b_id); kill_bot(bd_id); collision = true; } } }); } }); } }, REFRESH_RATE); Many thanks,

    Read the article

  • GameQuery Collision Detection

    - by Pez Cuckow
    I am having a problem with GameQuery (jQuery) collision detection Tthey just never seem to fire?!? I have checked all the .arrow's exist and the same for the .bot's but it just never seems to call the function I have the below code in my main callback: $(".bot").each(function(){ $(this).collision(".arrow").each(function(){ alert("Test"); }); }); Do you have any idea why this would just simply be doing nothing? The bot walks (has it's x value) moved right over the arrow. Current revision online at http://labs.pezcuckow.com/solveit/game.html (no where near finished) if anyone doesn't mine having a look! Many thanks,

    Read the article

  • PHP GD Gradient Text

    - by Pez Cuckow
    I have coded a PHP script that takes $text and $font and creates an image, it even caches the image. Is it possible to create a vertical gradient on the text using GD in PHP, I am trying to create the effect below! Many thanks,

    Read the article

  • Increase efficiency of a loop with jQuery and GameQuery

    - by Pez Cuckow
    I have a game coded in jQuery where bots are moved around the screen. The below code is a loop that runs every 20ms, currently if you have over 15 bots you start to notice the browser lagging (simply because of all the advanced collision detection going on). Is there any way to reduce the lag, can I make it any more efficient? P.s. sorrry for just posting a block of code, I can't see a way to make my point clear enough without! $.playground().registerCallback(function(){ //Movement Loop if(!pause) { for (var i in bots) { //bots - color, dir, x, y, z, spawned?, spawnerid, prevd var self = $('#b' + i); var current = bots[i]; if(bots[i][5]==1) { var xspeed = 0, yspeed = 0; if(current[1]==0) { yspeed = -D_SPEED; } else if(current[1]==1) { xspeed = D_SPEED; } else if(current[1]==2) { yspeed = D_SPEED; } else if(current[1]==3) { xspeed = -D_SPEED; } var x = current[2] + xspeed; var y = current[3] + yspeed; var z = current[3] + 120; if(current[2]>0&&x>PLAYGROUND_WIDTH||current[2]<0&&x<-GRID_SIZE|| current[3]>0&&y>PLAYGROUND_HEIGHT||current[3]<0&&y<-GRID_SIZE) { remove_bot(i, self); } else { if(current[7]!=current[1]) { self.setAnimation(colors[current[0]][current[1]]); bots[i][7] = current[1]; } if(self.css({"left": ""+(x)+"px", "top": ""+(y)+"px", "z-index": z})) { bots[i][2] = x; bots[i][3] = y; bots[i][4] = z; bots[i][8]++; } } } } $("#debug").html(dump(arrows)); $(".bot").each(function(){ var b_id = $(this).attr("id").substr(1); var collision = false; var c_bot = bots[b_id]; var b_x = c_bot[2]; var b_y = c_bot[3]; var b_d = c_bot[1]; $(this).collision(".arrow,#arrows").each(function(){ //Many thanks to Selim Arsever for this fix! var a_id = $(this).attr("id").substr(1); var piece = arrows[a_id]; var a_v = piece[0]; if(a_v==1) { var a_x = piece[2]; var a_y = piece[3]; var d_x = b_x-a_x; var d_y = b_y-a_y; if(d_x>=4&&d_x<=5&&d_y>=1&&d_y<=2) { //bots - color, dir, x, y, z, spawned?, spawnerid, prevd bots[b_id][7] = c_bot[1]; bots[b_id][1] = piece[1]; collision = true; } } }); if(!collision) { $(this).collision(".wall,#level").each(function(){ var w_id = $(this).attr("id").substr(1); var piece = pieces[w_id]; var w_x = piece[1]; var w_y = piece[2]; d_x = b_x-w_x; d_y = b_y-w_y; if(b_d==0&&d_x>=4&&d_x<=5&&d_y>=27&&d_y<=28) { kill_bot(b_id); collision = true; } //4 // 33 if(b_d==1&&d_x>=-12&&d_x<=-11&&d_y>=21&&d_y<=22) { kill_bot(b_id); collision = true; } //-14 // 21 if(b_d==2&&d_x>=4&&d_x<=5&&d_y>=-9&&d_y<=-8) { kill_bot(b_id); collision = true; } //4 // -9 if(b_d==3&&d_x>=22&&d_x<=23&&d_y>=20&&d_y<=21) { kill_bot(b_id); collision = true; } //22 // 21 }); } if(!collision&&c_bot[8]>GRID_MOVE) { $(this).collision(".spawn,#level").each(function(){ var s_id = $(this).attr("id").substr(1); var piece = pieces[s_id]; var s_x = piece[1]; var s_y = piece[2]; d_x = b_x-s_x; d_y = b_y-s_y; if(b_d==0&&d_x>=4&&d_x<=5&&d_y>=19&&d_y<=20) { kill_bot(b_id); collision = true; } //4 // 33 if(b_d==1&&d_x>=-14&&d_x<=-13&&d_y>=11&&d_y<=12) { kill_bot(b_id); collision = true; } //-14 // 21 if(b_d==2&&d_x>=4&&d_x<=5&&d_y>=-11&&d_y<=-10) { kill_bot(b_id); collision = true; } //4 // -9 if(b_d==3&&d_x>=22&&d_x<=23&&d_y>=11&&d_y<=12) { kill_bot(b_id); collision = true; } //22 // 21*/ }); } if(!collision) { $(this).collision(".exit,#level").each(function(){ var e_id = $(this).attr("id").substr(1); var piece = pieces[e_id]; var e_x = piece[1]; var e_y = piece[2]; d_x = b_x-e_x; d_y = b_y-e_y; if(d_x>=4&&d_x<=5&&d_y>=1&&d_y<=2) { current_bots++; bots[b_id] = false; $("#current_bots").html(current_bots); $("#b" + b_id).setAnimation(exit[2], function(node){$(node).fadeOut(200)}); } }); } if(!collision) { $(this).collision(".bot,#level").each(function(){ var bd_id = $(this).attr("id").substr(1); if(bd_id!=b_id) { var piece = bots[bd_id]; var bd_x = piece[2]; var bd_y = piece[3]; d_x = b_x-bd_x; d_y = b_y-bd_y; if(d_x>=0&&d_x<=2&&d_y>=0&&d_y<=2) { kill_bot(b_id); kill_bot(bd_id); collision = true; } } }); } }); } }, REFRESH_RATE); Many thanks,

    Read the article

  • PHP Fizzbuzz Challenge

    - by Pez Cuckow
    Someone at work as poised the challenge to create a script that prints the FizzBuzz game in as few likes as possible using PHP The challenge Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”. My attempt: foreach(range(1,100) as $i) { $val = ($i % 3 == 0 ? "Fizz" : "").($i % 5 == 0 ? "Buzz" : ""); echo (empty($val) ? $i : $val) . '<br />'; } Someone's Pythons attempt [ ("Fizz" if not i % 3 else "") + ("Buzz" if not i % 5 else "") + ("Baz" if not i % 7 else "") if _ else "" for i in range(0, 100) ] Can you see how to make this better/improve it? Or even do it better? Thanks for your time

    Read the article

  • Regex find the first word

    - by Pez Cuckow
    I'm trying to use regex to add a span to the first word of content for a page, however the content contains HTML so I am trying to ensure just a word gets chosen. The content changes for every page. Current script is: preg_match('/(<(.*?)>)*/i',$page_content,$matches); $stripped = substr($page_content,strlen($matches[0])); preg_match('/\b[a-z]* \b/i',$stripped,$strippedmatch); echo substr($page_content, 0, strlen($matches[0])).'<span class="h1">'.$strippedmatch[0].'</span>'.substr($stripped, strlen($strippedmatch[0])); However if the $page_content is <p><span class="title">This is </span> my title!</p> Then my regex thinks the first word is "span" and adds the tags around that. Is there any way to fix this? (or a better way to do it).

    Read the article

  • More efficient comparison of numbers

    - by Pez Cuckow
    I have an array which is part of a small JS game I am working on I need to check (as often as reasonable) that each of the elements in the array haven't left the "stage" or "playground", so I can remove them and save the script load I have coded the below and was wondering if anyone knew a faster/more efficient way to calculate this. This is run every 50ms (it deals with the movement). Where bots[i][1] is movement in X and bots[i][2] is movement in Y (mutually exclusive). for (var i in bots) { var left = parseInt($("#" + i).css("left")); var top = parseInt($("#" + i).css("top")); var nextleft = left + bots[i][1]; var nexttop = top + bots[i][2]; if(bots[i][1]>0&&nextleft>=PLAYGROUND_WIDTH) { remove_bot(i); } else if(bots[i][1]<0&&nextleft<=-GRID_SIZE) { remove_bot(i); } else if(bots[i][2]>0&&nexttop>=PLAYGROUND_HEIGHT) { remove_bot(i); } else if(bots[i][2]<0&&nexttop<=-GRID_SIZE) { remove_bot(i); } else { //alert(nextleft + ":" + nexttop); $("#" + i).css("left", ""+(nextleft)+"px"); $("#" + i).css("top", ""+(nexttop)+"px"); } } On a similar note the remove_bot(i); function is as below, is this correct (I can't splice as it changes all the ID's of the elements in the array. function remove_bot(i) { $("#" + i).remove(); bots[i] = false; } Many thanks for any advice given!

    Read the article

  • MySQL More Tables or More Rows

    - by Pez Cuckow
    I am working on a game that I am going to open to the public to have on their game. The game stores lots of information (about 300 rows) per website and spends a lot of time updating values within this MySQL database. Is it better (faster/efficient) to add a new table for every website or to just have 1000's of rows in one table and add a column "website_id" or similar?

    Read the article

  • GWT i18n - Plural Forms doesn't work at all?

    - by PEZ
    I'm using GWT internationalization Messages. The documentation for Plural Forms says this should work: @DefaultMessage("{0} {1,number} hours {2}") @PluralText({"one", "an hour"}) String hours(String prefix, @PluralCount int count, String suffix); Well, it doesn't. Whatever value of count it still delivers DefaultMessage (e.g. "1 hours ago"). Same if I use a .properties file: hours[one]=an hour hours[few]=some hours hours={0} {1,number} hours {2} Is there a bug in the docs or in GWT (I'm using GWT 2.0.3) or in me? If any of the two former, anyone knows of a workaround?

    Read the article

  • How to get Eclipse + PyDev + App Engine + Unit testing to work?

    - by PEZ
    I want to run my unit tests for a Python Google App Engine project using Run As = Python unit-test But when I try that all my Model tests bail with the error message: BadArgumentError: app must not be empty. Anyone got this to work? NB: The tests runs fine using Nose --with-gae. But I want the PyDev integration with hyperlinking of resources and such.

    Read the article

  • How to model a social news feed on Google App Engine

    - by PEZ
    We want to implement a "News feed" where a user can see messages broadcasted by her friends, sorted with newest message first. But the feed should reflect changes in her friends list. (If she adds new friends, messages from those should be included in the feed, and if she removes friends their messages should not be included.) If we use the pubsub-test example and attach a recipient list to each message this means a lot of manipulation of the message recipients lists when users connect and disconnect friends. We first modeled publish-subscribe "fan out" using conventional RDBMS thinking. It seemed to work at first, but then, since the IN operator works the way it does, we quickly realized we couldn't continue on that path. We found Brett Slatkin's presentation from last years Google I/O and we have now watched it a few times but it isn't clear to us how to do it with "dynamic" recipient lists. What we need are some hints on how to "think" when modeling this.

    Read the article

1 2  | Next Page >