Skip to content

Instantly share code, notes, and snippets.

View xer0x's full-sized avatar

Drew Miller xer0x

  • SLUG/LAB
  • Vancouver
View GitHub Profile
@abozhilov
abozhilov / gist:1333507
Created November 2, 2011 12:32
Arguments default value
function func(a, f) {
return function (args) {
args.__proto__ = a;
f.call(this, args);
};
};
var f = func({foo : 10, bar : 20}, function (args) {
print(args.foo, args.bar);
anonymous
anonymous / dict-ie.js
Created December 28, 2012 07:12
old IE shim for creating empty dict objects
// pre-ES5 IE version
var dict = (function() {
var PROPERTY_KEYS = [
"hasOwnProperty",
"isPrototypeOf",
"propertyIsEnumerable"
"valueOf",
"toString",
"toLocaleString",
"constructor"
@timcharper
timcharper / Makefile
Created September 20, 2015 21:33
multirust source downloader
# Save this file to ~/.multirust/Makefile
# to run, cd ~/.multirust; make toolchains/1.3.0/src
.PHONY: clean
rust.git:
git clone https://github.com/rust-lang/rust.git --bare
toolchains/nightly/src: toolchains/master/src
ln -sf $$(pwd)/toolchains/master/src $$(pwd)/$@

Challenges in using postmortem debugging with promises

Introduction

This document seeks to summarize recent discussions about postmortem debugging, promises, and using them together. It starts by presenting what post-mortem debugging use cases are impacted negatively by the usage of promises. Then it describes some potential solutions that have been tried to fix these issues and their shortcomings.

@cfj
cfj / console.reverselog.js
Last active August 21, 2017 10:00
More console.log sillyness
var _log = console.log;
window.console.log = function(log){
_log.call(console, log.reverse ? log.reverse() : typeof log === 'string' ? log.split('').reverse().join('') : typeof log === 'number' ? log.toString().split('').reverse().join('') : typeof log === 'boolean' ? !log : log);
};

Challenges in using post-mortem debugging with async/await

Introduction

async/await is a new feature of the EcmaScript programming language that combines generators and promises to improve the language-level model for writing asynchronous code.

It is currently in "stage 3" of the TC39 process, which means it's a "candidate" that needs more implementation experience.

@stefanjudis
stefanjudis / console.js
Last active July 31, 2019 17:09
Suprising replacement patterns in String.prototype.replace
const msg = 'This is a great message';
msg.replace('great', 'wonderful');
// "This is a wonderful message"
//
// -> 'great' is replaced by 'wonderful'
msg.replace('great', '$&-$&');
// "This is a great-great message"
// '$&' represents the matched substring
@shripadk
shripadk / gist:652819
Created October 29, 2010 03:10
Express authentication using Redis for session store and Couchdb for database (in coffeescript!)
###
Module dependencies
###
require.paths.unshift "#{__dirname}/lib/support/express-csrf/"
require.paths.unshift "#{__dirname}/lib/support/node_hash/lib/"
express = require 'express'
app = module.exports = express.createServer()
RedisStore = require 'connect-redis'
@Deborah-Digges
Deborah-Digges / README.md
Last active August 11, 2020 18:46
Send logs to Splunk

Hacky script to send a bunch of logs to splunk directly

Currently, we don't have a tool that can send

  • a specific set of logs
  • with the right shape
  • to a tenant
  • in any environment

We have a bunch of separate tools that do different parts of this. We need a way to consolidate this functionality into fox-cli.

@marc-barry
marc-barry / handler.js
Created June 30, 2020 18:29
Cloudflare Worker for Auth0 Self-Managed Certificates
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
const url = new URL(request.url)
url.hostname = 'SOME_HOSTNAME' // i.e. 'dev-w-47n-vy-cd-e88kLg26GFbLGgBI.edge.tenants.auth0.com'
request = new Request(request)
request.headers.set('cname-api-key', 'SOME_KEY') // i.e. 'd4f2f3ef5a3ee3af4846127281d3450628bdc16d63e802dea75878fe9a63a279'