Skip to content

Instantly share code, notes, and snippets.

@import Darwin;
@import Foundation;
@import IOKit;
// clang -fmodules -o i2cwrite i2cwrite.m && ./i2cwrite
typedef CFTypeRef IOAVServiceRef;
extern IOAVServiceRef IOAVServiceCreate(CFAllocatorRef allocator);
extern IOReturn IOAVServiceCopyEDID(IOAVServiceRef service, CFDataRef* x2);
// outputBufferSize must be less than (1 << 12) (4096 bytes)
@alin23
alin23 / listen.py
Last active September 4, 2020 17:03 — forked from kissgyorgy/listen.py
How to use PostgreSQL's LISTEN/NOTIFY as a simple message queue with psycopg2 and asyncio
import asyncio
import psycopg2
# dbname should be the same for the notifying process
conn = psycopg2.connect(host="localhost", dbname="example", user="example", password="example")
conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
cursor = conn.cursor()
cursor.execute(f"LISTEN match_updates;")
@alin23
alin23 / main.rs
Last active January 27, 2018 09:56
Benchmark gauss sum volume
#![feature(test)]
extern crate test;
fn gauss_sum(sequence_size: u16, first_element: u16, increment: u16) -> u16 {
if sequence_size == 0 {
return first_element;
}
let last_element = first_element + increment * (sequence_size - 1);
sequence_size * (first_element + last_element) / 2
}