Skip to content

Instantly share code, notes, and snippets.

@dead-claudia
dead-claudia / dummyfinch.py
Created November 23, 2014 13:40
A dummy equivalent implementation for the Finch Robot Python API. Saved me so much hassle in multiple CS assignments.
# Finch Robot API Dummy Implementation
# ====================================
#
# This is simply a dummy API implementation, printing each instruction to the
# console. It has been very faithful in helping me debug multiple CS
# assignments without constantly having to plug in the Finch robot. Various use
# cases I've experienced that this saved me a lot of hassle include sparing me
# from distraction from my 9 year old brother (10 years age difference is
# fun...), being more able to work on this at night, and being able to debug
# without the robot itself being with me.
@dead-claudia
dead-claudia / rmdir-async.ls
Created December 27, 2014 09:42
Recursive rmdir inspired by CoffeeScript implementation from https://gist.github.com/4605986
require! {fs, path}
# Promises simplify things greatly here. This, by default, uses an ES6
# polyfill if a global Promise doesn't exist (either already implemented or
# polyfilled by something else)
if typeof Promise == 'undefined'
require! 'es6-promise': {Promise}
# For other promise libraries...
#require! 'Bluebird': Promise
#require! 'rsvp': {all, Promise}; Promise.all = all
@dead-claudia
dead-claudia / proto.js
Created January 27, 2015 03:57
Object.prototype.__proto__ polyfill for ES6 (if the runtime *doesn't* implement it -- it's technically optional for non-web browsers)
/**
* By Isiah Meadows.
* This code is licensed under CC0 1.0 Universal. You can get a copy of the license at https://creativecommons.org/publicdomain/zero/1.0/legalcode.txt
*/
if (!function (F) {
return {}.__proto__ === Object.prototype; // Also if it's broken
}(function () {}) && Object.getPrototypeOf && Object.setPrototypeOf) {
Object.defineProperty(Object.prototype, '__proto__', {
'get': function () {
@dead-claudia
dead-claudia / Gmail Filter by Search Query.md
Last active December 18, 2023 21:37
Gmail script filter based on search queries

Gmail Filter by Search Query

This program, in the form of a configuration script and a main script, allows for complicated Gmail search queries to be used as filters. It also lets you do more advanced stuff you can't do with ordinary filters, like label based on whether an email contains a specific kind of attachment.

Installing

  1. Go to script.google.com.
  2. Go to File > New > Script File, and type Main as the title for the new script. This will be for the main script.
  3. Delete any pre-filled text in the script file, and copy main.gs from this gist to that file.
  4. Go to File > New > Script File again, and type Config as the title for the new script. This will be for configuration.
@dead-claudia
dead-claudia / polyfill.js
Created June 11, 2015 12:52
Run other languages in the browser as first class citizens (uses MutationObserver with a CSS-based fallback)
/**
* This allows for compile-to-JS languages to run as first-class citizens
* in a browser. Very useful for development and smaller apps. It depends
* on MutationObserver, with a fallback to the deprecated DOM
*
* Usage:
*
* ```js
* installLanguage('text/coffee', CoffeeScript.compile, null, true);
* installLanguage('text/ls', require('livescript').run);
// Uses the m.route.configure plugin in https://gist.github.com/impinball/2e1a78f24f1979f2b7eb
m.route.configure(function () {
return hasLocalStorageToken()
}, function (route) {
return route("/login")
})
@dead-claudia
dead-claudia / mithril-conditional-route.js
Last active October 3, 2016 22:59
Conditional routing for Mithril
;(function (mod) {
if (typeof module === "object" && module != null && module.exports) {
// Node
module.exports = mod
} else if (typeof define === "function" && define.amd) {
// AMD
define("mithril-configure", function () { return mod })
} else if (typeof exports === "object" && exports != null) {
// Other CommonJS
exports.init = mod
@dead-claudia
dead-claudia / example.js
Created September 19, 2015 05:05
Experiment with maybe types, the pipeline operator, and the binding operator, in both LiveScript and proposed JavaScript.
import * as http from "http"
import * as https from "https"
import pipe from "./pipe.js"
import {then, orElse} from "./maybe.js"
const error = message => () => { throw new TypeError(message) }
const is = (obj, type) => typeof obj === type
class Settings {
@dead-claudia
dead-claudia / LICENSE.md
Last active December 11, 2015 11:58
Monadified error-first callbacks in LiveScript, inspired by JS's async-await proposal. Version in JS is for speed.

Copyright (c) 2015, Isiah Meadows

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

@dead-claudia
dead-claudia / observable-map.js
Created November 4, 2015 07:27
Observable Map
export default class ObservableMap extends Map {
constructor(...args) {
super(...args)
this._onSet = new Set()
this._onDelete = new Set()
this._onClear = new Set()
}
onSet(f) {
this._onSet.add(f)