Skip to content

Instantly share code, notes, and snippets.

View fundon's full-sized avatar
🎯
Focusing

Fangdun Tsai fundon

🎯
Focusing
View GitHub Profile
@fundon
fundon / LICENSE.txt
Created May 18, 2012 07:49 — forked from yaoduren123/LICENSE.txt
convert RGB to HEX
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@fundon
fundon / consumer_producer.clj
Created May 18, 2012 07:51
Queue based consumer/producer.
;; This example shows how to create a single producer and multiple consumers.
;; Each consumer will receive the message. I'm not sure if internally it's handled in a round-robin manner,
;; but when queue does not listen for messages (e.q. it's processing them), it won't receive one.
;;
;; In order to run it, use:
;;
;; lein2 run --mode consumer
;;
;; And in other window:
;;
@fundon
fundon / arcfour.js
Created May 21, 2012 14:39 — forked from bellbind/arcfour.js
[javascript]arcfour aka RC4 enc/decript function
// arcfour aka RC4 enc/decrypt function
// see: http://en.wikipedia.org/wiki/RC4
arcfour = (function () {
"use strict";
var swap = function (a, i, j) {
var tmp = a[i];
a[i] = a[j];
a[j] = tmp;
};
@fundon
fundon / utf8length.js
Created May 21, 2012 14:39 — forked from vmi/utf8length.js
Calulate byte length of string as UTF-8.
/*
* Fair License (Fair)
*
* Copyright (c) 2012, IWAMURO Motonori
*
* Usage of the works is permitted provided that this instrument is
* retained with the works, so that any entity that uses the works is
* notified of this instrument.
*
* DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
@fundon
fundon / [JS]GetUTF8CodePoint
Created May 21, 2012 14:39
Get UTF-8 Codepoint from UTF-8 Hex-Num array in JavaScript
function getCodePoint(array) {
/*-----------------------------------------------------------------------------------------
[UCS-2 (UCS-4)] [bit pattern] [1st byte] [2nd byte] [3rd byte] [4th byte]
U+ 0000.. U+007F 00000000-0xxxxxxx 0xxxxxxx
U+ 0080.. U+07FF 00000xxx-xxyyyyyy 110xxxxx 10yyyyyy
U+ 0800.. U+FFFF xxxxyyyy-yyzzzzzz 1110xxxx 10yyyyyy 10zzzzzz
U+10000..U+1FFFFF 00000000-000wwwxx 11110www 10xxxxxx 10yyyyyy 10zzzzzz
-xxxxyyyy-yyzzzzzzz
------------------------------------------------------------------------------------------*/
@fundon
fundon / count_utf8.js
Created May 21, 2012 14:39 — forked from frne/count_utf8.js
Function to count bytes of a string (UTF8)
/**
* Function to fix native charCodeAt()
*
* Now, we can use fixedCharCodeAt("foo€", 3); for multibyte (non-bmp) chars too.
*
* @access public
* @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/charCodeAt
* @note If you hit a non-bmp surrogate, the function will return false
* @param str String Mixed string to get charcodes
* @param idx Integer Position of the char to get
@fundon
fundon / sqlpostgres.vim
Created May 23, 2012 02:52 — forked from kmatt/sqlpostgres.vim
SQL postgres vim syntax file
" Vim syntax file
" Language: SQL, PGSQL (postgres 9.1)
" Last Change: 2012 May 21st
" Maintainer: Grégoire Hubert <greg DOT hubert AT gmail DOT com>
" Based on the work of Paul Moore <pf_moore AT yahoo.co.uk>
" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
if version < 600
syntax clear
foo {
animation-name: spin;
animation-duration: 3s;
animation-timing-function: ease | linear | ease-in | ease-out | ease-in-out | step-start | step-end | steps(10,start | end) | cubic-bezier(<number>, <number>, <number>, <number>);
animation-delay: 3s;
animation-iteration-count: infinite | 10;
animation-direction: alternate | normal;
animation-fill-mode: forward | backwards | both | none;
animation-play-state: running | paused;
}
@fundon
fundon / portable-node.md
Created May 27, 2012 14:39 — forked from rhiokim/portable-node.md
Tips for Writing Portable Node.js Code

Tips for Writing Portable Node.js Code

(This is the kind of thing I should put on my hypothetical blog.)

I'm a Node.js user... on Windows. (Gasp!) And here are some of the issues I face every day:

Easy to Fix

In order of most-violated to least-violated:

@fundon
fundon / gist:2852614
Created June 1, 2012 14:43 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt