Skip to content

Instantly share code, notes, and snippets.

@noonien
noonien / async_loader.js
Created July 16, 2012 17:36
Asynchronous Javascript/CSS loader.
AL = function(type, url, callback) {
var el, doc = document;
switch(type) {
case 'js':
el = doc.createElement('script');
el.src = url;
break;
case 'css':
el = doc.createElement('link');
@noonien
noonien / evil
Created July 19, 2012 12:07
Simple bash prank
# This script disables execution of commands and echoes messages to the user, to disable type: "wat"
#
# To install this, you need to have access to the user's home directory.
# sudo -u <user> -i sh -c 'cp /path/to/evil ~/.evil && cp ~/.bashrc ~/.bashrc.ebak && echo ". ~/.evil" >> ~/.bashrc'
shopt -s extdebug
function disable_evil() {
rm ~/.evil
rm ~/.bashrc
@noonien
noonien / tracker.py
Last active January 28, 2020 21:11
from torrent.database import mongo
from flask import Blueprint, Response, current_app, request
from bencode import bencode
from IPy import IP
from socket import inet_pton, inet_ntop, ntohs, htons, AF_INET, AF_INET6
from struct import pack
bp = Blueprint('tracker', __name__)
class TrackerFailure(Exception):
import struct
import hashlib
from datetime import datetime
t = datetime.now()
ci = 0
for i in xrange(0, 2**42):
buf = struct.pack('Q', i)
m = hashlib.sha256()
@noonien
noonien / cloud-config-master-node.yaml
Last active September 16, 2015 11:49
k8s v0.15.0 on CoreOS
#cloud-config
hostname: node-01
ssh_authorized_keys:
- ssh-rsa <redacted>
coreos:
etcd2:
discovery: https://discovery.etcd.io/<redacted>
advertise-client-urls: http://node-01.mux.lan:2379
apiVersion: v1
kind: List
items:
- kind: ReplicationController
apiVersion: v1
metadata:
name: gitlab
namespace: internal
spec:
replicas: 1
@noonien
noonien / cache_stat.cpp
Last active October 13, 2016 16:19
LRU cache for stat()
// compile with: g++ -fPIC -shared -std=c++11 cache_stat.cpp -ldl -O3 -o cache_stat.so
#include <functional>
#include <sys/stat.h>
#include <dlfcn.h>
#include "lrucache.hpp"
typedef int (*xstat_type)(int ver, const char *pathname, struct stat *buf);
typedef int (*xstat64_type)(int ver, const char *pathname, struct stat64 *buf);
typedef int (*fxstatat_type)(int ver, int dirfd, const char *path, struct stat *stat_buf, int flags);
@noonien
noonien / recwin
Last active April 19, 2017 17:30
Record window, encode and upload
#!/usr/bin/env python3
import argparse
import subprocess
import time
import os
import re
parser = argparse.ArgumentParser(description='Record window')
parser.add_argument('-window-id', type=int)
parser.add_argument('-fps', type=int, default=30)
@noonien
noonien / lego_00-namespace.yaml
Last active May 22, 2017 12:03
kube-lego + nginx-ingress on k8s 1.6+
apiVersion: v1
kind: Namespace
metadata:
name: kube-lego
@noonien
noonien / forward-pxe-to-windows-deployment.md
Created October 12, 2017 12:05
Forward PXE requests to Windows deployment servers using OpenWRT

Append the following to /etc/config/dhcp:

config boot 'linux'                        
        option filename 'pxelinux.0'       
        option serveraddress 'YOUR.SERVER.IP.HERE'
        option servername 'HP Deployment'  
        list dhcp_option '186,10.0.255.251'
        list dhcp_option '187,8017'      
 list dhcp_option '252,\\boot\BCD'