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
@jibsen
jibsen / srgbtogenericrgb.py
Created October 22, 2014 06:50
Example of converting RGB colors from sRGB to Generic RGB
#!/usr/bin/env python3
# Copyright (c) 2014 Joergen Ibsen
#
# 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:
@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\\}\\)")
@sam
sam / gist:4113718
Created November 19, 2012 20:36
QBE example
module Query
class Expression
attr_reader :field, :operator, :target
def initialize(field, operator, target)
@field, @operator, @target = field, operator, target
end
end
Latency Comparison Numbers
--------------------------
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
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms

The server.rb file slowly feeds data to the socket, and both clients will yield data as it's available. UneventfulMachine steals the API of EventMachine.

; 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/'
@d630
d630 / 0.16.2.md
Last active January 26, 2017 13:28
fzf - a command-line fuzzy finder

fzf - a command-line fuzzy finder

Internal opts struct

opts.Field Type Default
Ansi bool false
Black bool false
Bold bool true
Case Case CaseSmart