Skip to content

Instantly share code, notes, and snippets.

View JmeHsieh's full-sized avatar

Jo-Yuan Hsieh JmeHsieh

  • 03:10 (UTC +08:00)
View GitHub Profile
defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false && \
defaults write NSGlobalDomain KeyRepeat -int 1 && \
defaults write NSGlobalDomain InitialKeyRepeat -int 10 && \
sudo reboot
@JmeHsieh
JmeHsieh / open_in_iTerm.app
Created November 20, 2016 03:23
Open current Finder folder in iTerm app.
-- Copied from http://hohonuuli.blogspot.tw/2016/02/iterm2-version-3-open-iterm-here-script.html--
-- 1. Open Automator
-- 2. Create an Application, Choose Actions > Utilities > Run Applescript
-- 3. Paste the contents of open_in_iterm.app into the window.
-- 4. Save the script somewhere convenient.
-- 5. Find the script, then drag the script onto the Finder window while holding the command key (or in Yosemite, the command + option keys)
(*
Open Terminal Here
@JmeHsieh
JmeHsieh / crossing_bridge.py
Last active November 19, 2016 03:33
Find best moves by minimum weight
#!/usr/bin/env python3
from copy import deepcopy
class Game(object):
""" Crossing Bridge
One flashlight, bridge capicity: 2
Start from left. """
@JmeHsieh
JmeHsieh / tictactoe.py
Last active August 23, 2016 04:07
Tic Tac Toe game
#!/usr/bin/env python3
# indexing the slots
#
# 0 | 1 | 2
# -----|-----|-----
# 3 | 4 | 5
# -----|-----|-----
# 6 | 7 | 8
#
@JmeHsieh
JmeHsieh / keybase.md
Created August 12, 2016 01:22
Keybase <--> Github

Keybase proof

I hereby claim:

  • I am jmehsieh on github.
  • I am jmehsieh (https://keybase.io/jmehsieh) on keybase.
  • I have a public key whose fingerprint is 2D81 6DE4 ACAC B4F1 B06C 0A91 F2C8 3791 6E86 9295

To claim this, I am signing this object:

@JmeHsieh
JmeHsieh / BullsCows.hs
Created August 10, 2016 05:12
Bulls and Cows game
module BullsCows where
import Control.Monad (forever)
import Data.List
import Data.Sequence (Seq, adjust, fromList, index)
import System.Exit (exitSuccess)
parseInput :: String -> Maybe [Int]
parseInput s = do
s <- (if length s /= 4 then Nothing else return s)
@JmeHsieh
JmeHsieh / InfiniteLists.hs
Created July 21, 2016 02:51
infinite lists using `scanl`
fibs :: [Integer]
fibs = 1 : (scanl (+) 1 fibs)
facts :: [Integer]
facts = 1 : (scanl (\b a -> b * (b `div` a + 1)) 2 fact)
module hackerrank where
import Data.List
orderedElem :: [Int] -> [Int]
orderedElem = foldl (\r x -> if x `elem` r then r else r++[x]) []
unorderedGrouping :: [Int] -> [[Int]]
unorderedGrouping = group . sort
@JmeHsieh
JmeHsieh / gist:2002207
Created March 8, 2012 17:25
Decode UIImage in background
__weak Photo *p = self;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^
{
CGImageRef imageRef = image.CGImage;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(NULL,
CGImageGetWidth(imageRef),
CGImageGetHeight(imageRef),
8,
CGImageGetWidth(imageRef) * 4,