Skip to content

Instantly share code, notes, and snippets.

View artnez's full-sized avatar
🪐

Artem Nezvigin artnez

🪐
View GitHub Profile
@artnez
artnez / monkey-patch
Created May 6, 2013 04:15
Monkey patching a function in bash.
#! /usr/bin/env bash
#
# Monkey patching a function in bash. Why.
patch() {
new_guy=$(declare -f $1)
new_guy=${new_guy##$1*\{}
new_guy=${new_guy/\}/}
old_guy=$(declare -f $2)
old_guy=${old_guy/$2*{/}
$ time make devel
Tearing it down...
Creating virtualenv...
Installing Python packages (locally)...
Installing Node.js packages (locally)...
Creating environment symlink...
Adding Vagrant integration...
Booting Vagrant...
Creating users...
Configuring iptables...
@artnez
artnez / gist:7444121
Created November 13, 2013 05:17
This will crash Firefox.
<!DOCTYPE html>
<html>
<head>
<title>Crash</title>
<style>
#crash {
position: absolute;
top: 0;
left: 0;
width: 100%;
#! /usr/bin/env bash
if [ $DEBUG ]; then
set -o xtrace
fi
# ...
#! /usr/bin/env python
#
# For Keri. There really isn't a generalizable way to go about this because the
# input has very specific rules. But here's a pretty typical way to do it.
from re import compile, split
RE_DELIMETERS = compile(r'[\/\s]+')
RE_NUMERIC = compile(r'^[0-9]+')
RE_BINARY_OPS = compile(r'^[\+\-]+')
#include <stdio.h>
int main(char *arg, char **argv) {
int n = 10;
int i;
int m = 100;
switch (n) {
case 0:
m = 1;
while (m--) {