Run 5 times, with one second delay between calls
t1 = new Timer(500, function(){
console.log(this.count);
if (this.count >= 5) {
this.stop();
}
});
| // | |
| // This server will start a bash shell and expose it | |
| // over socket.io to a browser. See ./term.html for the | |
| // client side. | |
| // | |
| // You should probably: | |
| // | |
| // npm install socket.io | |
| // curl -O https://github.com/LearnBoost/Socket.IO/raw/master/socket.io.min.js | |
| // |
| var child_process = require('child_process'); | |
| // exec: spawns a shell. | |
| child_process.exec('ls -lah /tmp', function(error, stdout, stderr){ | |
| console.log(stdout); | |
| }); | |
| // execFile: executes a file with the specified arguments | |
| child_process.execFile('ls', ['-lah', '/tmp'], function(error, stdout, stderr){ | |
| console.log(stdout); |
rsync (Everyone seems to like -z, but it is much slower for me)
| #!/bin/sh | |
| ### BEGIN INIT INFO | |
| # Provides: webcam | |
| # Required-Start: $remote_fs $syslog | |
| # Required-Stop: $remote_fs $syslog | |
| # Default-Start: 2 3 4 5 | |
| # Default-Stop: 0 1 6 | |
| # Short-Description: Control raspistill | |
| # Description: Control raspistill camera time lapse | |
| # and save images to RAM disk. |
| # PROBLEM | |
| # Find an implementation of "x" that will force the code below to print "helloworld". | |
| # SOLUTION | |
| # This doesn't work with threads forked to return true/false. The trick is to just have x do both. | |
| def x | |
| print "hello" | |
| false | |
| end |
| #!/bin/sh | |
| # Change Mirrors | |
| # sed --in-place 's/us.archive.ubuntu.com/mirror.0x.sg/' /etc/apt/sources.list | |
| # sed --in-place 's/us.archive.ubuntu.com/download.nus.edu.sg\/mirror/' /etc/apt/sources.list | |
| get_and_execute() | |
| { | |
| FILE=$1 | |
| echo "Getting $FILE" |
| :local newanimal [("lease status = ".[$leaseBound]." | ".[$"lease-hostname"]." | ".[$leaseActIP]." | ".[$leaseActMAC])] | |
| /tool fetch "https://api.telegram.org/botAPIKEY/sendmessage\?chat_id=CHATID&text=Movement in the animal farm!%0a $newanimal" keep-result=no; | |