Skip to content

Instantly share code, notes, and snippets.

View elliotchance's full-sized avatar
🤓
Building awesome stuff with V

Elliot Chance elliotchance

🤓
Building awesome stuff with V
View GitHub Profile
package main
import (
"fmt"
"strings"
"sync"
"time"
)
type ChannelPerf struct {
@leongersen
leongersen / TypeHint.js
Last active October 31, 2021 08:58
Proof of concept for adding type-hinting to JavaScript.
// Set testable values;
window.Type = {
Number: 1,
String: 'a',
Function: function(){}
}
// Add a hint method;
Function.prototype.hint = function(){
@abreckner
abreckner / waitsForAndRuns.js
Created May 9, 2014 01:56
Jasmine 2 plug in to re-enable waitsFor and runs functionality
// This is the equivalent of the old waitsFor/runs syntax
// which was removed from Jasmine 2
waitsForAndRuns = function(escapeFunction, runFunction, escapeTime) {
// check the escapeFunction every millisecond so as soon as it is met we can escape the function
var interval = setInterval(function() {
if (escapeFunction()) {
clearMe();
runFunction();
}
}, 1);
@elliotchance
elliotchance / .vimrc
Last active August 7, 2017 01:17
My vimrc
" INSTALL (run this):
" cd ~ && curl -s https://gist.github.com/elliotchance/5801752/download | tar -x --strip-components=1 && cat .vimrc | grep '^\"% ' .vimrc | cut -c 3- | bash
" Lines started with % will be executed on install:
"
"% # install ctags-exuberant
"% if [ ! -f /usr/local/bin/ctags ]; then
"% wget http://prdownloads.sourceforge.net/ctags/ctags-5.8.tar.gz
"% tar -zxf ctags-5.8.tar.gz
"% cd ctags-5.8 && ./configure && make && sudo make install && sudo rm -f /usr/bin/ctags && sudo ln -s /usr/local/bin/ctags /usr/bin/ctags && cd ..

The Scope class regulates lexical scoping within CoffeeScript. As you generate code, you create a tree of scopes in the same shape as the nested function bodies. Each scope knows about the variables declared within it, and has a reference to its parent enclosing scope. In this way, we know which variables are new and need to be declared with var, and which are shared with the outside.

Import the helpers we plan to use.

{extend, last} = require './helpers'