Skip to content

Instantly share code, notes, and snippets.

@bakkot
bakkot / horrifying.js
Last active December 17, 2022 18:02
Various really bad JavaScript
(function x(){"use strict"; x = 1;}()); // TypeError
(function x(){x = 1; return x !== 1;}()); // write fails silently; function returns true
(function x(){"use strict"; x = (function(){throw 0;})();})() // Error 0
// These three lines rely on ES6.
(function x(){const x = 1;})() // No-op. In particular, not a redeclaration of x.
(function (){"use strict"; const x = 1; x = 2;})() // TypeError
(function (){const x = 1; x = 2;})() // TypeError. contrast (function x(){x = 2;}());
@paf31
paf31 / unsession.md
Last active August 29, 2015 14:06
PureScript Unsession
@dherman
dherman / node.c
Created July 18, 2013 23:48
A lightweight implementation of node.js
#include <stdio.h>
int main() {
int *p = 0;
char line[1024];
printf("> ");
fgets(line, 1024, stdin);
*p = 12;
@michaelficarra
michaelficarra / levels.coffee
Last active December 17, 2015 00:49
identifier-only scope colouring levels
fs = require 'fs'
esprima = require 'esprima'
escope = require 'escope'
eslevels = require 'eslevels'
js = (fs.readFileSync './input.js').toString()
ast = esprima.parse js, {range: yes}
scopes = (escope.analyze ast).scopes
@michaelficarra
michaelficarra / task.coffee
Created December 6, 2012 06:03
comonadic futures on top of Q
Q = require './q'
class exports.Task
constructor: (@promise) ->
value: null
reason: null
result: ->
unless @promise.isResolved()
@alexspeller
alexspeller / source_maps.rb
Created September 16, 2012 00:03
Coffeescript Source Maps in Rails
# config/initializers/source_maps.rb
if Rails.env.development?
require 'open3'
module CoffeeScript
class SourceMapError < StandardError; end;
class << self
def map_dir
var module = (function (exports) {
var NameSequence,
ZeroSequenceCache;
NameSequence = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
ZeroSequenceCache = [];
function stringRepeat(str, num) {
var result = '';
@michaelficarra
michaelficarra / CoffeeScriptIdioms.vim
Created May 17, 2012 22:47
vim substitutions for cleaning up coffeescript projects
:%s/[\r \t]\+$//
:%s/() ->/->/c
:%s/if \!/unless /c
:%s/;$//c
:%s/^\(\s*\)\(@\?[a-z0-9$_]\+\)()/\1do \2/ic
:%s/\!==?/isnt/c
:%s/===\?/is/c
:%s/\([a-z0-9$_]\)(\([^)]\+\))$/\1 \2/ic
:%s/true/yes/c
:%s/false/no/c
@paulmillr
paulmillr / active.md
Last active April 23, 2024 17:32
Most active GitHub users (by contributions). http://twitter.com/paulmillr

Most active GitHub users (git.io/top)

The count of contributions (summary of Pull Requests, opened issues and commits) to public repos at GitHub.com from Wed, 21 Sep 2022 till Thu, 21 Sep 2023.

Only first 1000 GitHub users according to the count of followers are taken. This is because of limitations of GitHub search. Sorting algo in pseudocode:

githubUsers
 .filter(user =&gt; user.followers &gt; 1000)
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#