Skip to content

Instantly share code, notes, and snippets.

@thatmarvin
thatmarvin / machine.js
Created November 25, 2020 03:14
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@thatmarvin
thatmarvin / overcastfm-keyboard-shortcuts.user.js
Last active September 16, 2015 08:26
Overcast.fm Keyboard Shortcuts
// ==UserScript==
// @name Overcast.fm Keyboard Shortcuts
// @namespace http://your.homepage/
// @version 0.2
// @description Space bar to play/pause, left/right arrow to seek forward/backward.
// @author @thatmarvin
// @match https://overcast.fm/+*
// @grant none
// ==/UserScript==
@thatmarvin
thatmarvin / interval-provider-patch.js
Last active August 29, 2015 14:10
Patches Angular 1.2.x's $interval with fix from 1.3.x
/**
* The following is stolen from the patch that landed in 1.3.0-beta.13:
* https://github.com/angular/angular.js/pull/7999
*
* Remove this if upgraded to Angular 1.3.x.
*/
(function () {
'use strict';
@thatmarvin
thatmarvin / test-ui-router.html
Created November 17, 2014 19:38
ui.router erroring out in IE8
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="//code.angularjs.org/1.2.25/angular.js"></script>
<script src="//rawgit.com/angular-ui/ui-router/0.2.12/release/angular-ui-router.js"></script>
<script>
angular.module('fooApp', [
'ui.router'
module.exports = function (grunt) {
grunt.initConfig({
stylus: {
compile: {
options: {
compress: true,
use: [ require('bootstrap.stylus') ]
},
files: [{
expand: true,
angular.module("ui.bootstrap", ["ui.bootstrap.tpls", "ui.bootstrap.position","ui.bootstrap.tooltip","ui.bootstrap.popover"]);
angular.module("ui.bootstrap.tpls", ["template/tooltip/tooltip-html-unsafe-popup.html","template/tooltip/tooltip-popup.html","template/popover/popover.html"]);
angular.module('ui.bootstrap.position', [])
/**
* A set of utility methods that can be use to retrieve position of DOM elements.
* It is meant to be used where we need to absolute-position DOM elements in
* relation to other, existing elements (this is the case for tooltips, popovers,
* typeahead suggestions etc.).
*/
@thatmarvin
thatmarvin / setter-test.js
Created April 19, 2013 22:17
Setter isn't invoked when value === null
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var assert = require('assert');
mongoose.connect('mongodb://localhost/test');
var OrderSchema = new Schema({
total: {
type: Number,
var Q = require('q');
require('should');
require('mocha-as-promised')();
// This pretends to be the API client
function get(url) {
var deferred = Q.defer();
if (url === '/1') {
deferred.resolve([
'use strict';
var express = require('express')
, app = module.exports = express.createServer();
// Configuration
app.configure(function () {
app.use(app.router);
});
@thatmarvin
thatmarvin / postageapp.js
Created February 21, 2013 22:43
Demonstrating HTTP 500 response from PostageApp
/*
Remember to fill in your API key.
usage: node postageapp.js [email protected]
*/
var apiKey = 'FILL IN YOUR API KEY HERE',
postageapp = require('postageapp')(apiKey),
recipient = process.argv[2];