Skip to content

Instantly share code, notes, and snippets.

View jhliberty's full-sized avatar
:octocat:
It's a rails kind of year

John-Henry Liberty jhliberty

:octocat:
It's a rails kind of year
View GitHub Profile
#!/usr/bin/env ruby
require 'benchmark'
Benchmark.bm do |b|
n = 1_000_000
hash1 = {a: 1, b: 2, c: 3}
hash2 = {x: 1, y: 2, z: 3}
//To run Q.js examples:
// 1. Open a new browser tab in Chrome and turn on developer toolbar.
// 2. Copy/Paste this gist in the console and hit enter to run all the snippets.
// Based on the inspiration from samples @ https://github.com/kriskowal/q
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
{
"app/adapters/*.js": {
"command": "adapter",
"template": [
"// export default DS.{capitalize}Adapter.extend();",
]
},
"app/components/*.js": {
"command": "component",
// new: accepts an optional transformer as first argument
// str.template({key:value});
// or
// str.template(htmlEscaper, {key:value});
String.prototype.template = function (fn, object) {
// Andrea Giammarchi - WTFPL License
var
hasTransformer = typeof fn === 'function',
prefix = hasTransformer ? '__tpl' + (+new Date) : '',
stringify = JSON.stringify,

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:

@jhliberty
jhliberty / LICENSE
Last active August 29, 2015 14:27 — forked from ourmaninamsterdam/LICENSE
Arrayzing - The JavaScript array cheatsheet
The MIT License (MIT)
Copyright (c) 2015 Justin Perry
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
@jhliberty
jhliberty / build.sh
Last active February 21, 2016 19:24 — forked from patrickarlt/build.sh
ES 7 async/await demo!
babel github-es6.js -o github.js --optional runtime --experimental
@jhliberty
jhliberty / streams.md
Last active August 29, 2015 14:28 — forked from domenic/streams.md
Byte streams exploration

File streams

According to libuv folks, the most reliable way to do asynchronous file I/O is blocking read(2) in a threadpool. Although Windows has IO Completion Ports, they fall down in enough cases they are largely not used. Regardless, we want to support read(2)-in-a-threadpool models, so this section assumes files are a good instantiation of that model, and analyzes how readable byte streams work in that case.

Reading a file byte stream into an ArrayBuffer

Given a file readable byte stream with a known size, read the entire thing into memory:

async function file_exact(fileRBS, knownFileSize) {
@jhliberty
jhliberty / LittlebitsWebSocket.cs
Created January 26, 2016 00:45 — forked from rondagdag/LittlebitsWebSocket.cs
Littlebits Web Socket using WebSocketSharp.Net and Newtonsoft.Json
using UnityEngine;
using System.Collections;
using System;
using System.Security.Policy;
using System.Threading;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using WebSocketSharp;
using WebSocketSharp.Net;
@jhliberty
jhliberty / froala-semantic-icons.js
Created January 27, 2016 22:56 — forked from Panman82/froala-semantic-icons.js
This is an ember-cli / ember initializer that changes the Froala Editor icons from the Font Awesome names to the Semantic UI names (technically Font Awesome just re-named). For those using Froala Editor with Semantic UI outside of the ember ecosystem, just use lines 5 to 57 and remove `Ember.` prefixes.
// app/initializers/froala-semantic-icons.js
import Ember from 'ember';
export function initialize() {
// https://www.froala.com/wysiwyg-editor/docs/concepts/custom-icon
Ember.$.FroalaEditor.ICON_DEFAULT_TEMPLATE = 'semantic_ui';
Ember.$.FroalaEditor.DefineIconTemplate( 'semantic_ui', '<i class="[NAME] icon"></i>');
Ember.$.FroalaEditor.DefineIcon( 'color' , { NAME: 'theme' } ); // tint
Ember.$.FroalaEditor.DefineIcon( 'undo' , { NAME: 'undo' } ); // rotate-left
Ember.$.FroalaEditor.DefineIcon( 'redo' , { NAME: 'repeat' } ); // rotate-right