Skip to content

Instantly share code, notes, and snippets.

View ympbyc's full-sized avatar
💭
Lisping in the mountains.

Minori Yamashita ympbyc

💭
Lisping in the mountains.
View GitHub Profile
@ympbyc
ympbyc / clock-ticking-io.coffee
Last active December 27, 2015 19:59
Clock Ticking I/O. Not sure if it has any benefits.
#### Clock Ticking Model ####
fs = require 'fs';
## Probably, clock should be global rather than per function
clock = (f) ->
cache = {}
(args...) ->
time = args[0]
@ympbyc
ympbyc / io.clj
Last active December 27, 2015 11:09
PFIO
(++ (print "name:")
(read)
(FN :name
(read)
(FN :age
(print (str "hello, " name " of age " age))
(getJson "http://...")
(FN :result ...))))))
;;=> ["name: " print read :name name
;; "age: " print read :age name
@ympbyc
ympbyc / pasta.cljs
Last active December 24, 2015 05:29
Pasta for ClojureScript
;;;; 2013 Minori Yamashita <[email protected]>
;;;; MIT
(defmacro deftransition
"Define a function that receives the current state and returns a patch to it.
The patch returned will get conjed onto the state.
Use `watch-transition` to react to the state change."
[name params & body]
`(defn ~name [app# & pars#]
(let [diff# (apply (fn ~params ~@body) (cons @app# pars#))
@ympbyc
ympbyc / fact.nadeko.scm
Last active December 24, 2015 01:29
plain old factorial
;;nadeko
(= fact n
(=? n 0
1
(* n (fact (- n 1)))))
@ympbyc
ympbyc / list-of-languages.json
Created August 14, 2013 06:43
List of languages that show up in the selection box at "Trending repositories on GitHub today". 2013/8/14
["ABAP",
"ActionScript",
"Ada",
"Apex",
"AppleScript",
"Arc",
"Arduino",
"ASP",
"Assembly",
"Augeas",
@ympbyc
ympbyc / core-async-how-to-use.clj
Last active December 20, 2015 15:28
core.asyncの意味が分かった。
(ns experiment
(:use [cljs.core.async :only [>! <! chan timeout put!]])
(:use-macros [cljs.core.async.macros :only [go]]))
;;; Wire events to a channel. Channels are like blocking queues.
(def clicker
(let [c (chan)]
(.addEventListener js/document "click" (fn [] (put! c "clicked")))
c))
@ympbyc
ympbyc / havingfun.clj
Last active December 20, 2015 14:19
Playing around with core.async
(require '[clojure.core.async :as async :refer :all])
(defn map-chan [f in]
(let [c (chan)]
(go (loop []
(>! c (f (<! in)))
(recur)))
c))
@ympbyc
ympbyc / Castorocauda3.gif
Last active December 20, 2015 11:59
castorocauda
Castorocauda3.gif
(ns castorocauda.example
(:require [castorocauda.core :as castorocauda])
(:use [castorocauda.util :only [dom-ready q-select]]
[castorocauda.timeline :only [tl-map tl-filter tl-merge dom-events]])
(:use-macros [castorocauda.macros :only [run-app]]))
(defn render-all [{:keys [a b result]
:or {a 0, b 0, result 0}}]
[:div
@ympbyc
ympbyc / super_simple_twitter.php
Last active December 19, 2015 16:29
最近のPHPすげえ
<?php
namespace Tweets;
//type Tweet = ["id" => String,
// "name" => String,
// "text" => String,
// "deleted" => Boolean]
//String * String -> Tweet
function mkTweet ($name, $text) {