Skip to content

Instantly share code, notes, and snippets.

View corpix's full-sized avatar
👹
Fighting demons

corpix corpix

👹
Fighting demons
View GitHub Profile

Keybase proof

I hereby claim:

  • I am corpix on github.
  • I am corpix (https://keybase.io/corpix) on keybase.
  • I have a public key whose fingerprint is BE24 A859 6D62 D58B 60A2 EEBF 50BE EC20 48B4 DB04

To claim this, I am signing this object:

package main
// XXX: Here will be a bunch of shitcoded solutions :)
import (
"crypto/sha1"
"encoding/base64"
"encoding/hex"
"fmt"
"io"
@corpix
corpix / dockerfile-brew
Last active August 10, 2016 19:25
Tiny script to brew your dockerfile with ease
#!/usr/bin/env python3
import argparse
import json
import os
from os import path
def get_file_content(path):
with open(path, "r") as file:
return file.read()
#!/usr/bin/env bash
set -e
set -x
mkdir recovery
cd recovery
# Iterate installed packages (pkgname=pkgversion)
for pkgfullname in `dpkg -l | grep '^ii' | awk '{print $2"="$3}'`; do
# Get package name without version
{
leaf=$$
ps -eo pid,ppid,command | awk -v leaf="$leaf" \
'{parent[$1]=$2;command[$1]=$3;}
function print_ancestry(pid)
{
print pid " (" command[pid] ") child of " parent[pid];
if(pid!=1) print_ancestry(parent[pid])
};
END{\
package main
import (
"github.com/nictuku/dht"
"log"
"play/dht/utils"
)
func main() {
config := dht.NewConfig()
@corpix
corpix / hero-ku.py
Created September 27, 2015 12:12
heroku logsaver
# -*- coding: utf-8 -*-
from __future__ import print_function
import requests
from lxml import html
import json
import sys
import os
HOST = "http://lumber.leanpoker.org"
SOURCE = HOST + "/logs/tournament/55e4be2d4adaaf0003000002/team/poker-player-abuse-or-lose/log"
@corpix
corpix / htoprc
Created June 16, 2015 11:00
Htop rc
mkdir -p ~/.config/htop; cat <<EOF | tee ~/.config/htop/htoprc
fields=0 48 17 18 38 39 40 2 46 47 49 1
sort_key=46
sort_direction=1
hide_threads=0
hide_kernel_threads=1
hide_userland_threads=0
shadow_other_users=1
show_thread_names=0
highlight_base_name=1
@corpix
corpix / each-line.py
Last active August 29, 2015 14:23
Execute command for each line
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import subprocess
while True:
x = sys.stdin.readline().strip()
if x != "":
subprocess.check_call(sys.argv[1:] + [x], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
else:
rm -rf node-instances
while true; do
x="$(ps aux | grep $USER | grep node | grep -v grep)";
d="$(date +%s)"
[ ! -z "$x" ] && echo "$x" | perl -p -i -e "s/^/$d /g" >> node-instances
sleep 0.1
done