Skip to content

Instantly share code, notes, and snippets.

View ChristopherRabotin's full-sized avatar
🚀

Chris ChristopherRabotin

🚀
View GitHub Profile
from ast import *
from pygraphviz import AGraph
from re import sub
COLOR_KWD = '#a020f0'
COLOR_VAR = '#6c71c4'
COLOR_STR = '#8b2252'
def colorize(s, col):
return '<font color="%s">%s</font>' % (col, s)
@seanjensengrey
seanjensengrey / rust-python-cffi.md
Last active April 3, 2024 11:55
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
@mattetti
mattetti / gist:3798173
Last active April 16, 2023 03:09
async fetching of urls using goroutines and channels
package main
import (
"fmt"
"net/http"
"time"
)
var urls = []string{
"https://splice.com/",
@andypiper
andypiper / readserial.py
Created September 15, 2011 09:56
Scrape serial port for text data and publish on MQTT
#!/usr/bin/python
#
#simple app to read string from serial port
#and publish via MQTT
#
#uses the Python MQTT client from the Mosquitto project
#http://mosquitto.org
#
#Andy Piper http://andypiper.co.uk
#2011/09/15