Skip to content

Instantly share code, notes, and snippets.

View hsbt's full-sized avatar
🏠
Working from home

Hiroshi SHIBATA hsbt

🏠
Working from home
View GitHub Profile
@nz
nz / solr-3.6.0-kuromoji-schema.xml
Created April 20, 2012 11:25
Solr 3.6.0 schema.xml with Kuromoji analysis for text_jp
<?xml version="1.0" encoding="UTF-8"?>
<schema name="sunspot" version="1.0">
<types>
<!-- Scalar field types -->
<fieldType name="boolean" class="solr.BoolField" omitNorms="true"/>
<fieldType name="date" class="solr.DateField" omitNorms="true"/>
<fieldType name="rand" class="solr.RandomSortField" omitNorms="true"/>
<fieldType name="sdouble" class="solr.SortableDoubleField" omitNorms="true"/>
@mperham
mperham / convert.rake
Created March 15, 2012 17:44
Ruby script to update MySQL from Latin1 to UTF8 without data conversion
desc "convert a latin1 database with utf8 data into proper utf8"
task :convert_to_utf8 => :environment do
puts Time.now
dryrun = ENV['DOIT'] != '1'
conn = ActiveRecord::Base.connection
if dryrun
def conn.run_sql(sql)
puts(sql)
end
else
#!/usr/bin/env perl
use strict;
use warnings;
use Pod::Usage;
use Text::Markdown 'markdown';
use HTML::TreeBuilder;
use List::Util 'max';
@tily
tily / scaling_isomorphic_javascript_code.ja.markdown
Last active May 1, 2023 09:03
サバクラ両方で動く JavaScript の大規模開発を行うために

サバクラ両方で動く JavaScript の大規模開発を行うために

原文:Scaling Isomorphic Javascript Code (This is just for study, please contact me at tily05 atmark gmail.com if any problem.)

考えてみれば Model-View-Controller とか MVC ってよく聞くよね。実際どんなものか知ってる? 抽象的に言うなら「オブジェクト情報の保持されるグラフィック・システム (つまり、ラスターではないグラフィック。ゲームとか) 上に構築された、表示系を中心としたアプリケーションにおいて、主要な機能どうしの関わりをうまく分離すること」とでも言おうか。もう少し深く考えを押し進めてみれば、これは当然、他のさまざまなアプリケーションにもあてはまる言葉 (bucket term ?) だ。

過去に多くの開発コミュニティが MVC による解決案を提供し、それによってよくあるユースケースにうまく対処し、地位を築くことができた。例をあげるなら、Ruby や Python コミュニティは Rails や Django を作り、MVC アーキテクチャを実現した。

@cefstat
cefstat / lion-fullscreen.patch
Created November 10, 2011 19:31
Patch for Emacs fullscreen support under Mac OS X 10.7 (Lion)
=== modified file 'lisp/term/ns-win.el'
--- old/lisp/term/ns-win.el 2011-10-01 20:32:01 +0000
+++ new/lisp/term/ns-win.el 2011-11-10 16:22:51 +0000
@@ -928,6 +928,10 @@
(add-to-list 'frame-creation-function-alist '(ns . x-create-frame-with-faces))
(add-to-list 'window-system-initialization-alist '(ns . ns-initialize-window-system))
+(declare-function ns-toggle-fullscreen-internal "nsfns.m" ())
+(defun ns-toggle-fullscreen ()
+ (interactive)
@akiinyo
akiinyo / FizzBuzz
Created October 27, 2011 13:14
素直にかくとこうなる。
range = 1..100
range.each do |num|
if (num%3 == 0 && num%5 == 0)
p 'FizzBuzz'
elsif (num%3 == 0)
p 'Fizz'
elsif (num%5 == 0)
p 'Buzz'
else
p num
@sgk
sgk / trac2down.py
Created October 14, 2011 09:35
Trac Wiki to Markdown converter
#!/usr/bin/python
# vim:set fileencoding=utf-8 sw=2 ai:
import sqlite3
import datetime
import re
SQL = '''
select
name, version, time, author, text
@arirusso
arirusso / img_convert.rb
Created September 30, 2011 16:44
convert html img tags to rails image_tag calls
#!/usr/bin/env ruby
require "nokogiri"
# opens every file in the given dir tree and converts any html img tags to rails image_tag calls
#
# example usage:
# ruby convert.rb ~/my_rails_app/app/views
#
# ***be careful and backup before using this***
#
@ogawa
ogawa / homebrew-emacs-23.3b.diff
Created July 22, 2011 16:40
emacs.rb with emacs-inline and fullscreen patches.
diff --git a/Library/Formula/emacs.rb b/Library/Formula/emacs.rb
index 856a34a..20654fd 100644
--- a/Library/Formula/emacs.rb
+++ b/Library/Formula/emacs.rb
@@ -28,6 +28,7 @@ class Emacs < Formula
def patches
p = []
+ p0 = []
@knu
knu / iTerm2-rich-text-copy.patch
Created July 5, 2011 04:37
Make iTerm2's copy also save the selected region in rich text format.
From 9fbd75b0ba43d2e37aae4ed1b48752baa1908cd3 Mon Sep 17 00:00:00 2001
From: Akinori MUSHA <[email protected]>
Date: Tue, 5 Jul 2011 11:00:32 +0900
Subject: [PATCH] Make copy() also save the selected text in rich text format.
---
Headers/iTerm/PTYTextView.h | 2 +
PTYTextView.m | 161 +++++++++++++++++++++++++++++++++++++++++-
2 files changed, 159 insertions(+), 4 deletions(-)