Skip to content

Instantly share code, notes, and snippets.

@mrnugget
mrnugget / parse_fat_arrow_functions_monkey.patch
Last active July 18, 2017 16:19
These changes add support for fat arrow functions to Monkey's parser. E.g. `(a, b) => { a + b }`. The current implementation expects that the body is a block statement, i.e. it needs curly braces.
diff --git src/monkey/ast/ast.go src/monkey/ast/ast.go
index fb30b05..70668a6 100644
--- src/monkey/ast/ast.go
+++ src/monkey/ast/ast.go
@@ -337,3 +337,28 @@ func (hl *HashLiteral) String() string {
return out.String()
}
+
+type FatArrowFunction struct {
@robdodson
robdodson / index.html
Last active October 4, 2023 18:57
Shady DOM example
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<h2>Hello from outside the Shadow DOM!</h2>
@alexlafroscia
alexlafroscia / README.md
Last active August 6, 2018 19:13
Skate.js ShadyCSS Mixin

ShadyCSS Skate.js Mixin

Out of the box, Skate.js doesn't work that well with ShadyCSS. This is a mixin that helps bridge the gap.

Usage

The usage example below assumes you're using a build tool like Webpack to transform a CSS file into a string when loaded.

import Component from 'skatejs';
/**
* ================== angular-ios9-uiwebview.patch.js v1.1.1 ==================
*
* This patch works around iOS9 UIWebView regression that causes infinite digest
* errors in Angular.
*
* The patch can be applied to Angular 1.2.0 1.4.5. Newer versions of Angular
* have the workaround baked in.
*
* To apply this patch load/bundle this file with your application and add a
@rootical
rootical / browserify_watchify_babelify.js
Last active September 23, 2017 16:40
Gulp task example of using Browserify, Watchify, Babelify, Browser Sync, ngAnnoatate with ES6 source maps.
var gulp = require('gulp');
var gulpif = require('gulp-if');
var sourcemaps = require('gulp-sourcemaps');
var util = require('util');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var watchify = require('watchify');
var browserify = require('browserify');
var browserSync = require('browser-sync');
var babelify = require('babelify');
angular.module('lib.decorators', [])
.config(['$provide', function($provide){
$provide.decorator('$rootScope', ['$delegate', function($rootScope) {
var _proto
, _new
, nextUid = function() {
return ++$rootScope.$id;
}
, Scope = function() {
@nk9
nk9 / largestFiles.py
Last active November 14, 2023 09:47
Python script to find the largest files in a git repository.
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Python script to find the largest files in a git repository.
# The general method is based on the script in this blog post:
# http://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/
#
# The above script worked for me, but was very slow on my 11GB repository. This version has a bunch
# of changes to speed things up to a more reasonable time. It takes less than a minute on repos with 250K objects.
#
@eyecatchup
eyecatchup / ascii-binary-converter.js
Last active November 6, 2023 20:03
JavaScript native ASCII to Binary / Binary to ASCII convert functions.
// ABC - a generic, native JS (A)scii(B)inary(C)onverter.
// (c) 2013 Stephan Schmitz <eyecatchup@gmail.com>
// License: MIT, http://eyecatchup.mit-license.org
// URL: https://gist.github.com/eyecatchup/6742657
var ABC = {
toAscii: function(bin) {
return bin.replace(/\s*[01]{8}\s*/g, function(bin) {
return String.fromCharCode(parseInt(bin, 2))
})
},
/**
* @random-map.js
* @version: 1.00
* @author: Jesse Freeman
* @date: May 2012
*
* This class creates a "Random Map" button in the weltmeister editor.
* It requires two layers, a collision layer named "collation" and your
* map layer named "main". The generator will automatically create the collision
* tiles.
anonymous
anonymous / inheritance.js
Created December 23, 2012 13:23
A Javascript inheritance function. Derived by joining some parts by John Resig http://ejohn.org/ and some by Ajax.org Code Editor (ACE) Source. The end result: When you call `inherits` each overridden method in the derived class can call it's super-method by using this._super.
/* JavaScript Inheritance
* Author: Mutahhir Ali Hayat
* Made by joining some parts by John Resig http://ejohn.org/ and some by Ajax.org Code Editor (ACE)
*/
define(function(require, exports, module) {
var initializing = false,
fnTest = /xyz/.test(function() {
xyz;
}) ? /\b_super\b/: /.*/;