Skip to content

Instantly share code, notes, and snippets.

View luke10x's full-sized avatar

Luke 10X luke10x

View GitHub Profile
@luke10x
luke10x / remote2tailable
Created April 16, 2014 21:58
Syncs new lines in a remote log file to a local file then outputs it through tailable
#!/bin/bash
# Syncs new lines in a remote log file to a local file.
# Downloads remote file, and prints all lines that are
# not yet printed
source=$1
# Find the name for the locally copied file
hash=`echo "$source" | md5sum | cut -d " " -f 1`
@luke10x
luke10x / monitor-file-changes.py
Created April 16, 2014 22:11
Process that monitors file system changes within directory and runs scripts on changed entities
#!/usr/bin/python
import gamin
import time
from os.path import expanduser
import threading
import thread
import os
import Queue
#!/usr/bin/env /usr/bin/python
import os, errno, shutil, sys
from pipes import quote
script_dir = os.path.realpath(os.path.dirname(__file__))
output_dir = script_dir + "/outerr"
tmp_dir = script_dir + "/tmppppppp"
book_dir = os.path.realpath(sys.argv[1])
book_name = os.path.basename(book_dir)
@luke10x
luke10x / nginx-wordpress-site
Created July 26, 2014 21:55
Wordpress site with separate directory for app related stuff
server {
server_name tkbodycode.dev;
root /home/lape/workspace/tkbodycode/wordpress;
index index.php;
location / {
try_files $uri $uri/ /index.php;
}
@luke10x
luke10x / lcm.py
Created October 17, 2014 18:31
Python oneliners to find lowest common multiplier
#!/usr/bin/env python
print "="*80
#import sys
b = 24
a = 32
for i in range(1, min(a, b)):
if (a % i == 0 and b % i == 0):
gcd = i
#print "Found common divisor" + str(gcd)
caption string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} %Y-%m-%d %c"
caption always
hardstatus off
shell "bash"
startup_message off
vbell off
altscreen on
attrcolor b ".I"
defbce "on"
termcapinfo xterm* 'is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l'
@luke10x
luke10x / cast-here.sh
Last active October 31, 2015 23:39
sound travel
#/bin/bash
FIFO=/tmp/recast-fifo
rm $FIFO
mkfifo $FIFO
(while true; do cat $FIFO | pv | nc -u 127.0.0.1 14999; NC_PID_1=$!; done) &
TCP_PULL_PID=$!
(while true; do nc 0.0.0.0 14888 >$FIFO; NC_PID_2=$!; done) &
UDP_PUSH_PID=$!
@luke10x
luke10x / autossh.service
Created May 18, 2016 04:06 — forked from thomasfr/autossh.service
Systemd service for autossh
[Unit]
Description=Keeps a tunnel to 'remote.example.com' open
After=network.target
[Service]
User=autossh
# -p [PORT]
# -l [user]
# -M 0 --> no monitoring
# -N Just open the connection and do nothing (not interactive)
<?php
namespace So\ProphecyTest;
use PHPUnit\Framework\TestCase;
class SimpleRecord {
private $value = 'default-one';
}
class MagicRecord {
public function __get($prop) {
### Flush and Delete Old Settings ...
iptables -X
iptables -F
iptables -t nat -F
### " ALL MYSQL TRAFFIC FROM Y, PORT (3306) TO Z PORT (3306) ...."
# iptables -t nat -A PREROUTING -p tcp -d db-host.com --dport 3306 -j DNAT --to-destination 192.168.5.1:4041
iptables -t nat -A OUTPUT -p tcp -d db-host.com --dport 3306 -j DNAT --to-destination 192.168.5.1:4041
#iptables -A FORWARD -p tcp -d db-host.com --dport 3306 -j ACCEPT