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 / pythonizedlisp.py
Created December 10, 2011 06:31
リポジトリにするほどのもんでもないためgistに退避。リポジトリは消す
#!/usr/bin/python
import re
class Unbound: pass
###utilities###
def car(lst):
return lst[0]
def cdr(lst):
return lst[1:len(lst)]
@ympbyc
ympbyc / iNegaeri.js
Created December 12, 2011 04:17
寝返ったーiOS4.2+版
var prevpos = 0; //一つ前の状態を管理
var negaeri = function(e){
var x;
if (Math.abs((x = Math.floor(e.accelerationIncludingGravity.x)) - prevpos) > 5)
{
if ((prevpos < 0 && x < 0) || (prevpos > 0 && x > 0)) return;
var stat = (x > -2 && x < 2) ? "上を向いたようです" : (x < prevpos) ? "右に寝返りをうったようです" : "左に寝返りをうったようです";
prevpos = x;
var d = new Date();
var tweet = d.getHours() + "時" + d.getMinutes() + "分" + d.getSeconds() + "秒に" + stat + " #negaeri";
@ympbyc
ympbyc / oop.lisp
Created February 2, 2012 10:49
jslisp oop
(define forrange (lambda (i to fn)
(if (>= (+ i 1) to)
(fn i)
(begin (fn i)
((. arguments callee) (+ i 1) to fn)))))
(= (. Object prototype get)
(lambda (attr) (get this attr)))
(= (. Number prototype foreach)
@ympbyc
ympbyc / bf.js
Created February 12, 2012 15:23
bf
//eg: bf('[bfcode]', {input: 'string', display: console.log})
function bf (str, opt) {
opt = opt || {};
var mem = new Array();
var ptr = 0;
if (!! opt.input) opt.input = opt.input.split('');
mem[0] = 0;
for (var i = 0; i < str . length; ++ i) {
switch (str[i]) {
case '+':
@ympbyc
ympbyc / カッコじゃないから恥ずかしくないもん.coffee
Created April 8, 2012 14:31
またつまらぬりすぷをかいてしまった. 引数を一つしか取れないようにすれば括弧いらないよねというもの。3時間で適当だしくそい
class Instructions
class Refer extends Instructions
constructor : (@variable, @next) ->
class Close extends Instructions
constructor : (@parameter, @body, @next) ->
class Frame extends Instructions
constructor : (@x, @next) ->
class Constant extends Instructions
constructor : (@value, @next) ->
class Assign extends Instructions
@ympbyc
ympbyc / Ym.js
Created May 10, 2012 15:18
よく使うものだけまとめる
function Ym (obj) {
// Ym() returns an instance of this Constructor
var Constructor = function (obj) {
if (obj)
for (key in obj)
if (obj.hasOwnProperty(key))
this[key] = obj[key]
}
// Copy the prototype of the object given to our Ym object's prototype
// javascript 1.8.2 or lator
@ympbyc
ympbyc / 0.src_router.js
Created May 14, 2012 09:13
titanium mobileの画面遷移をWebアプリのそれっぽく記述したい
exports.init = function () {
//ナビゲーショングループを入れるための空ウインドウ
var rootWin = Ti.UI.createWindow();
this.connect('top', {'rootWin' : rootWin});
}
function connect (windowName, cookie) {
var watcher,
next = function (controller) {
return function (cookie) {
@ympbyc
ympbyc / html.rb
Created June 25, 2012 17:18 — forked from pasberth/html.rb
require 'regparsec'
module HTMLParsers
extend RegParsec::Regparsers
ValidTags = ->(state) { one_of(*state.valid_tags) }
OpenTag = between('<', '>', ValidTags)
CloseTag = between('</', '>', ValidTags)
Line = try /[^\<\n]+/, &:to_s
@ympbyc
ympbyc / minimumscore.js
Created July 17, 2012 10:48
書き始めただけでまだ動かない。 -> 動くけどまだやりたい事と違う -> 近い!後で続き
var _ =
(function () {
var _, Wrapper, result, breaker, slice;
breaker = {};
slice = Array.prototype.slice;
Wrapper = function(obj) { this._wrapped = obj; };
_ = function (obj) { obj=obj||{}; return new Wrapper(obj) }
result = function(obj, chain) {
@ympbyc
ympbyc / memo.el
Created August 6, 2012 13:55
めも
(setq my-key-map nil) ;;初期化しとく
(defun hello-world () (interactive) (message "hello world")) ;;なんでinteractiveが要るのかよくわかってない
(defun fuck () (interactive) (message "fuck"))
(defun hoge ()
"function hoge" ;;説明?
(interactive) ;;この関数(hoge)は対話的に使う
(switch-to-buffer "*hackel*")
(if my-key-map nil ;;my-key-mapがnil以外(=真)なら何もしない