Skip to content

Instantly share code, notes, and snippets.

View ichiban's full-sized avatar

Yutaka Ichibangase ichiban

View GitHub Profile
angular.module('app').controller('MainController', ['$scope', 'userResource', function($scope, userResource) {
$scope.current = {};
$scope.$watch('current.user', function(user) {
if (user) { return; }
var user = userResource();
user.then(function(user) {
$scope.current.user = user;
});
});
}]);
(function() {
'use strict';
var overlayVisible = 'overlay--visible';
var $document = $(document);
$document.on('overlay:open', function() {
var $body = $('body');
var $overlay = $('.overlay');
(require :fare-matcher)
;; Clojure or ML's function syntax style defun
(defmacro defunction (name &body body)
(flet ((match-clause (clause)
(cons `(list ,@(car clause)) (cdr clause))))
(let ((args (gensym)))
`(defun ,name (&rest ,args)
(fare-matcher:ematch ,args
@ichiban
ichiban / WhatIsJavaLibraryPaty.java
Created August 1, 2011 11:25
script to see what java.library.path is.
import static java.lang.System.*;
public class WhatIsJavaLibraryPath {
public static void main(String[] args) {
out.println(getProperty("java.library.path"));
}
}
@ichiban
ichiban / cat.ml
Created September 21, 2011 15:32
simple 'cat' command in O'Caml
(* cat.ml *)
(* simple cat command in O'Caml *)
open Sys
open Array
open List
let print_channel in_channel =
let rec iter _ =
print_endline (input_line in_channel);
@ichiban
ichiban / gist:1290650
Created October 16, 2011 08:21
Flymake Ocaml settings that doesn't hang my GNU Emacs 23.3.1 (x86_64-apple-darwin10.7.0, NS apple-appkit-1038.35)
;; Flymake Ocaml
(add-to-list 'exec-path "~/bin")
(defun flymake-ocaml-init ()
(flymake-simple-make-init-impl
'flymake-create-temp-with-folder-structure nil nil
(file-name-nondirectory buffer-file-name)
'flymake-get-ocaml-cmdline))
(defun flymake-get-ocaml-cmdline (source base-dir)
(list "ocaml_flycheck.pl"
(list source base-dir)))
;;; The following lines added by ql:add-to-init-file:
#-quicklisp
(let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp"
(user-homedir-pathname))))
(when (probe-file quicklisp-init)
(load quicklisp-init)))
;;; make cffi to dlopen homebrewed libraries
(require :cffi)
@ichiban
ichiban / gist:1350361
Created November 9, 2011 04:19
これ聴きながら仕事してます
$ cat > kiku.c
#include <pthread.h>
char c;f(){while(1)c=~getchar();}main(t,p){pthread_create(&p,NULL,f,NULL);for(t=0;;t++)putchar(t>>~c|t>>5|t>>1000-c|t>>c);}
$ make kiku
cc kiku.c -o kiku
kiku.c: In function ‘main’:
kiku.c:2: warning: passing argument 1 of ‘pthread_create’ from incompatible pointer type
kiku.c:2: warning: passing argument 3 of ‘pthread_create’ from incompatible pointer type
$ sudo tcpdump | ./kiku | sox -traw -r8k -c1 -eunsigned -b8 - -d
@ichiban
ichiban / xor_texture.lisp
Created January 6, 2012 13:57
XOR texture in Common Lisp
(require :lispbuilder-sdl)
(defun run ()
(sdl:with-init ()
(sdl:window 320 240)
(draw-xor-texture)
(sdl:with-events ()
(:quit-event () t)
(:idle
(sdl:update-display)))))
@ichiban
ichiban / app.rb
Created January 20, 2012 16:17
example for big-upload
require 'sinatra'
require 'yajl/json_gem'
set(:mongrel2_upload) do |value|
condition do
case value
when :start
request.env.key?('x-mongrel2-upload-start')
when :done
request.env.key?('x-mongrel2-upload-done')