Skip to content

Instantly share code, notes, and snippets.

@davesmylie
davesmylie / gist:5476146
Last active December 16, 2015 18:09
calling function makes pebble crash
void draw_text_layer(TextLayer *layer) {
text_layer_init(layer, GRect(120,30,30,40));
layer_add_child(&window.layer, layer.layer);
}
void handle_init_app(AppContextRef ctx) {
(void)ctx;
window_init(&window, "Window Name");
@davesmylie
davesmylie / gist:5430368
Created April 21, 2013 17:32
pyobjc-core pip install
~/code/pebble/pebble-sdk/pulse (master ✘)✖✹✭ ᐅ sudo pip install pyobjc-core
dyld: DYLD_ environment variables being ignored because main executable (/usr/bin/sudo) is setuid or setgid
Password:
Downloading/unpacking pyobjc-core
Running setup.py egg_info for package pyobjc-core
warning: no directories found matching 'Scripts'
warning: no directories found matching 'setup-lib'
warning: no directories found matching 'source-deps'
warning: no previously-included files matching '.DS_Store' found anywhere in distribution
/code/pebble/pebble-sdk/pulse (master ✘)✖✹✭ ᐅ sudo pip install pyobjc
dyld: DYLD_ environment variables being ignored because main executable (/usr/bin/sudo) is setuid or setgid
Requirement already satisfied (use --upgrade to upgrade): pyobjc in /Library/Python/2.7/site-packages/pyobjc-2.5.1-py2.7.egg
Downloading/unpacking pyobjc-core==2.5.1 (from pyobjc)
Running setup.py egg_info for package pyobjc-core
warning: no directories found matching 'Scripts'
warning: no directories found matching 'setup-lib'
warning: no directories found matching 'source-deps'
warning: no previously-included files matching '.DS_Store' found anywhere in distribution
@davesmylie
davesmylie / gist:5427113
Created April 20, 2013 19:37
pebble issues using mini_snprintf from https://github.com/mludvig/mini-printf. Instead of displaying "Test: 5", I get a single small square char
void handle_init(AppContextRef ctx) {
(void)ctx;
char str[100];
// create our formatted string
mini_snprintf(str, 20, "Test: %d", 5);
window_init(&window, "Demo");
window_stack_push(&window, true /* Animated */);
@davesmylie
davesmylie / gist:3418191
Created August 21, 2012 18:32
jquery issues
// this is firing on each ajaxSubmit once per form on the page - not just once for the current form.
$('form').ajaxStart(function(e) {
console.log("element is " + ($(e).attr('id')));
return $(e).addClass('submitting');
}).ajaxComplete(function(e) {
$("input").removeAttr("disabled");
return $('form.submitting').removeClass('submitting');
});
@davesmylie
davesmylie / gist:3109697
Created July 14, 2012 06:22
H2DP2E Exercise 177
See http://htdp2e.blogspot.com.au/2012/07/exercise-177-modify-program-from.html
Exercise 177: Modify the program from exercise 176 so that a player can control the left or right movement of the dropping block. Each time the player presses the "left" arrow key, the dropping block should shift one column to the left unless it is in column 0 or there is already a stack of resting blocks to its left. Similarly, each time the player presses the "right" arrow key, the dropping block should move one column to the right if possible.
(require racket/base)
(define-struct block (x y) #:transparent)
(define-struct tetris (block landscape))
; physical constants
(define WIDTH 10) ; the maximal number of blocks horizontally
@davesmylie
davesmylie / gist:3044599
Created July 4, 2012 01:27
how to design programs 2nd edition. Code Solution For Exercise 176
;See http://htdp2e.blogspot.co.nz/2012/07/exercise-176-design-interactive-program.html
(require racket/base)
; The struct block contains the blocks that make up landscape and the
; current falling block. We need to define this struct as transparent or
; the member? function won't be able to look inside it.
(define-struct block (x y) #:transparent)
@davesmylie
davesmylie / gist:3036890
Created July 3, 2012 01:24
H2DP2E: Exercise 175
; See http://htdp2e.blogspot.co.nz/2012/07/exercise-175-design-program-tetris.html
(define-struct block (x y))
(define-struct tetris (block landscape))
 
; physical constants
(define WIDTH 10) ; the maximal number of blocks horizontally
; graphical constants
(define SIZE 10) ; blocks are square
@davesmylie
davesmylie / gist:3008089
Created June 28, 2012 01:21
H2DP2E: Exercise 174
; How to design programs 2nd ed. Question 174
; See http://htdp2e.blogspot.co.nz/2012/06/exercise-174-equip-your-program-from.html
; Constants
(define WORM-SIZE 10)
(define WORM-MOVE (* WORM-SIZE 2))
(define WIDTH 800) ; width of the game
(define HEIGHT 500) ; height of the game
@davesmylie
davesmylie / htdp2e Exercise 173
Created May 29, 2012 01:57
htdp2e Exercise 173
; Constants
(define WORM-SIZE 10)
(define WORM-MOVE (* WORM-SIZE 2))
(define WIDTH 800) ; width of the game
(define HEIGHT 500) ; height of the game
(define SEGMENT (circle WORM-SIZE "solid" "red"))
; these structs hold the current list of worm segments, the direction