This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import url("reset-fonts-grids.css"); | |
@import url("hk-pyg.css"); /* for syntax highlighting */ | |
html { background: #f9f9f9; color: black; } | |
body { margin: 10px; font-family: verdana; } | |
fieldset { border: 1px solid #ccc; padding: 1em; } | |
legend { font-weight: bold; margin-left: 1em; padding: 4px; } | |
h1, h2, h3, h4, h5, h6 { font-weight: bold; font-family: Georgia, serif; } | |
table, tr, td, th { border: none; } | |
hr { height: 1px; color: #aaa; background-color: #aaa; border: 0; margin: .2em 0 .2em 0; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#-*- coding: utf8 -*- | |
from __future__ import print_function | |
from optparse import OptionParser | |
import zipfile | |
from sys import argv, exit | |
from subprocess import Popen, PIPE, check_output | |
import os.path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Problem 1 | |
myLast [] = error "empty list." | |
myLast [x] = x | |
myLast (x:xs) = myLast xs | |
-- Problem 2 | |
myButLast x = head . drop 1 . reverse $ x | |
-- Problem 3 | |
elementAt (x:xs) n = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Read the contents of clipboard | |
-- Ref: http://stackoverflow.com/questions/1712347/closest-equivalent-to-subprocess-communicate-in-haskell | |
import System.Process | |
processData :: String -> String | |
processData = (id :: String -> String) | |
processPaste :: (String -> String) -> IO () | |
processPaste pd = do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
processPaste' :: (String -> String) -> IO () | |
processPaste' pd = putStrLn . pd =<< readProcess "pbpaste" [] [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
DEFAULT_CONTENTS="""<!-- | |
.. link: | |
.. description: | |
.. tags: all | |
.. date: $time | |
.. title: $title | |
.. slug: $slug | |
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta name="description" content=""> | |
<meta name="author" content=""> | |
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.no-icons.min.css" rel="stylesheet"> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sol1 = takeWhile (<1000) $ filter (\x -> x `mod` 3 == 0 || x `mod` 5 == 0) [1..] | |
sol2 = takeWhile (<1000) [x| x<-[1..], x `mod` 3 ==0 || x `mod` 5 ==0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List | |
import System.Cmd | |
type ExecuteCmd = String | |
type Option = String | |
type OptionList = [Option] | |
data Command = Cmd ExecuteCmd OptionList | |
deriving (Show, Eq) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Singleton{ | |
public: | |
static const Singleton& getInstance(){ | |
static Singleton single; | |
return single; | |
}; | |
private: | |
Singleton():a(0){}; | |
unsigned int a; | |
}; |
OlderNewer