Skip to content

Instantly share code, notes, and snippets.

View jhsu's full-sized avatar
💀
compliant with future standards

Joe Hsu jhsu

💀
compliant with future standards
  • MineHub
  • New York, NY
  • X @jhsu
View GitHub Profile
function* fib(a, b) {
let c = 0
yield a
yield b
while (true) {
c = a + b
a = b
b = c
yield c
eventsource
go-eventsource
client/client
@jhsu
jhsu / rb_array_iterate.rb
Created August 3, 2012 04:47 — forked from ephekt/rb_array_iterate.rb
array iteration problem
def add1(arr, val, n)
# how many times are we going to increment
increment_count = n == 0 ? arr.length : n.abs
# are we going up or down the array
indices = n < 0 ? (-1..-arr.length) : (0...arr.length)
# iterate and update the array in place
indices.each do |index|
arr[index] = arr[index] + 1 if val == arr[index]
break if (increment_count -= 1) == 0
@jhsu
jhsu / .rvmrc
Created July 19, 2012 02:07 — forked from anonymous/.rvmrc
Ruby for rails MRI 1.9.2+
# via http://www.reddit.com/r/ruby/comments/wgtqj/how_i_spend_my_time_building_rails_apps/c5daer4
export RUBY_HEAP_MIN_SLOTS=800000
export RUBY_HEAP_FREE_MIN=100000
export RUBY_HEAP_SLOTS_INCREMENT=300000
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1
export RUBY_GC_MALLOC_LIMIT=79000000
@jhsu
jhsu / randomthumbs.rb
Created April 23, 2012 14:56 — forked from psobot/randomthumbs.rb
Random Image Thumbnailer
# Hacky random image thumbnailer.
# by Peter Sobot, April 21, 2012
# Based heavily on code by Michael Macias
# (https://gist.github.com/a54cd41137b678935c91)
require 'rmagick'
images = Dir.glob(ARGV[0] ? ARGV[0]
: '-default-input-paths-')
output_dir = (ARGV[1] ? ARGV[1]
@jhsu
jhsu / gist:2292055
Created April 3, 2012 13:38 — forked from jrom/gist:1162348
Requeue failed resque jobs
(Resque::Failure.count-1).downto(0).each { |i| Resque::Failure.requeue(i) }
Resque::Failure.clear
@jhsu
jhsu / index.html
Created February 21, 2012 00:29 — forked from benjchristensen/index.html
Animated Line Graphs / Sparklines using SVG Path and d3.js
<html>
<head>
<title>Animated Sparkline using SVG Path and d3.js</title>
<script src="https://raw.github.com/mbostock/d3/master/d3.v2.min.js"></script>
<style>
/* tell the SVG path to be a thin blue line without any area fill */
path {
stroke: steelblue;
stroke-width: 1;
fill: none;
@jhsu
jhsu / mkick.rb
Created September 26, 2011 19:15
# mkick.rb
#
# Mass-kicks users in a channel
#
# http://scripts.irssi.org/html/mkick.pl.html
#
# Possible inspiration: http://weechat.org/files/scripts/unofficial/chanlist.rb
#
# Usage: /mkick <channel> <kick message>
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
" Vim syntax file
" Language: HTML (version 5)
" Maintainer: Rodrigo Machado <rcmachado@gmail.com>
" URL: http://gist.github.com/256840
" Last Change: 2009 May 13
" License: Public domain
" (but let me know if you liked it :) )
"
" Note: This file just adds the new tags from HTML 5
" and don't replace default html.vim syntax file