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
// reference: http://stackoverflow.com/questions/6167515/simulating-finally-block-in-c0x | |
#include <functional> | |
class finally | |
{ | |
std::function<void (void)> const action; | |
finally(const finally&) = delete; | |
public: |
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
require 'test/unit' | |
require 'rps' | |
class RPSTestCase < Test::Unit::TestCase | |
def test_simple_win_lose | |
# :rock loses :paper | |
turn_person = rps_game([[:rock], [:paper]]) | |
assert_equal(turn_person, [0, 1]) | |
# :rock wins :scissors |
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
# coding: utf-8 | |
import sys | |
# For each integer 1..n, print "jojo" if it is a prime number, | |
# else print the number. | |
def jojo_iter(num): | |
if 1 <= num: | |
yield 1 |
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
curl -u "GIT-ACCOUNT-NAME:PASS" --data '{"text":"# Hello","mode":"gfm" }' https://api.github.com/markdown |
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
/* | |
* Snippet :: jQuery Syntax Highlighter v2.0.0 | |
* http://steamdev.com/snippet | |
* | |
* Copyright 2011, SteamDev | |
* Released under the MIT license. | |
* http://www.opensource.org/licenses/mit-license.php | |
* | |
* Date: Wed Jan 19, 2011 | |
*/ |
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"> | |
<title>n-tagram</title> | |
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script> | |
</head> | |
<body> | |
<label for="pointsSpinner">Points: </label> |
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
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE ExtendedDefaultRules #-} | |
{-# OPTIONS_GHC -fno-warn-type-defaults #-} | |
import Control.Monad (forM_) | |
import qualified Data.Text.Lazy as LT (append, pack, Text) | |
import Filesystem.Path (append, basename, filename) | |
import Shelly | |
import System.Environment (getArgs) | |
default (LT.Text) |
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
-- references | |
-- http://code.haskell.org/haskell-src-exts/Test/examples/HaskellParser.hs | |
-- http://code.haskell.org/haskell-src-exts/examples/Prettify.hs | |
import qualified Language.Haskell.Exts.Annotated as P | |
import qualified Language.Haskell.Exts.Extension as Ext | |
import Language.Haskell.Exts.Pretty (prettyPrint) | |
import System.Environment (getArgs) | |
parse originalFileName input = P.parseModuleWithMode parseMode input |
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
{-# Language TemplateHaskell, QuasiQuotes, FlexibleContexts #-}↲ | |
↲ | |
import Control.Monad↲ | |
import Text.Peggy↲ | |
↲ | |
[peggy|↲ | |
expr :: Double↲ | |
= expr "+" fact { $1 + $2 }↲ | |
/ expr "-" fact { $1 - $2 }↲ | |
/ fact↲ |
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 qualified Data.Set as S | |
import Data.String.Utils | |
genEquivalentClass :: Ord a => [(a, a)] -> [[a]] | |
genEquivalentClass pairs = | |
sort . map (sort . S.toList) $ foldr eqcs [] pairs | |
where | |
eqcs (n, m) cs = case (lookupClass n cs, lookupClass m cs) of | |
(Nothing, Nothing) -> S.fromList [n, m] : cs |
OlderNewer