Skip to content

Instantly share code, notes, and snippets.

View rcoh's full-sized avatar

Russell Cohen rcoh

View GitHub Profile
@rcoh
rcoh / post1complete.nut
Last active August 29, 2015 14:00
Complete code after Post 1
// Adapted from:
// http://techgurka.blogspot.com/2013/04/quick-temperature-graph-using-electric.html
class TemperatureSensor {
i2cPort = null;
constructor(port) {
i2cPort = port;
i2cPort.configure(CLOCK_SPEED_100_KHZ);
}
// Retrieve temperature (from local sensor) in deg F
@rcoh
rcoh / tmp102.nut
Last active August 29, 2015 14:00
TMP 102 Electric IMP i2c
// Adapted from:
// http://techgurka.blogspot.com/2013/04/quick-temperature-graph-using-electric.html
class TemperatureSensor {
i2cPort = null;
constructor(port) {
i2cPort = port;
i2cPort.configure(CLOCK_SPEED_100_KHZ);
}
// Retrieve temperature (from local sensor) in deg F
@rcoh
rcoh / therm.nut
Last active August 29, 2015 14:00
setPoint <- 68;
function updateTemp() {
// Read the ambient temperature
temp <- readTemp();
// If it's below what it should be, turn on the heat.
if (temp < setPoint) {
heatOn();
} else {
@rcoh
rcoh / nothrowable.scala
Created April 18, 2014 23:41
Why you should never catch throwable.
def inlineme(f: => Int): Int = {
try {
f
inlineme {
return 0
}
} catch {
case ex: Throwable => println(ex); return 1
}
}
@rcoh
rcoh / inkenablesimple.m
Created August 13, 2013 06:54
Ink Enable, nondynamic
INKBlob *blob = [INKBlob blobFromData:content];
blob.uti = @"public.png"
[myView INKEnableWithBlob:blob];
@rcoh
rcoh / actions.json
Last active December 20, 2015 03:29
Update actions.json
{
"actions": [
{...},
{...},
{
"id": 2,
"uuid": "abcdefg",
"name": "Sign in PDFSign",
"call_to_action": "Sign",
"description": "This will save a file",
@rcoh
rcoh / returntoacaller.m
Last active December 20, 2015 03:29
Return to calle
if ([INK appShouldReturn]) {
// 3 choices (choose 1)
// Return with data unchanged
[Ink return];
// Return with updated data
[INK returnBlob:newBlob];
// Return with error: (You must indicate to the user what went wrong before calling this)
@rcoh
rcoh / registeractions.m
Last active December 20, 2015 03:29
Registering actions for Ink
// Get the UUID for your action from the developer portal
INKAction *store = [INKAction actionWithUUID:@"store-asdfasd-sdfads"];
[Ink registerAction:store withTarget:self selector:@selector(storeBlob:action:error:)];
@rcoh
rcoh / actions.json
Created July 23, 2013 17:12
New actions for actions.json
{
"actions": [ … ],
"leftActions": [
{...},
{...},
{
"id": 4,
"uuid": "abcdefg",
"name": "Return to Frame",
"call_to_action": "Return",
@rcoh
rcoh / registeraction.m
Created July 23, 2013 17:11
Register Action for Ink
INKAction *returnAction = [INKAction action:@"Return" type:INKActionType_Return];
[INKCore registerAction:returnAction withBlock:^(INKBlob *blob, NSError *error) {
NSLog(@"Return");
//Code to handle the returned blob
}];
INKAction *returnCancelAction = [INKAction action:@"ReturnCancel" type:INKActionType_ReturnCancel];
[INKCore registerAction:returnCancelAction withBlock:^(INKBlob *blob, NSError *error) {
NSLog(@"Return Cancel");
}];