Skip to content

Instantly share code, notes, and snippets.

View jdrew1303's full-sized avatar
probably drinking coffee

James Drew jdrew1303

probably drinking coffee
View GitHub Profile
@jdrew1303
jdrew1303 / 0_reuse_code.js
Created March 25, 2014 10:17
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
import com.google.caliper.Runner;
import com.google.caliper.SimpleBenchmark;
import java.util.HashSet;
import java.util.TreeSet;
public class SetBenchmark extends SimpleBenchmark {
// If you add a main function, you can run it from your IDE.
public static void main(String[] args) throws Exception {
new Runner().run(
@jdrew1303
jdrew1303 / designer.html
Created January 25, 2015 03:38
designer
<link rel="import" href="../ace-element/ace-element.html">
<link rel="import" href="../core-input/core-input.html">
<link rel="import" href="../paper-button/paper-button.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
@jdrew1303
jdrew1303 / recog.js
Last active August 29, 2015 14:22 — forked from addyosmani/recog.js
r = new webkitSpeechRecognition;
r.continuous = true;
r.interimResults = true;
r.onresult = function(ev) {
console.log(ev.results[ev.results.length-1][0].transcript);
};
r.start()
# Start an HTTP server from a directory, optionally specifying the port
function server() {
local port="${1:-8000}"
open "http://localhost:${port}/"
# Set the default Content-Type to `text/plain` instead of `application/
# And serve everything as UTF-8 (although not technically correct, this
python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTP
}
@jdrew1303
jdrew1303 / Readme.md
Last active August 29, 2015 14:22 — forked from addyosmani/Readme.md

stopBefore.js

2min screencast

Examples

stopBefore(document, 'getElementById')
stopBefore('document.getElementById') // the same as the previous
stopBefore(Element.prototype, 'removeChild')
@jdrew1303
jdrew1303 / Grep.js
Last active August 29, 2015 14:22 — forked from addyosmani/Grep.js
/*
Grep.js
Author : Nic da Costa ( @nic_daCosta )
Created : 2012/11/14
Version : 0.2
(c) Nic da Costa
License : MIT, GPL licenses
Overview:
Basic function that searches / filters any object or function and returns matched properties.

#If you're on Ubuntu or working with a Linux VM...

Step 1: Install the Ubuntu dependencies needed:

SSH into your server as a root or do sudo -i.

Then install necessary software:

apt-get update
/* Cranium MVC
* A minimalist MVC implementation written for
* demonstration purposes at my workshops
* http://addyosmani.com
* Copyright (c) 2012 Addy Osmani; Licensed MIT */
var Cranium = Cranium || {};
// Set DOM selection utility
var timeUntil = {
inHours: function(d1, d2) {
return parseInt((d2.getTime()-d1.getTime())/(24*3600), 10);
},
inDays: function(d1, d2) {
return parseInt((d2.getTime()-d1.getTime())/(24*3600*1000), 10);
},