Skip to content

Instantly share code, notes, and snippets.

@watmough
watmough / gist:0a11ecc424799ea5557901fe0bd9418c
Last active December 15, 2016 04:36
Silver Dollar Game in Rust
extern crate rand;
use rand::Rng;
use std::io;
// From "Practical Programs for the BBC Computer and Acorn ATOM"
// (c) David Johnson-Davies
// Sigma Technical Press 1983
// Silver Dollar Game
// http://www.acornatom.nl/atom_plaatjes/boeken/pracprog/pp.htm
@watmough
watmough / FCPrivateBatteryStatus.m
Created January 30, 2016 00:03
How to get raw battery info (mAh remaining, etc.) from iOS using private APIs. For internal testing only, NOT APP STORE DISTRIBUTION!
#import <Foundation/Foundation.h>
#include <dlfcn.h>
NSDictionary *FCPrivateBatteryStatus()
{
static mach_port_t *s_kIOMasterPortDefault;
static kern_return_t (*s_IORegistryEntryCreateCFProperties)(mach_port_t entry, CFMutableDictionaryRef *properties, CFAllocatorRef allocator, UInt32 options);
static mach_port_t (*s_IOServiceGetMatchingService)(mach_port_t masterPort, CFDictionaryRef matching CF_RELEASES_ARGUMENT);
static CFMutableDictionaryRef (*s_IOServiceMatching)(const char *name);
@watmough
watmough / Add Web Tab.py
Created January 13, 2016 23:45 — forked from steventroughtonsmith/Add Web Tab.py
Insert a custom browser tab into Pythonista
# coding: utf-8
from Foundation import *
from QuartzCore import *
from UIKit import *
import console
WKWebView = ObjCClass('WKWebView')
@on_main_thread
@watmough
watmough / pascal2.c
Created January 6, 2012 05:18
Better C implementation for Pascals Triangle
/*
* Pascal2.c
*
* Pascals Triangle in C
*
* See notes below.
* To run:
gcc -std=c99 pascal2.c -o pascal2 && ./pascal2 10
*/
@watmough
watmough / pascal.c
Created January 5, 2012 23:00
Display a line of Pascals Triangle
/*
* Pascals Triangle in C
*
* Hacker News: http://news.ycombinator.com/item?id=3428984
*
*/
#include <stdio.h>
#include <stdlib.h>