Skip to content

Instantly share code, notes, and snippets.

View EFulmer's full-sized avatar
😄

Eric Fulmer EFulmer

😄
View GitHub Profile
@EFulmer
EFulmer / ex1.go
Last active August 29, 2015 14:04
Building a simple Cron utility to update my Homebrew packages
// first version:
// just runs "brew update", waits for result, and exits
package main
import (
"os/exec"
)
func main() {
@EFulmer
EFulmer / random_dril_tweet.py
Last active June 14, 2016 17:37
I don't know why I'm doing this...
from __future__ import print_function
import csv
import os.path
import random
import subprocess
import sys
TWEET_FILE_NAME = 'dril.txt'
@EFulmer
EFulmer / property.py
Created July 18, 2017 00:20
property examples
class Ramone(object):
def __init__(self, name, instrument):
self.name = name
self.instrument = instrument
@property
def countdown(self):
if not hasattr(self, '_countdown'):
self._countdown = 1
return self._countdown
@EFulmer
EFulmer / reverse_args.py
Created August 19, 2017 23:37
decorator to call function's arguments in reversed order
def reverse_args(f):
def g(*args, **kwargs):
return g(*reversed(args), **kwargs)
return g
def foo(a, b):
return a + b
rev_foo = reverse_args(foo)
@EFulmer
EFulmer / rust-python-cffi.md
Created April 15, 2018 20:15 — forked from seanjensengrey/rust-python-cffi.md
Calling Rust from Python/PyPy using CFFI (C Foreign Function Interface)

This is a small demo of how to create a library in Rust and call it from Python (both CPython and PyPy) using the CFFI instead of ctypes.

Based on http://harkablog.com/calling-rust-from-c-and-python.html (dead) which used ctypes

CFFI is nice because:

  • Reads C declarations (parses headers)
  • Works in both CPython and PyPy (included with PyPy)
  • Lower call overhead than ctypes