Skip to content

Instantly share code, notes, and snippets.

@joscha
joscha / run_raopx.applescript
Created April 23, 2010 22:59 — forked from sumbach/run_raopx.applescript
added temporary file deletion
-- TODO: save as a bundle and include the RaopX application: not sure if I can do that since it also contains libsamplerate
-- For German OSX
set SoundPrefName to "Ton"
set InputPanelName to "Eingabe"
set OutputPanelName to "Ausgabe"
-- For English OSX uncomment this
-- set SoundPrefName to "Sound"
-- set InputPanelName to "Input"
@joscha
joscha / d2-Network-shutdown.py
Created April 24, 2010 23:17
Script for shutting down LaCie d2 Network version 1
#!/usr/bin/env python
''' Script for automatically shutting down LaCie d2 Network version 1
Tested with system version 2.2.5, but might also work on others '''
import crypt, sys, hmac, urllib, urllib2, cookielib
from xml.dom.minidom import parseString
''' Your user name '''
USER = u"admin"
@joscha
joscha / mount.sh
Created August 11, 2012 14:10
Shell file for mounting an encfs volume in OSX by using the keychain password
#!/bin/bash
target=/Volumes/tmp.mytarget
source=/Users/bla/Dropbox/encrypted
volname=EncodedDropbox
keychainPassword=encodedDropbox
mount | grep $target >/dev/null
[[ "$?" -eq "0" ]] && diskutil umount force $target
if [ ! -d $target ]
@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.

@joscha
joscha / config.coffee
Last active December 10, 2015 23:48
run with `coffee server`
exports.db =
host: 'localhost'
name: 'example'
exports.db.url = "mongodb://#{exports.db.host}/#{exports.db.name}"
var hash = CryptoJS.HmacSHA1("Message", "Secret Passphrase");
var hashPlusOne = CryptoJS.enc.Hex.parse(BigInteger.parse(hash.toString(),16).add(1).toString(16));
console.log(hash.toString(),hashPlusOne.toString());
@joscha
joscha / factory.coffee
Last active December 17, 2015 18:59
Factory pattern for CommonJS, AMD and Browser
((root, ns, factory) ->
'use strict'
# CommonJS
if typeof exports is 'object' and typeof module is 'object'
module.exports = factory()
# AMD
else if typeof define is 'function' and define.amd
define factory
#!/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.,"
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)."

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: