Skip to content

Instantly share code, notes, and snippets.

# before
def my_decorator(f):
def wrapper(*args, **kwds):
print('Calling decorated function')
return f(*args, **kwds)
return wrapper
# but why not
def my_decorator(f)(*args, **kwds):
print('Calling decorated function')
import pty
import time
import os
import termios
import signal
import sys
import traceback
import threading
if len(sys.argv) > 1:
/*
* $ gcc -m32 -fPIC -shared -o regdump.so regdump.c
* $ LD_PRELOAD=$(pwd)/regdump.so ./test
*
* Dump register state with 'ud2a' (0F 0B)
*/
#define _GNU_SOURCE
#include <signal.h>
#include <stdlib.h>
package main
var x interface{ f() }
type A struct {
fp func()
}
func (a A) f() { a.fp() }
#!/usr/bin/env python
import os
import time
import torch
import torch.distributed as dist
import torch.multiprocessing as mp
INTERVAL = 1
COMM_SIZE = (10,)
@nelhage
nelhage / llama.json
Last active January 3, 2021 18:34
Llama CF template
{
"Parameters": {
"ObjectStoreBucket": {
"Type": "String",
"Description": "A pre-existing S3 bucket to use for llama's object store"
},
"ObjectStorePrefix": {
"Type": "String",
"Description": "A prefix in $ObjectStoreBucket under which to store objects",
"Default": "/",
# BoringSSL build times, Pixelbook
# `make -j5`, local compiler
real 2m40.180s
user 8m37.189s
sys 1m21.565s
# `ninja -j6`, local
real 2m35.987s
user 7m53.337s
sys 1m14.439s
b1:
%x1 = 1
jmp b3
b2:
%x2 = 2
jmp b3
b3:
%x3 = phi [b1, %x1], [b2, %x2]
@nelhage
nelhage / main.go.c
Last active September 22, 2020 02:49
A Go/C polyglot
// \
/*
#include <stdio.h>
int main() {
printf("Hello, World from C!\n");
return 0;
}
#if 0
//*/
@nelhage
nelhage / .gitignore
Last active May 26, 2020 07:04
cuviper/probe bug report
/target