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; | |
}; |
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
from __future__ import print_function | |
class Attribute(object): | |
def __init__(self): | |
pass | |
def main(): | |
a = Attribute(); | |
print(a.__dict__) | |
a.__setattr__("test", 5) |
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
module ListFiles where | |
import System.Directory | |
import System.FilePath.Posix | |
split:: [a] -> [Bool] -> ([a], [a]) | |
split xs bs = foldr s ([], []) (zip xs bs) | |
where s (d, i) (y, z) = if i then (d:y, z) else (y, d:z) | |
isSpecialFile :: FilePath -> Bool |
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
git branch -m old_branch new_branch # Rename branch locally | |
git push origin :old_branch # Delete the old branch | |
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote |
OlderNewer