Skip to content

Instantly share code, notes, and snippets.

import System.Environment
fizzbuzz n
| 0 >= n = error "n must be >0."
| otherwise =
let fb x
| 0 == mod x 15 = "FizzBuzz"
| 0 == mod x 5 = "Buzz"
| 0 == mod x 3 = "Fizz"
| otherwise = show x
import Control.Applicative
goodRoute :: (Real a) => [[a]] -> [a]
goodRoute = n . goodRoute_
where
goodRoute_ :: (Real a) => [[a]] -> Maybe [a]
goodRoute_ ([]:_) = Nothing
goodRoute_ [] = Nothing
goodRoute_ ((x:[]):[]) = Just (x:[])
goodRoute_ matrix =
(function() {
var curry = function(f) {
var c = function(l, args) {
return function(a) {
switch(l) {
case 1:
args.push(a)
case 0:
return f.apply(this, args)
@haiiro-shimeji
haiiro-shimeji / style.css
Last active December 16, 2015 07:59
clickhold/taphold implementation example on openlayers map
/**
* CSS Reset
* From Blueprint reset.css
* http://blueprintcss.googlecode.com
*/
html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, code, del, dfn, em, img, q, dl, dt, dd, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {margin:0;padding:0;border:0;font-weight:inherit;font-style:inherit;font-size:100%;font-family:inherit;vertical-align:baseline;}
body {line-height:1.5;}
table {border-collapse:separate;border-spacing:0;}
caption, th, td {text-align:left;font-weight:normal;}
table, td, th {vertical-align:middle;}
$.extend({
deepEquals: function(obj1, obj2) {
var q = []
var r = function(o1, o2) {
var k1 = Object.keys(o1).sort()
var k2 = Object.keys(o2).sort()
if (k1.length != k2.length) return false;
var result = true
$.each(k1, function(_, key) {
$.extend({
foldl: function(array, acc, callback) {
$.each(array, function(_, value) {
acc = callback(value, acc)
})
return acc
},
foldr: function(array, acc, callback) {
@haiiro-shimeji
haiiro-shimeji / Test1.java
Last active December 16, 2015 22:29
子どもとして持てるノードタイプを型として定義可能なツリー構造が作りたかった
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.junit.Test;
/**
* 子どもとして持てるノードタイプを型として定義可能なツリー構造が作りたかった
*/
public class Test1 {
@haiiro-shimeji
haiiro-shimeji / ScopeTest.js
Last active December 17, 2015 07:59
#js #tddjs
var hoge_ScopeTest = 1001, fuga_ScopeTest = 1002, piyo_ScopeTest = 1003, foo_ScopeTest = 1004;
TestCase("Scope Test", {
"test scope": function () {
var sum = function() {
//関数内部で宣言されたローカル変数は先頭で宣言されたのと同義になる(=ホイスト)
//var i, total;
@haiiro-shimeji
haiiro-shimeji / Makefile
Last active December 17, 2015 10:48
Sample that describe how to call c function from python, and how to give float array.
PYTHON_VERSION=2.7
CCFLAG=-std=gnu99 -Wall -fPIC -I/usr/include/python${PYTHON_VERSION}
LDFLAG=-lpython${PYTHON_VERSION}
run: build
python -m unittest pythonc_test
build: spam.so
spam.so: spam.o
gcc -shared -o $@ $^ ${LDFLAG}
@haiiro-shimeji
haiiro-shimeji / jstestdriver
Last active December 17, 2015 12:29
Simple example of init script. This is a script starting JsTestDriver Daemon
#!/bin/bash
NAME=JsTestDriver
USER=ikeda
DESC="JsTestDriber daemon"
JAVA=/usr/bin/java
PORT=4224
PATH=/usr/local/share/${NAME}
PIDFILE=${PATH}/${NAME}.pid