Skip to content

Instantly share code, notes, and snippets.

#!/Users/moro/opt/ruby192/bin/ruby
magicome = "# coding: #{Encoding.default_external.to_s.downcase}"
ARGV.each do |fname|
File.open(fname, 'r+:BINARY') do |src|
content = src.read
src.rewind
src.puts magicome
src.write content
end
@ded
ded / domready.js
Created February 24, 2011 08:46
Smallest x-browser DOM Ready, ever
function r(f){/in/(document.readyState)?setTimeout(r,9,f):f()}
int main(int argc, char** argv) { return 0; }
#include <iostream>
using namespace std;
template<class Cond, class Expr>
struct While {
While(Cond& cond, Expr& expr)
{
@mrkn
mrkn / enum_ports.rb
Created March 23, 2011 05:17
A sample script for calling EnumPortsW exported by winspool.drv from Ruby using dl library.
require 'dl/import'
require 'dl/types'
module Win32API
module Kernel32
extend DL::Importer
dlload "kernel32.dll"
include DL::Win32Types
# DWORD GetLastError(void)
@moro
moro / gist:1024620
Created June 14, 2011 10:05
Kaminari and pushState
(function($){
$('.pagination a[data-remote=true]').live('ajax:success', function(e){ window.history.pushState('', '', $(e.target).attr('href')) })
$(window).bind('popstate', function(){ $.ajax({url:window.location, dataType:'script'}) ; return true });
})(jQuery);
@ohnishiakira
ohnishiakira / togetter-auto-more.user.js
Created July 19, 2011 08:47
togetterの"続きを読む"を自動でクリック
// ==UserScript==
// @match http://togetter.com/li/*
// ==/UserScript==
(function (element) {
if (element !== null) {
var event = document.createEvent("MouseEvents");
event.initEvent("click", false, true);
element.dispatchEvent(event);
}
| 国語 社会 数学 理科 英語 3計 合計
---------+------------------------------------
得点 | 51 71 77 56 94 222 349
標準点 | 48 56 61 56 70 61 59
男女順位 | 53 32 16 30 1 14 20
全体順位 | 118 57 27 52 3 28 38
教科 | 得点 平均点 標準点 |
-----+--------------------+
diff --git a/ChangeLog b/ChangeLog
index b151bc4..f643541 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Thu Jul 27 10:35:00 2011 Kenta Murata <[email protected]>
+
+ * configure.in: change default compilers to gcc-4.2 and g++-4.2 on OS
+ X 10.7 (Lion).
@riywo
riywo / gist:1251364
Created September 29, 2011 17:37
形態素解析した結果を数えるとか

りすこがこんなの書いてて、聞いてみたら名詞だけ抜き出してcountとかやりたいとか。 そういう時はawk使うと便利ですよ(perlでもいいですが)

$ cat filename | awk '$4 ~ /^名詞/{print $1}' | sort | uniq -c | sort -n

4個目のカラムが「品詞」で始まる性質を使ってます。


@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 アーキテクチャを実現した。