Skip to content

Instantly share code, notes, and snippets.

View jason2506's full-sized avatar
🔰

Chi-En Wu jason2506

🔰
View GitHub Profile
@jason2506
jason2506 / post-commit
Created January 19, 2014 11:50
git post-commit hook that automatically update the bundle version.
#!/bin/sh
plist_path=`find . -type f -iname *.plist -d 2`
build=`git rev-parse --short HEAD`
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $build" $plist_path
APORT3 EQU 03FD0H
BPORT3 EQU 03FD2H
CPORT3 EQU 03FD4H
CNT3 EQU 03FD6H
FND EQU 03FF0H
IR_WR EQU 0FFC1H
IR_RD EQU 0FFC3H
DR_WR EQU 0FFC5H
RAME EQU 0EFFFH
FLAG EQU RAME-0FFFH
@jason2506
jason2506 / gist:2783615
Created May 24, 2012 19:12
Capture all key press events in the system.
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
CGEventMask eventMask = CGEventMaskBit(kCGEventKeyDown);
CFMachPortRef eventTap = CGEventTapCreate(kCGHIDEventTap,
kCGHeadInsertEventTap,
kCGEventTapOptionDefault,
eventMask,
eventHandler,
NULL);
CFRunLoopSourceRef runLoopSource = CFMachPortCreateRunLoopSource(kCFAllocatorDefault, eventTap, 0);
@jason2506
jason2506 / dfa.hs
Created May 8, 2012 12:13
[Haskell Practice] finite automata
module DFA
( DFA (..)
, trans
, run
, accept
) where
import qualified Data.Map as Map
import qualified Data.Set as Set
import Data.Maybe
@jason2506
jason2506 / tree.hs
Created March 29, 2012 20:05
[Haskell Practice] binary search tree
-- define data type
data Tree a = EmptyTree | Node a (Tree a, Tree a) deriving (Show, Read, Eq)
-- create single node
treeNode :: a -> Tree a
treeNode item = Node item (EmptyTree, EmptyTree)
-- covert from/to list
treeFromList :: (Ord a) => [a] -> Tree a
treeFromList items = foldr treeInsert EmptyTree $ reverse items
@jason2506
jason2506 / sorting.hs
Created March 27, 2012 16:38
[Haskell Practice] some common sorting algorithms
import Data.List
bubbleSort :: (Ord a) => [a] -> [a]
bubbleSort [] = []
bubbleSort (first:[]) = first:[]
bubbleSort (first:remains) =
if first < smallest
then first:(bubbleSort bubbledRemains)
else smallest:(bubbleSort (first:(tail bubbledRemains)))
where bubbledRemains = bubbleSort remains
@jason2506
jason2506 / split.hs
Created March 7, 2012 13:30
[Haskell Practice] split a list into sub-lists using a set of separators.
split :: (Eq a) => [a] -> [a] -> [[a]]
split _ [] = [[]]
split sep (list_head:list_tail) =
if list_head `elem` sep
then []:splited_tail
else (list_head:(head splited_tail)):(tail splited_tail)
where splited_tail = split sep list_tail
main = do
putStr (show (split " " "this is a book"))