This file contains hidden or 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 scala.reflect.runtime.{universe => ru} | |
import ru._ | |
case class Hoge(id: Int, title: String) | |
class Fuga[T: TypeTag](orig: T) { | |
val mirror = ru.runtimeMirror(Thread.currentThread.getContextClassLoader) | |
val clazz = mirror.runtimeClass(typeOf[T]) | |
val fields = clazz.getDeclaredFields |
This file contains hidden or 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
object Sudoku { | |
val N = 9 | |
val ROOM = Math.sqrt(N).asInstanceOf[Int] | |
type Coord = (Int, Int) | |
def nextCoord(coord: Coord): Coord = { | |
if (coord._2 == N - 1) { | |
return if (coord._1 == N-1) (0, 0) else (coord._1 + 1, 0) | |
} else { |
This file contains hidden or 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
// compile: g++ -std=c++11 sudoku.cpp | |
#include <iostream> | |
#include <tuple> | |
#include <string> | |
#include <vector> | |
#include <array> | |
#include <cmath> | |
using namespace std; |
This file contains hidden or 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 Control.Monad (when) | |
import System.IO (hFlush, stdout) | |
-- main = f | |
main = g | |
f :: IO () | |
f = do | |
x <- getLine | |
when (x /= "q") $ do |
This file contains hidden or 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
#include <sys/param.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
int main(int argc, char **argv) { | |
if (argc != 2) { | |
printf("usage: %s <path>\n", argv[0]); | |
exit(1); | |
} |
This file contains hidden or 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 ScopedTypeVariables #-} | |
type Nat = Int | |
---------------------------------------- | |
-- Lists | |
---------------------------------------- | |
data NatList = Nil () | Cons (Nat, NatList) | |
deriving (Eq, Show) |
This file contains hidden or 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 #-} | |
import Language.Haskell.TH | |
import Control.Applicative ((<$>)) | |
data Hoge = Hoge1 | Hoge2 | Hoge3 deriving (Eq, Show) | |
data Fuga = Fuga1 | Fuga2 deriving (Eq, Show) | |
-- runQ [| \t -> case t of "hoge1" -> Hoge1; "hoge2" -> Hoge2; "hoge3" -> Hoge3; _ -> error "Hoge" |] |
This file contains hidden or 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
/** | |
* Haskell Brushe for SyntaxHighlighter 3.0 | |
*/ | |
SyntaxHighlighter.brushes.Haskell = function() | |
{ | |
var constants = 'True False Nothing Just Left Right LT EQ GT'; | |
var datatypes = 'Bool Maybe Either Ordering Char String Int Integer Float Double Rational ' + | |
'IO ReadS ShowS FilePath IOError Monad Functor Show Read' + | |
'Eq Ord Enum Bounded Num Real Integral Fractional Floating RealFrac RealFloat'; |
This file contains hidden or 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 'anything-grep) | |
(defun recentf-grep (str) | |
(interactive "sSearch: ") | |
(let* ((files (mapconcat #'(lambda (x) (concat "'" x "'")) | |
(filter #'file-readable-p recentf-list) " ")) | |
(command (concat "grep -i -nH -e " str " " files)) | |
(pwd "/tmp") | |
(src (agrep-source (agrep-preprocess-command command) pwd))) | |
(setcdr (assoc 'name src) (format "grep %s in recentf-list" str)) | |
(anything-grep-base (list src) (format " *recentf-grep:%s*" str)))) |