Skip to content

Instantly share code, notes, and snippets.

View mzp's full-sized avatar

Hiro Mizuno mzp

View GitHub Profile
@mzp
mzp / gist:728609
Created December 4, 2010 23:44
websocket.py
#!/usr/bin/env python
#-*- coding:utf-8 -*-
from optparse import OptionParser
import SocketServer
import struct
import hashlib
import itertools
class WebsocketHandler(SocketServer.BaseRequestHandler):
def handle(self):
(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"
1377 apply
1154 auto
1024 rewrite
994 destruct
867 intros
574 omega
539 assert
472 intro
440 simpl
345 unfold
@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))
-- 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のコードを利用した。
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"
type_ = [("d","42"),
("s","\"fish\"")]
flag = ["-","+",""]
gen = do f <- flag
(t,arg) <- type_
return $ "printf(\"%" ++ f ++ t ++ "\","++ arg ++ ")"
@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 = []
import System
import Data.List
main = getArgs >>= (return . concat . intersperse " ") >>= putStrLn
(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"