Skip to content

Instantly share code, notes, and snippets.

View spiermar's full-sized avatar

Martin Spier spiermar

View GitHub Profile
@spiermar
spiermar / ignore.js
Last active August 29, 2015 14:11 — forked from tj/ignore.js
function ignore(paths, fn) {
return function(req, res, next) {
if (~paths.indexOf(req.url)) {
next();
} else {
fn(req, res, next);
}
}
}
@spiermar
spiermar / nodeservice.conf
Created November 16, 2014 05:39
Node.js Upstart Configuration
description "Node.JS Service"
author "Martin Spier"
env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
respawn
start on runlevel [23]
stop on shutdown
respawn limit 20 5
@spiermar
spiermar / receiver.sh
Last active August 29, 2015 14:09
git pre-receive deploy hook
#!/bin/bash
DEPLOY_DIR=/apps/myapp
SERVICE_NAME=myservice
NOW=$(date +"%Y%m%d%H%M%S")
mkdir -p $DEPLOY_DIR/releases/hotpush-$NOW && cat | tar -x -C $DEPLOY_DIR/releases/hotpush-$NOW
cp $DEPLOY_DIR/current/prod.env $DEPLOY_DIR/releases/hotpush-$NOW
(cd $DEPLOY_DIR/releases/hotpush-$NOW && npm install)
sudo chown -R node:deploy $DEPLOY_DIR/releases/hotpush-$NOW
sudo service $SERVICE_NAME stop
rm $DEPLOY_DIR/current
loop do
use_synth :tb303
with_fx(:reverb, room: 0.5, mix: 0.3) do
play choose(chord(:e3, :minor)), release: 0.2, cutoff: rrand(60, 130)
end
sleep 0.25
end
\n
time_namelookup: %{time_namelookup}\n
time_connect: %{time_connect}\n
time_appconnect: %{time_appconnect}\n
time_pretransfer: %{time_pretransfer}\n
time_redirect: %{time_redirect}\n
time_starttransfer: %{time_starttransfer}\n
----------\n
time_total: %{time_total}\n
\n
package io.overloaded.jmeter;
import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.log.Logger;
import org.apache.http.client.methods.HttpGet;
@spiermar
spiermar / nginx.sh
Last active December 24, 2015 08:29
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemin
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /usr/local/nginx/conf/nginx.conf
# pidfile: /usr/local/nginx/logs/nginx.pid
jQuery.ajaxSetup({ cache: false });
function updatePlaylist() {
jQuery.getJSON("http://playlist-service.appspot.com/v1/playlist/last", function(data) {
var display = '';
if(data.song_artist) { display += data.song_artist + ' - '; }
display += data.song_name;
jQuery('div#playlist').text(display);
});
}
jQuery(document).ready(function () {
#!/bin/bash
ps -A -o pid,rss,command | grep nginx | grep -v grep | awk '{total+=$2}END{printf("nginx=%dMb\n", total/1024)}'
ps -A -o pid,rss,command | grep php-fpm | grep -v grep | awk '{total+=$2}END{printf("php-fpm=%dMb\n", total/1024)}'
ps -A -o pid,rss,command | grep mysqld | grep -v grep | awk '{total+=$2}END{printf("mysql=%dMb\n", total/1024)}'
ps -A -o pid,rss,command | grep transmission-da | grep -v grep | awk '{total+=$2}END{printf("transmission=%dMb\n", total/1024)}'
ps -A -o pid,rss,command | grep fail2ban | grep -v grep | awk '{total+=$2}END{printf("fail2ban=%dMb\n", total/1024)}'
ps -A -o pid,rss,command | grep sshd | grep -v grep | awk '{total+=$2}END{printf("sshd=%dMb\n", total/1024)}'
@spiermar
spiermar / spots.py
Last active December 15, 2015 06:39
import urllib2
import xml.etree.ElementTree as ET
from xml.dom import minidom
results = ET.Element('results')
def get_posts(url):
retry = 0
while (retry < 3):
try: