Skip to content

Instantly share code, notes, and snippets.

View junegunn's full-sized avatar
🐷
Please be kind to animals

Junegunn Choi junegunn

🐷
Please be kind to animals
View GitHub Profile
@rmm5t
rmm5t / README.md
Created August 19, 2008 23:38
Locale override examples for the timeago jQuery plugin (http://timeago.yarp.com)

This gist is now deprecated

Please visit the locales directory inside the main timeago repository intead.

# 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
; Released under the Apache License, Version 2.0
; http://www.apache.org/licenses/LICENSE-2.0.html
(defmacro try-let
"A combination of try and let such that exceptions thrown in the binding or
body can be handled by catch clauses in the body, and all bindings are
available to the catch and finally clauses. If an exception is thrown while
evaluating a binding value, it and all subsequent binding values will be nil.
Example:
@ik5
ik5 / daemon.rb
Created June 22, 2010 18:43
a quick and dirty jruby daemon based on basic_daemon
#!/usr/bin/env jruby
#
#
require 'rubygems'
require 'spoon'
EXEC = '/tmp/exec.rb'
PID_PATH = '/tmp/exec.pid'
WORK_PATH = '/tmp/'
@mathiasbynens
mathiasbynens / appify
Created November 12, 2010 13:46 — forked from subtleGradient/appify
appify — create the simplest possible Mac app from a shell script
#!/bin/bash
if [ "$1" = "-h" -o "$1" = "--help" -o -z "$1" ]; then cat <<EOF
appify v3.0.1 for Mac OS X - http://mths.be/appify
Creates the simplest possible Mac app from a shell script.
Appify takes a shell script as its first argument:
`basename "$0"` my-script.sh
@kusor
kusor / markdown.vim
Created December 1, 2010 07:44
Little plugin to open Markdown preview in browser.
" markdown.vim
" Markdown preview using RDiscount ruby gem.
" Put this file into .vim/ftplugin
command! -nargs=0 MarkdownPreview call MarkdownRenderBufferToPreview()
noremap <buffer> <Leader>rp :MarkdownPreview<CR>
setlocal ignorecase
setlocal wrap
@junegunn
junegunn / jruby-daemon.sh
Created September 2, 2011 08:42
init.d-style jruby daemon
#!/bin/bash
# Junegunn Choi (junegunn.c@gmail.com)
# 2011/09/02-
# init.d-style daemon script for JRuby with spoon gem.
APP_NAME=sleeper
APP_PATH=/Users/jg/github/jruby-daemon/sleeper.rb
JRUBY=/Users/jg/.rvm/rubies/jruby-1.6.4/bin/ruby
@purcell
purcell / color-utils.el
Created October 17, 2011 12:59
A few hacky color-related functions
(defun format-color (rgb)
"Convert a triplet of floating point (0.0-1.0) RGB values into
a hex triplet"
(apply 'format "#%02x%02x%02x"
(mapcar (lambda (x) (* 255 x)) rgb)))
(defconst colour-triplet-regex
"\\([0-9A-Fa-f]\\{2\\}\\)\\([0-9A-Fa-f]\\{2\\}\\)\\([0-9A-Fa-f]\\{2\\}\\)")
@daveray
daveray / seesaw-repl-tutorial.clj
Created December 7, 2011 04:55
Seesaw REPL Tutorial
; A REPL-based, annotated Seesaw tutorial
; Please visit https://github.com/daveray/seesaw for more info
;
; This is a very basic intro to Seesaw, a Clojure UI toolkit. It covers
; Seesaw's basic features and philosophy, but only scratches the surface
; of what's available. It only assumes knowledge of Clojure. No Swing or
; Java experience is needed.
;
; This material was first presented in a talk at @CraftsmanGuild in
; Ann Arbor, MI.
@rkh
rkh / chat.rb
Created December 14, 2011 12:55
Simple Chat Application using the Sinatra Streaming API
# coding: utf-8
require 'sinatra'
set server: 'thin', connections: []
get '/' do
halt erb(:login) unless params[:user]
erb :chat, locals: { user: params[:user].gsub(/\W/, '') }
end
get '/stream', provides: 'text/event-stream' do