Skip to content

Instantly share code, notes, and snippets.

@honbin
honbin / ssl.conf
Created November 21, 2012 03:44
名前ベースのSSLバーチャルホスト設定
##
## SSL Virtual Host Context
##
NameVirtualHost *:443
#以下コメントアウト
@honbin
honbin / gist:4085110
Created November 16, 2012 07:31
create .gitkeep
#URL: http://d.hatena.ne.jp/conceal-rs/20100127/1264573975
find . -type d -empty -not -path './.git*' -exec touch {}\/.gitkeep \;
## surround.vim how to
# ds'
foo 'b*ar' baz #=>foo b*ar baz
# cs'"
foo 'b*ar' baz #=>foo "b*ar" baz
#ys$)
a = Array.new *foo, bar #=> a = Array.new (*foo, bar)
# reference url: http://jp.rubyist.net/magazine/?0038-MapAndCollect#l2
#reduce for lisp
# (reduce (lambda (i j) (+ i j)) '(3 4 5 6))
#reduce for ruby
p [3, 4, 5, 6].reduce {|i, j| i + j } #=>18
#inject for smalltalk
# #(3 4 5 6) inject: 0 into: [:i :j | i + j ]
#inject for ruby
p [3, 4, 5, 6].inject(0) {|i, j| i + j } #=>18
# reference url: http://jp.rubyist.net/magazine/?0038-MapAndCollect#l2
# map for lisp
# (map 'list (lambda (i) (+ i 1)) '(3 4 5 6))
#map for ruby
p [3, 4, 5, 6].map {|i| i + 1 } #=>[4, 5, 6, 7]
#collect for smalltalk
# #(3 4 5 6) collect: [:i | i + 1 ]
#collect for ruby
p [3, 4, 5, 6].collect {|i| i + 1 } #=>[4, 5, 6, 7]
@honbin
honbin / tmuxinator.md
Created October 11, 2012 08:51
tmuxinator

tmuxinatorとは

tmuxで起動するセッション定義を事前に設定できるツール

事前に必要な環境

  • tmux
  • gem

インストール方法

@honbin
honbin / gist:3065535
Created July 7, 2012 08:49
担当エリアの担当者名を出力するサンプル
<?php
$area = "setagaya";
$area_list = array(
1 => "setagaya",
2 => "sinagawa"
);
$staff_list = array(
@honbin
honbin / gist:2972021
Created June 22, 2012 10:45
ajaxzipの引数thisをディープコピーしてvalueの値を半角数値にして返す
(function($) {
convertHalfwidthNum = function(obj) {
var cObj = $.extend(true, {}, obj);
var str = '';
var v = cObj.value;
var len = v.length;
for (var i = 0; i < len; i++) {
var c = v.charCodeAt(i);
if ((c >= 65296 && c <= 65305))
str += String.fromCharCode(c - 65248);
@honbin
honbin / gist:2927815
Created June 14, 2012 03:00
jquery.validate 使い方
//参考サイト:http://d.hatena.ne.jp/sugyan/20090312/1236815025
// http://d.hatena.ne.jp/kudakurage/20091211/1260521031
//独自バリデーション追加方法
jQuery.validator.addMethod("isKatakana", function(value, element) {
return this.optional(element) || /^([ァ-ヶーァ-ン゙゚]+)$/.test(value);
}, "カタカナで入力してください"
);
//バリデーション設定方法
//投稿
// @url /posts/:id
var posts = {
id: "", // 投稿のID (Mongo[ORMapper]の仕様に合わせる)
img: "http://example.com/iamges/foo.png", // 画像のURL
body: "", // 投稿文
tags: [ // Tagの情報
{ id: "1", name: "Ruby" },
{ id: "4", name: "JavaScript" },
{ id: "6", name: "Python" }