Skip to content

Instantly share code, notes, and snippets.

View rubyist's full-sized avatar

Scott Barron rubyist

View GitHub Profile
@rubyist
rubyist / structure.m
Created September 5, 2012 12:45
Basic structure
objectManager = [RKObjectManager managerWithBaseURLString:kAPIBaseURL];
objectStore = [RKManagedObjectStore objectStoreWithStoreFilename:kDataStore];
objectManager.objectStore = objectStore;
// Set up object mappings, relationships, etc. e.g.
RKObjectMapping *collectionMapping = [Item mappingInStore:objectStore];
// Pagination mapping
RKObjectMapping *paginationMapping = [RKObjectMapping mappingForClass:[RKObjectPaginator class]];
[paginationMapping mapKeyPath:@"pagination.page" toAttribute:@"currentPage"];
@rubyist
rubyist / searchy.html
Last active February 19, 2017 21:39
How one might filter a list in meteor
<head>
<title>searchy</title>
</head>
<body>
{{> searchy}}
</body>
<template name="searchy">
<h1>Searchy</h1>
@rubyist
rubyist / client.js
Created May 30, 2013 15:35
I have a Meteor app that authenticates against Google for logging in. I also have a cucumber suite that runs against the app and I don't want it to go through the Google auth. This setup will check a KIT_ENV environment variable, and if it is "test" (i.e. being run for the cucumber suite) it will just run an anonymous login and setup a default u…
var attemptLogin = function() {
var validateResult = function(e, result) {
if (e) {
Meteor.loginWithGoogle();
}
};
Accounts.callLoginMethod({methodArguments: [{}], userCallback: validateResult});
};
@rubyist
rubyist / caveatPatchor.js
Created June 14, 2013 17:48
Put this in ~/Library/Application Support/Propane/unsupported/caveatPatchor.js
function sayIt(msg) {
message = this.chat.transcript.insertPendingMessage(msg);
new Campfire.OutgoingMessage(this.chat, message, msg, '').send();
this.chat.dispatch('messageSpoken', message);
}
Campfire.Speaker.Filters.push(
function(message) {
if(message.match(/^\/soundlist\s*$/)) {
var soundList = [];
@rubyist
rubyist / waves.m
Last active December 21, 2015 02:08
Generate different kinds of wave forms
long maxSampleCount = SAMPLE_RATE * DURATION;
long sampleCount = 0;
UInt32 bytesToWrite = 2;
double wavelengthInSamples = SAMPLE_RATE / hz;
while (sampleCount < maxSampleCount) {
// for (int i = 0; i < wavelengthInSamples; i++) {
// // Square wave
// SInt16 sample;
// if (i < wavelengthInSamples/2) {
@R2 // A = 2
M=0 // Memory[2] = 0
(LOOP)
@R1 // A = 1
M=M-1 // Memory[1] = Memory[1] - 1
D=M // D = Memory[1]
@END
D;JLT // Jump to @END if D < 0
@R0 // A = 0
D=M // D = Memory[0]
(START)
@SCREEN
D=A
@cur
M=D // Sets CUR to SCREEN
(LOOP)
@KBD // read from keyboard, 0=nothing pressed
D=M
@rubyist
rubyist / get_some.go
Created December 10, 2013 16:47
GET some
package main
import (
"fmt"
"io"
"net/http"
"os"
"strconv"
"sync"
)
@rubyist
rubyist / best.ino
Last active January 1, 2016 05:39
"You're The Best" from Karate Kid. Patches for accuracy welcome.
const int buzzerPin = 6;
// Trick these 4 out for accuracy
const int songLength = 17;
char notes[] = "efg dab bbbbbaagg";
int beats[] = {1,2,5,3,2,4,2,5,2,2,2,2,3,3,3,3,2};
int tempo = 90;
// Boom. Gold.
@rubyist
rubyist / button.ino
Last active January 3, 2016 02:09
Timing an interrupt driven button
#define LONGPRESS_TIME 1000 // 1 second
volatile int trackButton = 0;
volatile unsigned long buttonChangeMillis = 0;
void setup() {
attachInterrupt(0, buttonPressed, CHANGE);
}
void buttonPressed()