Skip to content

Instantly share code, notes, and snippets.

@samjoch
samjoch / util.ts
Created August 24, 2020 06:55
sinon sandbox and avajs
import ava, { TestInterface as TestI } from "ava";
import { createSandbox, SinonSandbox } from "sinon";
interface SinonContext {
sandbox: SinonSandbox;
}
export const test = ((test: TestI<SinonContext>): TestI<SinonContext> => {
test.beforeEach(t => {
t.context.sandbox = createSandbox();
@samjoch
samjoch / AVCaptureDevice-playground.swift
Created November 4, 2016 12:00
Playground to capture ios video input stream into a window
import Cocoa
import AVFoundation
import CoreMediaIO
import XCPlayground
var currentDevice: AVCaptureDevice!
var currentName: String!
var currentUUID: String!
var window = NSWindow(contentRect: NSRect(x: 30, y: 30, width: 375, height: 667),
@samjoch
samjoch / gist:28e1e62b49a39000817b
Created March 10, 2015 14:02
Mozilla bind polyfill
// Bind Polyfill
if (!Function.prototype.bind) {
Function.prototype.bind = function(oThis) {
if (typeof this !== 'function') {
// closest thing possible to the ECMAScript 5
// internal IsCallable function
throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');
}
var aArgs = Array.prototype.slice.call(arguments, 1),
PS1="\[\e[1;30m\]<\[\e[0m\]\[\e[33m\]\u\[\e[0m\]\[\e[1;30m\]>:\[\e[0m\]\[\e[35m\]\w\[\e[0m\] \[\e[36m\]\$(vcprompt -f '{%b}')\[\e[0m\] \[\e[1;30m\]$\[\e[0m\] "
@samjoch
samjoch / import-tasks.coffee
Created November 11, 2014 02:35
Import github opened issues in Things.app area tasks
###
# Need a ./.config.json file containing token, repo, area infos
# ie:
# {
# "token": "...",
# "repo": "username/repo",
# "area": "areaname"
# }
###
@samjoch
samjoch / script
Created February 3, 2014 16:59
gecko test update
# build new .mar file in objdir-gecko/dist/b2g-update/b2g-gecko-update.mar
./build.sh gecko-update-full
# save current version of gecko
mv ~/b2g/objdir-gecko/dist/b2g-update/b2g-gecko-update.mar ~/b2g-builds/gecko-custom-name.mar
# make ~/b2g/gecko-custom-name.mar available for device
python tools/update-tools/test-update.py ~/b2g-builds/gecko-custom-name.mar
@samjoch
samjoch / Vagrantfile
Created January 29, 2014 16:45
b2g vm
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
# This script will be run on the first start and it will set up the build
# environment.
# All you need to do afterwards is:
# * vagrant ssh
# * Unplug/Plug the phone; run adb devices to make sure that the phone is