Skip to content

Instantly share code, notes, and snippets.

View Katharine's full-sized avatar

Katharine Berry Katharine

View GitHub Profile
def largest_key(d):
k = None
largest = 0
for i in d:
if d[i] > largest:
largest = d[i]
k = i
return k
@Katharine
Katharine / link-hunspell.diff
Created April 25, 2012 18:53
Fix Darwin libhunspell.dylib linking (STORM-276)
@Katharine
Katharine / ai.cpp
Created May 12, 2012 16:20
Noughts and Crosses for netbyte
#include "ai.h"
ai::ai(tictactoe &game, tictactoe::player_t player) : m_game(game), m_player(player) { }
void ai::move() {
// All of these methods return true on success, thus the pile of ifs.
if(try_win()) return;
if(try_block()) return;
if(try_fork()) return;
if(try_block_fork()) return;
@Katharine
Katharine / clobber.c
Created May 16, 2012 18:11
Clobber i by overflowing s
#include <stdio.h>
struct foo {
char s[4];
int i;
};
int main() {
struct foo f;
f.i = 10;
diff -r 39932e2ec204 indra/newview/exonotificationmanager.cpp
--- a/indra/newview/exonotificationmanager.cpp Fri Aug 03 07:52:38 2012 -0400
+++ b/indra/newview/exonotificationmanager.cpp Sat Aug 04 00:00:13 2012 -0400
@@ -39,6 +39,8 @@
// Platform-specific includes
#ifdef LL_DARWIN
#include "exonotifiermacosx.h"
+#elif LL_LINUX
+#include "exonotifierlinux.h"
#endif
@Katharine
Katharine / gist:5597329
Created May 17, 2013 06:38
httpebble local cookie demo.
#include "pebble_os.h"
#include "pebble_app.h"
#include "pebble_fonts.h"
#include "http.h"
#include "itoa.h"
#define COUNTER_COOKIE 1
PBL_APP_INFO_SIMPLE(HTTP_UUID, "Counter Demo", "Demo Corp", 1 /* App version */);
Window window;
@Katharine
Katharine / http_demo.c
Created May 25, 2013 21:01
Simplest possible HTTP demo.
#include "pebble_os.h"
#include "pebble_app.h"
#include "pebble_fonts.h"
#include "http.h"
PBL_APP_INFO_SIMPLE(HTTP_UUID, "HTTP Demo", "Demo Corp", 1 /* App version */);
Window window;
TextLayer textLayer;
@Katharine
Katharine / gist:5677054
Created May 30, 2013 10:44
Demo program that breaks text. Move it left and right with the up and down keys.
#include "pebble_os.h"
#include "pebble_app.h"
#include "pebble_fonts.h"
#define MY_UUID { 0xFC, 0xF3, 0xC3, 0xF1, 0xBC, 0xE4, 0x48, 0x3D, 0x92, 0x48, 0x79, 0x97, 0xAC, 0xC7, 0x2F, 0x7F }
PBL_APP_INFO_SIMPLE(MY_UUID, "Text Rendering Error", "Demo Corp", 1 /* App version */);
Window window;
@Katharine
Katharine / anim_schedule.c
Created May 30, 2013 11:24
This code will crash your watch.
#include "pebble_os.h"
#include "pebble_app.h"
#include "pebble_fonts.h"
#define MY_UUID { 0xF7, 0x58, 0xEF, 0x93, 0x27, 0xBB, 0x4F, 0x0E, 0x93, 0x9A, 0x8F, 0x6A, 0xF1, 0x6F, 0x0A, 0x63 }
PBL_APP_INFO(MY_UUID,
"Animation Crash", "Your Company",
1, 0, /* App version */
DEFAULT_MENU_ICON,
@Katharine
Katharine / gist:8432720
Created January 15, 2014 08:31
Linting failure report.
Setting top to : /tmp/tmpj7gnmZ
Setting out to : /tmp/tmpj7gnmZ/build
Checking for program gcc,cc : arm-none-eabi-gcc
Checking for program ar : arm-none-eabi-ar
Found Pebble SDK in : /home/vagrant/sdk2/Pebble
'configure' finished successfully (0.030s)
Waf: Entering directory `/tmp/tmpj7gnmZ/build'
Traceback (most recent call last):
File "/home/vagrant/sdk2/Pebble/.waf-1.7.11-e248e7c2ab5100c227e21b0fb258ca96/waflib/Scripting.py", line 97, in waf_entry_point
run_commands()