Skip to content

Instantly share code, notes, and snippets.

/* Trivial keyboard input layout to english switcher by Alexander V. Zhouravlev.
* Compile it with gcc -framework Carbon -o SwitchToEnglish SwitchToEnglish.m */
#import <Carbon/Carbon.h>
int main (int argc, const char *argv[])
{
TISInputSourceRef english = TISCopyInputSourceForLanguage(CFSTR("en-US"));
if (!english)
return 1;
@bofh
bofh / test.m
Created October 28, 2011 19:11
Exploring @defs replacement in ObjC 2.0
/*
* Compile with gcc -framework Foundation
*/
#import <Foundation/Foundation.h>
struct internals {
int a;
int b;
};
@bofh
bofh / collections.m
Created November 19, 2011 18:12
Syntax sugar idea for collections in ObjC 2.0
/*
* Syntax sugar for collections
* [overlap :@"key"].integer = 0;
*
* gcc -framework Foundation collections.m
*
*/
#import <Foundation/Foundation.h>
@bofh
bofh / lang.py
Created October 15, 2012 11:52
learning words
# -*- coding: utf-8 -*-
# Name files like: L12-14 foreign translation.wav
import re, os, sys, tempfile, shutil
from subprocess import call
class Word:
filename = ""
def __init__(self, filename):
self.filename = filename
int ledState = 0;
int laserState = 0;
long prevTime = 0;
void setup()
{
// laser on A0
pinMode(A0, OUTPUT);
digitalWrite(A0, LOW);
(require '[bidi.ring :refer (make-handler)])
(require '[ring.util.response :refer (response)])
(def route-table ["/index.html" :index])
(defn index-page [request]
(response "Hi!"))
(def handler-map
{:index index-page})
import Foundation
import Darwin
func readInt() -> Int {
var res: Int = 0
withUnsafePointer(&res) {
vscanf("%d", getVaList([COpaquePointer($0)]))
}
return res
}
@bofh
bofh / libra2hdo.py
Last active November 28, 2015 12:18
import pandas as pd
def read_libra(path):
data = pd.read_csv(path, skiprows=3, sep=';')
data.rename(columns={'#date':'date'}, inplace=True)
return data
def read_hdo(path):
tmp = pd.read_csv(path, encoding='latin-1', nrows=5, header=4)
cols = tmp.columns
#![deny(unsafe_code)]
#![deny(warnings)]
#![no_std]
extern crate cortex_m;
extern crate embedded_hal as ehal;
extern crate stm32f30x_hal as hal;
mod beeper;
#[export_name = "_reset"]
pub unsafe extern "C" fn reset() -> ! {
asm!("
cpsie i\n
movw r0, 0xd800\n
movt r0, 0x1fff\n
ldr r0, [r0]\n
msr MSP, r0" ::: "r0" : "volatile");
let f = 0x1FFFD804u32 as *const fn();
(*f)();