Friday, December 14, 2012

Prevent ssh auto disconnect after some time

Prevent ssh auto disconnect after some time

On the server side:

nano /etc/ssh/sshd_config

Add or modify the lines:
ClientAliveInterval 30
ClientAliveCountMax 5

You will need to restart sshd:
/etc/init.d/ssh restart

On the client side:

nano /etc/ssh/ssh_config

Add or modify the lines:
ServerAliveInterval 30
ServerAliveCountMax 5


Friday, December 7, 2012

אנימציה חלקה ב - html5 JavaScript Canvas - requestAnimationFrame

רבים וטובים (וגם אני) משתמשים ב - setTimeout או setInterval בשביל ליצר אנימציה ב - HTML5 JavaScript עם Canvas Tag.

מתכנתים ותיקים בוודאי זוכרים את Vertical Sync שהיינו משתמשים ב - Assembler בכדי להשיג תנועה חלקה.

לאחרונה גיליתי יכולת חדשה של ה - browser בכדי לספק לנו דבר דומה בתכנות JavaScript ב- HTML5 עבור Canvas.

במקום להשתמש ב - setIntrerval / setTimeout ניתן להשתמש ב - requestAnimationFrame אשר קורא לפונקציית הציור של התמונה בקצב המהיר ביותר האפשרי מבחינת ה - browser.

הנה השימוש, בכדי להשיד תמיכה בכל הדפדפנים:

var animationFrame = window.requestAnimationFrame ||
 window.webkitRequestAnimationFrame ||
 window.mozRequestAnimationFrame ||
 window.oRequestAnimationFrame ||
 window.msRequestAnimationFrame ||
 null ;

Monday, November 19, 2012

פקודות לעבודה עם master-slave של mysql - replication

CHANGE MASTER TO
MASTER_HOST='xxx.xxx.xxx.xxx',
MASTER_PORT=3306,
MASTER_USER='repl',
MASTER_PASSWORD='slavepass',
MASTER_LOG_FILE='mysql-bin.000001',
MASTER_LOG_POS=0;


SHOW BINLOG EVENTS IN 'mysql-bin.000001' LIMIT 10;

STOP SLAVE;

START SLAVE;

SHOW SLAVE STATUS\G

And of course, a link to the master Moshe Kaplan Blog about MySQL repliaction

Sunday, November 18, 2012

Thursday, October 11, 2012

הרצת PHP מתוך cron

הרצת PHP מתוך cron

0 7 * * * cd /to/the/directory && php -f /to/the/directory/code.php >> /file.log 2>&1


יש לזכור לבצע cd  לספריה שבה יושב הקוד אחרת הוא יורץ מתוך ספריית הבית של ה - user

הוספת 
2>&1

בסוף השורה גורמת להודעות שגיאה שה - php מוציא להכנס ללוג stdout שאנחנו מיצרים בעזרת >>


Friday, September 7, 2012

Planet Commander - HTML5 Canvas Online Game


שיחקתי קצת עם HTML5 Canvas וכמובן JavaScript וזה מה שיצא:


להורדה לכרום - עובד גם ללא חיבור לאינטרנט:
https://chrome.google.com/webstore/detail/pkfcbmdddigmhfifefpomilfclfpgmli

Planet Commander
משחק דפדפן שבו צריך לכבוש כוכבים שונים. אשמח לשמוע את דעתכם.

http://www.cnaanaviv.com/stars