Skip to content

Instantly share code, notes, and snippets.

@joscha
joscha / DS1307.cpp
Last active May 14, 2016 06:38 — forked from technobly/sparkDS1307.cpp
RTC DS1307 LIBRARY FOR SPARK CORE
#include "application.h"
#include "DS1307.h"
const uint8_t daysInMonth[13] = {
31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};
// number of days since 2000/01/01, valid for 2001..2099
static uint16_t date2days(uint16_t y, uint8_t m, uint8_t d) {
if (y >= 2000)
function prettifySpreadsheetJSON(data) {
var prefix = 'gsx$';
for (var i = 0; i < data.feed.entry.length; i++) {
for (var key in data.feed.entry[i]) {
if (data.feed.entry[i].hasOwnProperty(key) && key.substr(0,prefix.length) === prefix) {
data.feed.entry[i][key.substr(prefix.length)] = data.feed.entry[i][key].$t;
delete data.feed.entry[i][key];
}
}
}
@joscha
joscha / install_bcm2385.sh
Last active August 29, 2015 14:13 — forked from annem/gist:3183536
Install BCM2385 library
#!/bin/sh
set -o errexit
bcm2385_version=1.38
rm bcm2835-$bcm2385_version.tar.gz
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-$bcm2385_version.tar.gz
tar zxvf bcm2835-$bcm2385_version.tar.gz
cd bcm2835-$bcm2385_version
./configure
make
@joscha
joscha / bower.json
Last active August 29, 2015 14:07 — forked from Xiphe/bower.json
{
"name": "jasmine-moar-matchers",
"authors": [
"Hannes Diercks"
],
"description": "Some additional Jasmine 2.0 Matchers.",
"main": ["toBeInstanceOf.js", "toBeTypeOf.js", "promises.js"],
"keywords": [
"jasmine",
"matcher"
// jQuery Deparam - v0.1.0 - 6/14/2011
// http://benalman.com/
// Copyright (c) 2011 Ben Alman; Licensed MIT, GPL
(function($) {
// Creating an internal undef value is safer than using undefined, in case it
// was ever overwritten.
var undef;
// A handy reference.
var decode = decodeURIComponent;

From Meteor's documentation:

In Meteor, your server code runs in a single thread per request, not in the asynchronous callback style typical of Node. We find the linear execution model a better fit for the typical server code in a Meteor application.

This guide serves as a mini-tour of tools, trix and patterns that can be used to run async code in Meteor.

Basic async

Sometimes we need to run async code in Meteor.methods. For this we create a Future to block until the async code has finished. This pattern can be seen all over Meteor's own codebase:

From Meteor's documentation:

In Meteor, your server code runs in a single thread per request, not in the asynchronous callback style typical of Node. We find the linear execution model a better fit for the typical server code in a Meteor application.

This guide serves as a mini-tour of tools, trix and patterns that can be used to run async code in Meteor.

Basic async

Sometimes we need to run async code in Meteor.methods. For this we create a Future to block until the async code has finished. This pattern can be seen all over Meteor's own codebase:

function substitute {
if [ -z "$1" -o -z "$2" ]; then
echo "Usage: substitue FROM_STRING TO_STRING [OPTION]..."
echo
echo "Replace all occurances of FROM_STRING (a sed-compatible regular"
echo "expression) with TO_STRING in all files for which ack-grep matches"
echo "FROM_STRING."
echo
echo "Any additional options are passed directly to ack-grep (e.g.,"
echo " --type=html would only run the substitution on html files)."
#!/bin/bash
if [ -z "$1" -o -z "$2" ]; then
echo "Usage: substitue FROM_STRING TO_STRING [OPTION]..."
echo
echo "Replace all occurances of FROM_STRING (a sed-compatible regular"
echo "expression) with TO_STRING in all files for which ack matches"
echo "FROM_STRING."
echo
echo "Any additional options are passed directly to ack (e.g.,"
@joscha
joscha / meteor-async.md
Last active August 29, 2017 06:51 — forked from possibilities/meteor-async.md
Meteor Async Guide

From Meteor's documentation:

In Meteor, your server code runs in a single thread per request, not in the asynchronous callback style typical of Node. We find the linear execution model a better fit for the typical server code in a Meteor application.

This guide serves as a mini-tour of tools, trix and patterns that can be used to run async code in Meteor.

Basic async

Sometimes we need to run async code in Meteor.methods. For this we create a Future to block until the async code has finished.