Skip to content

Instantly share code, notes, and snippets.

@motorcityadam
motorcityadam / preinstall.js
Created October 31, 2019 21:01
Preinstall script to fix npm proxy issues with Yarn and GitHub Package Registry
// Copyright (c) Alliedstrand Corporation. All rights reserved.
//
// Licensed under the MIT License.
'use strict';
/**
* @file Extract the GitHub Personal Access Token for GitHub Package Registry
* access.
*
@williballenthin
williballenthin / macOS_savedstate.py
Last active April 20, 2024 21:13
parse macOS savedState files
'''
parse SavedState artifacts extracted from OSX.
author: Willi Ballenthin (william.ballenthin@fireeye.com)
license: Apache 2.0
'''
import re
import sys
import json
import struct
@asolove
asolove / foo.js
Created April 11, 2016 16:13
Flow type for react component with ref callback
// I want to do something like this:
export default class Foo extends React.Component {
render() {
return <div ref={div => this._div = div}>I want a reference to this!</div>
}
}
// Flow says: "Property _div not found on Foo"
// Is there a way to give Foo the type Component & {_div?: Component} ?
@nkbt
nkbt / generate-specs.js
Created October 13, 2015 02:55
Generate empty Jasmine specs for React components
#!/usr/bin/env node
const glob = require('glob');
const path = require('path');
const fs = require('fs');
const mkdirp = require('mkdirp');
const args = global.process.argv.slice(2);
const sourcesRoot = args.shift() || path.join(__dirname, '..', 'src');
const specsRoot = args.shift() || path.join(__dirname, '..', 'spec');
@adamrneary
adamrneary / video-events-lamba-function.js
Created December 20, 2014 18:07
A simple function for Amazon Lambda
var Firebase = require('firebase');
var async = require('async');
// Extract data from the kinesis event
exports.handler = function(event, context) {
// This function abstracts the expected structure of any Kinesis payload,
// which is a base64-encoded string of a JSON object, passing the data to
// a private function.
function handlePayload(record, callback) {
@turadg
turadg / poltergeist_screenshot_helper.rb
Last active December 15, 2015 20:59
Poltergeist screenshot helper for Rspec
# spec/support/poltergeist_screenshot_helper.rb
module PoltergeistScreenshotHelper
# FROM http://blog.jerodsanto.net/2012/12/capybara-and-poltergeist-snap/
def snap!(options={})
path = options.fetch :path, "~/.Trash"
file = options.fetch :file, "#{Time.now.to_i}.png"
full = options.fetch :full, true
path = File.expand_path path
@naan
naan / source_maps.rb
Last active December 14, 2015 13:48 — forked from alexspeller/source_maps.rb
Monkey patch for Coffee Script v.1.6.2 Source Maps for Rails.
# config/initializers/source_maps.rb
if Rails.env.development?
module CoffeeScript
class SourceMapError < StandardError; end;
class << self
def compile script, options
script = script.read if script.respond_to?(:read)
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active May 2, 2024 05:55
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@kaznum
kaznum / gist:3810258
Created October 1, 2012 08:16
sanitize HTML with jQuery
/*
* sanitize HTML with jQuery based on whitelist
* example:
* sanitizer.sanitize('<a href="foo" class="bar">aaa</a><script>alert("...")</script>', {'a': ['href'], 'strong': []})
* returns '<a href="foo">aaa</a>'
*/
var sanitizer = {};
(function($) {
function trimAttributes(node, allowedAttrs) {
@jboner
jboner / latency.txt
Last active May 3, 2024 15:17
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD