Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View corpix's full-sized avatar
👹
Fighting demons

corpix corpix

👹
Fighting demons
View GitHub Profile
@corpix
corpix / sudo.py
Last active August 29, 2015 13:56
SImple wrapper around sudo on Python
from subprocess import call
import types
def sudo(cmd):
cmd = 'sudo %s' % cmd
return call(cmd, shell=True)
class SudoExecutor(type):
def __getattr__(self, name):
FROM stackbrew/ubuntu:saucy
RUN apt-get update
RUN apt-get install -y --force-yes \
software-properties-common \
pciutils \
debconf-utils
RUN add-apt-repository -y ppa:saltstack/salt
RUN apt-get update
@corpix
corpix / color_recover.js
Last active August 29, 2015 13:57
Recover color
(function(c,a,b,i,r){
r='#';
c=c.replace(r,'');
b=b.replace(r,'');
for(i=0;i<6;i+=2)
r+=Math.round(a*parseInt(c[i]+c[i+1],16)+(1-a)*parseInt(b[i]+b[i+1],16)).toString(16);
return r
})('#f4f3f0', 0.3, '#ffffff')
/* color, alpha, background */
@corpix
corpix / streamo.py
Created March 20, 2014 23:06
Streamo!
#!/usr/bin/env python
import os
import subprocess
import shutil
import hashlib
import time
from string import Template
STREAMS = [
@corpix
corpix / mirror
Created March 21, 2014 22:54
Simple git mirroring
#!/usr/bin/env python
import os
from subprocess import call
import hashlib
me = os.path.dirname(os.path.realpath(__file__))
tmp = "%s/tmp" % me
curl -I http://corpix.ru 2>/dev/null | grep Last-Modified | sed 's/.\+: //' | xargs node -e 'd=new Date(process.argv.slice(1).join(" "));e=new Date(Date.now()-10*1000);process.exit(d.getTime()>e.getTime()?0:1)'
#!/bin/bash
# Helpers for current branch tagging
function get_filetered_branch_repr {echo `git rev-parse --abbrev-ref HEAD` | sed 's/\//-/g'};
function get_last_tag {git tag | grep `get_filetered_branch_repr` | sort -r | head -n 1};
function get_incremented_tag {
get_last_tag | \
python -c "for line in __import__('sys').stdin: l=line.split('-');v=l[-1].rstrip().split('.');v[-1]=str(int(v[-1])+1);print '-'.join(l[:-1]+['.'.join(v)])"
}
@corpix
corpix / dd-wrt-static-leases-export.js
Created July 21, 2014 01:02
Exports dd-wrt dhcp static leases for isc-dhcpd
var s = '';for(var i = 0; i < nodes.length; i = i + 4) {s+="group {\n host " + nodes[i+1].value + " {\n hardware ethernet " + nodes[i].value + ";\n fixed-address " + nodes[i+2].value + ";\n }\n}\n"}
@corpix
corpix / download_latest_lists.py
Last active August 29, 2015 14:04
Generates salt pillar sls with adv domains
import os
import re
import http.client
connection = http.client.HTTPConnection('pgl.yoyo.org')
connection.request('GET', '/as/serverlist.php?hostformat=one-line&mimetype=plaintext')
response = connection.getresponse()
res_lines = response.read().decode().split(os.linesep)
@corpix
corpix / EventEmitter.delegate.coffee
Last active August 29, 2015 14:04
Delegate as monkey!
{EventEmitter} = require('events')
_emit = EventEmitter::emit
EventEmitter::emit = (type) ->
args = Array::slice.call(arguments)
res = _emit.apply(@, args)
if @_delegates and @_delegates[type]
for delegate in @_delegates[type]
if delegate.emit.apply(delegate, args)