Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python2
import multiprocessing
import socket
import time
import os
def handle(socket):
import logging
logging.basicConfig(level=logging.DEBUG)
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#define CHAR_BIT 8
#define MAXBITS (CHAR_BIT*sizeof(uintmax_t))
#define FMT_BUF_SIZE (MAXBITS+1)
char *binary_fmt(uintmax_t x, char buf[static FMT_BUF_SIZE])
{
@Excedrin
Excedrin / forkeval
Created August 27, 2012 08:24
2007 python multiprocessing
import os
def evalexit(code):
eval(code)
raise SystemExit
def forkexpr(s):
code = compile(s, "<string>", "eval")
os.fork() or evalexit(code)
@Excedrin
Excedrin / gist:3612698
Created September 3, 2012 19:33
imperative foldl and foldr
#!/usr/bin/rdmd
import std.stdio;
int sub(int x, int y) {
return x - y;
}
void main() {
int init = 0;
#!/bin/bash
set -e
VERSION=$1
INSTALLER="OCTGN-Setup-${VERSION}.exe"
echo $VERSION $INSTALLER
@Excedrin
Excedrin / bind.py
Last active December 21, 2015 01:59
#!/usr/bin/python
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Virt management features
Copyright 2007, 2012 Red Hat, Inc
Michael DeHaan <michael.dehaan@gmail.com>
Seth Vidal <skvidal@fedoraproject.org>
def selfdec(f):
def dec(*x, **kwa):
f.__globals__['self'] = x[0]
return f(*x[1:], **kwa)
return dec
class X():
@selfdec
def z(more, args, even="opt"):
self.hurr = 3