Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
import os
import sys
import time
import fcntl
import socket
import signal
import argparse
import subprocess
import struct
@bacher09
bacher09 / aliases.sh
Last active February 5, 2017 13:58
Useful aliases
myip() {
curl -4 "http://icanhazip.com/"
}
myip6() {
curl -6 "http://icanhazip.com/"
}
reverse_ipv4() {
local ip="$1"
function string_ends(text, ends)
return ends == "" or string.sub(text, -string.len(ends)) == ends
end
function vlc_format(filename)
-- https://wiki.videolan.org/VLC_Features_Formats#Format.2FContainer.2FMuxers
local formats = {
"3gp", "asf", "wmv", "au", "avi", "mka", "mkv", "flv", "mov", "mp4",
"ogg", "ogm", "ts", "mpg", "mp3", "mp2", "msc", "msv", "nut", "ra",
#!/bin/sh
wget --base=http://dl.xonotic.co/ -i maps.txt
@bacher09
bacher09 / xorg.conf
Created December 9, 2016 10:11
amazon g2 xorg.conf
Section "ServerLayout"
Identifier "X.org Configured"
Screen 0 "Screen0" 0 0
InputDevice "Mouse0" "CorePointer"
InputDevice "Keyboard0" "CoreKeyboard"
EndSection
Section "Files"
ModulePath "/usr/lib/xorg/modules"
FontPath "/usr/share/fonts/X11/misc"
#!/usr/bin/env python3
import getpass
import crypt
import argparse
import sys
METHODS_DICT = dict((meth.name.lower(), meth) for meth in crypt.methods)
@bacher09
bacher09 / decrypt.py
Created November 20, 2013 18:20
Decrypt files from testing program
import six
from six.moves import zip
import struct
uint = lambda x: x & 0xffffffff
uhex = lambda x: hex(x & 0xffffffff)
str_to_int = lambda x: struct.unpack("<i", x)[0]
int_to_str = lambda x: struct.pack("<i", sign_int(x))
sign_int = lambda x: x if x < 0x7FFFFFFF else x - 0x100000000
@bacher09
bacher09 / gist:7411777
Created November 11, 2013 11:23
Example of template_global in flask >= 0.10
from flask import Flask, render_template_string
MAIN_TEMPLATE = """ \
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>{{ message }}</title>
</head>
@bacher09
bacher09 / gist:7411829
Created November 11, 2013 11:28
Example of template_global in flask < 0.10
from flask import Flask, render_template_string
MAIN_TEMPLATE = """ \
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>{{ message }}</title>
</head>
module Main where
import Control.Monad (forM_, mapM_)
import Control.Applicative ((<$>))
import Data.Bifunctor (bimap, first, second)
import Data.Array.MArray (newArray, writeArray)
import Data.Array.ST (runSTArray)
import Data.Array (Array, bounds, (!))
import Text.Read (readMaybe)