Skip to content

Instantly share code, notes, and snippets.

View tmyymmt's full-sized avatar

Tomoya Yamamoto tmyymmt

View GitHub Profile
@tmyymmt
tmyymmt / attach.inc.php.1.5.0.diff
Created September 6, 2014 03:38
puwikiki attach zip /plugin/attach.inc.php.1.5.0.diff
42,43d41
< define('PLUGIN_OPEN_AVOID_DIRECT', FALSE); // TRUE or FALSE
<
160c158
< global $vars, $_attach_messages, $notify, $notify_subject;
---
> global $_attach_messages, $notify, $notify_subject;
190,221d187
< if ($vars['extract_mode'] == 'on') {
< switch (strtolower(substr($file['name'], -4))) {
// copy from Janx Spirit http://janxspirit.blogspot.jp/2011/11/introduction-to-casbah-scala-mongodb.html
//connect to a MongoDB server
val mongo = MongoConnection("anduin")
//create/connect to a collection
val coll = mongo("casbah_examples")("movies")
//drop collection
coll.dropCollection
@tmyymmt
tmyymmt / .tmux.conf
Created November 12, 2012 06:39
.tmux.conf for osx
bind -r ^ resize-pane -R 5
bind -r C-^ resize-pane -L 5
bind 0 kill-pane
bind 2 split-window -v
bind 3 split-window -h
@tmyymmt
tmyymmt / init.el
Created November 7, 2012 16:25
init.el for cocoa emacs
; css-mode
(defun coding-style-css ()
(setq css-indent-offset 2))
(add-hook 'css-mode-hook 'coding-style-css)
;
(setq truncate-lines t)
(setq truncate-partial-width-windows t)
@tmyymmt
tmyymmt / grep-specs2-unit-selected-buffer.l
Created October 11, 2012 15:00
Grep description of specs2 unit specification in selected buffer on xyzzy
; Grep description of specs2 unit specification in selected buffer on xyzzy
; Please copy & paste following code at your .xyzzy
; Usage: M-x grep-specs2-unit-selected-buffer
(defun grep-specs2-unit-selected-buffer ()
(interactive)
(grep " should \\| in " (selected-buffer)))
def compute1(maybeFoo: Option[Foo]): Option[Int] =
for {
foo <- maybeFoo
bar <- foo.bar
baz <- bar.baz
} yield baz.compute
// for compute2
import scalaz._
import Scalaz._
for {
foo <- maybeFoo
bar <- foo.bar
baz <- bar.baz
} yield baz.compute
@tmyymmt
tmyymmt / monad1.java
Created September 16, 2012 16:45
Monad 1
if (foo != null) {
Bar bar = foo.getBar();
if (bar != null) {
Baz baz = bar.getBaz();
if (baz != null)
return baz.compute();
else
return null;
}
else
@tmyymmt
tmyymmt / SolutionForNestedMatchStatements.scala
Created September 15, 2012 18:56
Solution for nested match statements
// see https://gist.github.com/2382341
// scalaz for only solution3
import scalaz._
import Scalaz._
object SolutionForMultiNestedMatchforMyStudy {
def f(num: Int): Option[Int] = {
num match {
@tmyymmt
tmyymmt / HexBytesUtil.scala
Created September 15, 2012 09:37
hex2bytes and bytes2hex fixed
object HexBytesUtil {
def hex2bytes(hex: String): Array[Byte] = {
hex.replaceAll("[^0-9A-Fa-f]", "").sliding(2, 2).toArray.map(Integer.parseInt(_, 16).toByte)
}
def bytes2hex(bytes: Array[Byte], sep: Option[String] = None): String = {
sep match {
case None => bytes.map("%02x".format(_)).mkString
case _ => bytes.map("%02x".format(_)).mkString(sep.get)