Skip to content

Instantly share code, notes, and snippets.

View mzp's full-sized avatar

Hiro Mizuno mzp

View GitHub Profile
@mzp
mzp / git-blog
Created October 11, 2009 12:26
git blog: generate blog template from git repository
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
#
# git blog: generate blog template from git repository
#
# Usage:
# $ git blog > diary.txt
#
# and upload diary.txt by some methods.
#
object Obj{
type T = {
/** */
def f : Unit
}
}
(require 'auto-complete)
(defvar ac-coq-sources
'(ac-source-coq-tactics
ac-source-coq-command
ac-source-coq-keyword))
(ac-define-dictionary-source
ac-source-coq-keyword
'("as"
(require 'auto-complete)
(defvar ac-coq-sources
'(ac-source-coq-tactics
ac-source-coq-command
ac-source-coq-keyword))
(ac-define-dictionary-source
ac-source-coq-keyword
'("as"
import System
import Data.List
main = getArgs >>= (return . concat . intersperse " ") >>= putStrLn
@mzp
mzp / github
Created May 29, 2010 06:41
github util command
#!/usr/bin/env ruby
require 'ostruct'
require 'rubygems'
require 'net/http'
require 'yaml'
require 'pit'
class Hash
def to_url_params
elements = []
type_ = [("d","42"),
("s","\"fish\"")]
flag = ["-","+",""]
gen = do f <- flag
(t,arg) <- type_
return $ "printf(\"%" ++ f ++ t ++ "\","++ arg ++ ")"
tell application "Alloy4" to activate
tell application "System Events"
tell process "Alloy 4"
tell menu bar 1
tell menu "File"
click menu item "Reload all"
end tell
tell menu "Execute"
-- alloy 4( http://alloy.mit.edu/alloy4/ )でコードをリロードして、解析をExecuteするAppleScript
-- emacsの場合は:
--
-- (defun alloy-execute ()
-- (interactive)
-- (shell-command "osascript /path/to/alloy-execute.scpt &"))
-- (define-key alloy-mode-map "\C-cr" 'alloy-execute)
--
-- とするといい感じかも。
-- GUI操作部分は、http://d.hatena.ne.jp/zariganitosh/20090218/1235019896のコードを利用した。
@mzp
mzp / ruby.l
Created October 24, 2010 08:35
informal ruby syntax definition from http://wiki.ruby-standard.org/wiki/Lexical_structure
(define-rule source-character (annot "any character in ISO/IEC 646"))
(define-rule line-terminator (seq (opt (ascii "0x0d")) (ascii "0x0a")))
(define-rule separator (or (lit ";") (annot "''line-terminator'' here")))
(define-rule single-variable-assignment-expression (seq (seq (seq variable (annot "no ''line-terminator'' here")) (lit "=")) operator-expression))
(define-rule whitespace (or (ascii "0x09") (or (ascii "0x0b") (or (ascii "0x0c") (or (ascii "0x0d") (or (ascii "0x20") (seq (seq (lit "\") (opt (ascii "0x0d"))) (ascii "0x0a"))))))))
(define-rule comment (or single-line-comment multi-line-comment))
(define-rule single-line-comment (seq (lit "#") (opt comment-content)))
(define-rule comment-content line-content)
(define-rule line-content (many-1 source-character))
(define-rule multi-line-comment (seq (seq multi-line-comment-begin-line (opt multi-line-comment-line)) multi-line-comment-end-line))