Skip to content

Instantly share code, notes, and snippets.

View omasanori's full-sized avatar

Masanori Ogino omasanori

View GitHub Profile
snippet class
abbr class Class(...): ...
class ${1:Name}(${2:object}):
"""${3:class documentation}"""
def __init__(self, ${4}):
"""${5:__init__ documentation}"""
${6:pass}
snippet def
abbr def function(...): ...
import os, tempfile
t = tempfile.NamedTemporaryFile()
path = os.path.abspath(t.name)
open(path)
--- pit.py.orig 2009-12-22 03:49:04.953125000 +0900
+++ pit.py.added 2009-12-22 03:47:37.671875000 +0900
@@ -18,13 +18,15 @@
else:
if not os.environ.has_key('EDITOR'):
return {}
- t = tempfile.NamedTemporaryFile()
+ t, path = tempfile.mkstemp()
c = yaml.dump(opts['config'] if opts.has_key('config') else Pit.get(name) ,default_flow_style=False)
t.write(c)
function! Test()
let l:foo = 1
python << __END__
print type(vim.eval('l:foo'))
print type(1)
__END__
endfunction
call Test()
;; 第1回 Scheme コードバトン
;;
;; ■ これは何か?
;; Scheme のコードをバトンのように回していき面白い物ができあがるのを楽しむ遊びです。
;; 次回 Shibuya.lisp で成果を発表します。
;; Scheme 初心者のコードを書くきっかけに、中級者には他人のコードを読む機会になればと思います。
;;
;; ■ 2 つのルール
;;
;; (1)自分がこれだと思える変更をコードに加えて2日以内に次の人にまわしてください。
;;; base64.clj --- Base64 encode/decode utility
;;
;; Copyright (c) 2010 OGINO Masanori <masanori.ogino@gmail.com>
;;
;; Permission is hereby granted, free to charge, to any person obtaining a
;; copy of this software and associated documentation files (the "Software"),
;; to deal in the Software without restriction, including without limitation
;; the rights to use, copy, modify, merge, publish, distribute, sublicense,
;; and/or sell copies of the Software, and to permit persons to whom the
;; Software is furnished to do so, subject to the following conditions:
@omasanori
omasanori / baton.clj
Created February 11, 2010 00:16 — forked from tnoborio/baton.clj
;; The First Edition Of Scheme Code Baton
;;
;; * What Is This?
;; This is a recreation that we pass Scheme codes as a baton and enjoy it
;; changed to something interesting.
;; Results are make public at Shibuya.lisp (event about Lisp held in Shibuya,
;; Japan).
;; We want code baton being a chance to write codes for beginner and to read
;; others codes for middles.
;;
(defn rand-assign
[n]
(take n (repeatedly #(rand-nth [true false]))))
(defn clause-satisfied?
[assign clause]
(some #(= (nth assign (first %)) (second %)) clause))
(defn formula-satisfied?
[assign formula]
@omasanori
omasanori / make_number.clj
Created May 26, 2011 00:07 — forked from nyuichi/sisoku.clj
A library to make certain number from some numbers.
(ns
^{:author "OGINO Masanori"
:see-also [["http://www.cs.nott.ac.uk/~gmh/book.html" "Programming in Haskell"]]
:doc "A library to make certain number from some numbers.
This library solves a well-known problem called \"Ten Puzzle\" or \"Countdown
Problem\", but the target number is not limited to 10. You can get any integer
or rational number. Also, the number of source numbers is not limited to 4.
Note that source numbers are *not always* used once, but never or once.
@omasanori
omasanori / bar.clj
Created July 22, 2011 23:10
An example to use record constructor
(ns bar
"Other namespace."
(:use foo))
(println "WARNING: constructor functions are enabled from 1.3 series!")
(println "WARNING: for now, try beta version at your risk.")
(println "Simple constructor: ->Point"
(->Point 10 20))