Skip to content

Instantly share code, notes, and snippets.

@elitak
elitak / anti_ddos.sh
Last active August 29, 2015 14:03 — forked from anonymous/anti_ddos.sh
# in one window, get the offenders (change ack filter to whatever's most accurate)
sudo tail -f /var/log/nginx/access.log | ack 'GET / ' | awk '{print $1}' | teesample
# in the other, have a look at the worst with this:
sort sample | uniq -c | sort -n | tail -n 50
# and then ban them
sort sample | uniq -c | sort -n | awk '{print }' | tail -n 50 | xargs -i echo {} tcp http | sudo tee -a /etc/shorewall/blacklist
# restart shorewall, then nginx to clear up latent connections
# Then, restart the sampler to get a new batch.
@elitak
elitak / github_create_repo.py
Last active August 29, 2015 14:04
create a repo from cmdline using python github api
#!/usr/bin/env python
from github import Github
import os, sys
g = Github(os.environ.get('GH_USER', 'elitak'), os.environ.get('GH_PASS', ''))
g.get_user().create_repo(name=sys.argv[1])
for repo in g.get_user().get_repos():
print(repo.name)
#!/bin/bash
# Rather than scping to then invoking this script on the remote host, you can run:
# sed s,^tarpath=.*,tarpath=theURL, thisfile | ssh targethost
# TODO: add this as an invocation option that can be run on local host.
set -a
if [[ "$BASH_SOURCE" = "$0" ]]; then
[[ `whoami` == "root" ]] || { echo "Run as root."; exit 1; }
@elitak
elitak / bootstrap.cmd
Created December 26, 2015 21:55
Busybox bootstrapper
@echo off
set PATH=%~dp0;.;%PATH%
for %%I in (busybox.exe) do set BUSYBOX=%%~$PATH:I
REM this is still wrong if scriptname has a space in it
REM (bug? just don't put a space in this filename)
set ORIGPATH=%~f0
"%BUSYBOX%" sed "1,/^#!\/bin\/bash/d" "%ORIGPATH%" > "%TEMP%\%~n0.sh"
@elitak
elitak / autoexec.cfg
Created January 21, 2016 21:24
dota2 autoexec.cfg
//// UI
dota_camera_disable_zoom "1" //Can't zoom camera in
engine_no_focus_sleep 0 // unlimited alt-tabbed framerate
dota_minimap_hero_size 1100 //Changes the size of heroes on the minimap
// this enables alt+right click to move towards location without pathing
// (stop at first obstacle). This is for aiming forcestaff/raze/pounce,
// planting wards on base highground, fake planting wards in river,
// move illus onto rosh (clicks thru),
@elitak
elitak / nixos-infect
Last active October 18, 2018 07:25
#! /usr/bin/env bash
# nixos-infect is so named because there's a good chance the system will get
# sick if anything goes wrong, and possibly die, requiring reprovisioning.
# Use with caution.
#
# WARNING NB This script wipes out the targeted host's root filesystem when it
# runs to completion. Any errors halt execution. set -x is used to help debug,
# as often a failed run leaves the system in an inconsistent state, requiring a
# rebuild (in DigitalOcean panel: Droplet Settings -> "Destroy" -> "Rebuild
Verifying that +elitak is my blockchain ID. https://onename.com/elitak
@elitak
elitak / morse.py
Created February 13, 2019 16:45
morse funcs
#! /usr/bin/env python
keylist = " 5H4S!V3I?F@U$^2E L R - A P W J .6B=D/X7N C K Y T Z G Q M8: O9)0"
def decode(code):
o = i = len(keylist) >> 1
for c in code:
o >>= 1
i += o if c == '-' else -o
return keylist[i]