Skip to content

Instantly share code, notes, and snippets.

View func-hs's full-sized avatar

松舘 剛志 func-hs

  • Sapporo, Japan
View GitHub Profile
@raa0121
raa0121 / README.txt
Created October 18, 2011 17:31
ニコ生アラート(本家)のAPIを叩いて、入ってるコミュニティの生放送をTwitterにPostするRubyBot
#=================================================================================
#【アプリ名】 ニコ生アラート(本家)のAPIを用いたTwitterBot
#【著作権者】 raa0121
#【対応環境】
# Linux Mac
# gem install twitter_oauth
# gem install mechanize
# 後は ruby nicolivealert.rb で起動が可能です。
#【開発環境】 Cygwin (WindowsVista SP2 32bit)
#【開発言語】 Ruby(1.9.2-p180)(DL元:http://www.artonx.org/data/asr/ )
@pasberth
pasberth / monad.scm
Last active October 3, 2020 21:48 — forked from anonymous/monad.scm
(define (then m k)
(bind m (lambda (_) k)))
(define (state-unit a)
(lambda (s) `(,a ,s)))
(define (state-bind m k)
(lambda (s)
(let* { [r (m s)]
[a (car r)]
(ns macro-combinator
(:refer-clojure :exclude [=]))
(defn prim [x] (fn [a] `(fn [~x] ~a)))
(defn in [v a] (v a))
(defn where [a v] (v a))
(defn = [v b] (fn [a] `(~(v a) ~b)))
(defn <- [v b] (fn [a] `(>>= ~b ~(v a))))
(println (in (= (prim 'x) 42) 'x))
; ((clojure.core/fn [x] x) 42)
@pasberth
pasberth / chomado.io
Last active December 16, 2015 05:38
(((o(*゚▽゚*)o)))(((o(*゚▽゚*)o)))(((o(*゚▽゚*)o)))(((o(*゚▽゚*)o)))
setSlot("", method(x, "(" with(x) with(")")))
o := method(if(call argAt(0)) then(return("(o" with(call argAt(0) code))) else(return(self with("o)"))))
(((o(*゚▽゚*)o))) println
@pasberth
pasberth / objective.zsh
Created April 16, 2013 01:21
zsh で OOP 的な記法をする感じ
# -*- sh -*-
# objective.zsh
# $ pwd
# /Users/pasberth
# $ pwd.dirname
# /Users
# $ pwd.basename
# pasberth
# $ pwd.ls -Ahl --color=auto
# lrwxr-xr-x 1 pasberth staff 38 8 22 2012 .zlogin -> /Users/pasberth/.dotfiles/home/.zlogin
(defn infixing-infix [rules infix-rule [a b & code]] (cond
(nil? b) `(~a)
(nil? (rules b)) (cond
(seq? a) (infixing-infix rules infix-rule `((~@a ~b) ~@code))
:else (infixing-infix rules infix-rule `((~a ~b) ~@code)))
:else (let [ b-rule (rules b) ] (cond
(< (b-rule :priority) (infix-rule :priority)) `(~a (~b ~@code))
(> (b-rule :priority) (infix-rule :priority)) (infixing-infix rules infix-rule `((~b ~a) ~@code))
(= :left (b-rule :recur) (infix-rule :recur)) `(~a (~b ~@code))
@athos
athos / tramp.clj
Last active December 16, 2015 07:08
(declare odd?)
(defn even? [x]
(if (== 0 x)
true
#(odd? (- x 1))))
(defn odd? [x]
(if (== 1 x)
true
@pasberth
pasberth / monad.clj
Last active December 17, 2015 00:29
protocol では return とか定義できないから、いい感じの多態をするには。
(defprotocol Monad
(monad-context [this m]))
(defrecord MonadUnit [a])
(defrecord MonadBind [m k])
(extend-protocol Monad
MonadUnit
(monad-context [this m] m)
MonadBind
@pasberth
pasberth / monad-zip.clj
Created May 8, 2013 17:18
granjure で monad-zip
(use 'granjure.control.monad.zip)
(use 'granjure.data.list)
(use 'granjure.data.maybe)
(import '[granjure.data.maybe Just Nothing])
(println (do-mzip (x | x <- '(1 2 3))))
; (1 2 3)
(println (do-mzip (x | x <- '(1 2 3) :when (even? x))))
; (2)
@pasberth
pasberth / type-classes.rb
Created May 8, 2013 19:30
動的言語ではObjectをうまく活用することで型クラスのように振る舞わせることができる
module Monad
def return!(a); end
def bind(m,k); end
def join(m,k); (bind m,->(_){k}); end
end
module MonadPlus; include Monad
def mzero; end
def guard(cond); cond ? (return! nil) : mzero; end