Skip to content

Instantly share code, notes, and snippets.

View serverwentdown's full-sized avatar

Ambrose Chua serverwentdown

View GitHub Profile
@refabr1k
refabr1k / DhcpReporter
Last active February 13, 2024 23:34
Mikrotik dhcp lease notification using telegrambot
: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;
@jellyjellyrobot
jellyjellyrobot / ._
Last active February 25, 2018 12:40
Me being a lazy guy
#!/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"
@HoyaBoya
HoyaBoya / x.rb
Last active August 29, 2015 13:58
Print "helloworld" with the following if/else statement.
# 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
@rmamba
rmamba / timelapsed
Last active August 29, 2015 13:58
Timelapse daemon for RaspberryPI
#!/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.
@KartikTalwar
KartikTalwar / Documentation.md
Last active April 13, 2024 23:09
Rsync over SSH - (40MB/s over 1GB NICs)

The fastest remote directory rsync over ssh archival I can muster (40MB/s over 1gb NICs)

This creates an archive that does the following:

rsync (Everyone seems to like -z, but it is much slower for me)

  • a: archive mode - rescursive, preserves owner, preserves permissions, preserves modification times, preserves group, copies symlinks as symlinks, preserves device files.
  • H: preserves hard-links
  • A: preserves ACLs
@s4y
s4y / gist:1215700
Created September 14, 2011 02:12
child_process.execFile example
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);
@mixonic
mixonic / server.js
Created April 28, 2011 22:49
Node.js + Socket.io + Bash. A collaborative terminal for your browser.
//
// 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
//
@NV
NV / README.md
Created April 12, 2010 11:28
JavaScript Timer class. setInterval pool. Much more powerful than prototype.js's periodicalExecuter

JavaScript Timer

Run 5 times, with one second delay between calls

t1 = new Timer(500, function(){
  console.log(this.count);
  if (this.count >= 5) {
    this.stop();
  }

});