Skip to content

Instantly share code, notes, and snippets.

View ryan5500's full-sized avatar

Tomoaki Sano ryan5500

View GitHub Profile
@ryan5500
ryan5500 / data-attribute-params.js
Created July 12, 2016 06:42
サードパーティJavaScriptの引数処理
/* <script data-stork-product-id="1234">
(function() {
//jsの読み込みコード
})();
</script> */
function getProductId() {
var scripts = document.getElementsByTagName('script');
var id;
@ryan5500
ryan5500 / load-jquery.js
Last active July 12, 2016 06:32
サードパーティJavaScriptのウィジェットの土台
var Stork = Stork || {};
Stork.$ = Stork.jQuery = jQuery.noConflict(true); // noconflictを使うことで外のバージョンと切り分けてjQueryをロードできる
@ryan5500
ryan5500 / for_new_browser.html
Created July 11, 2016 08:26
サードパーティJavaScriptでの古いブラウザ用のタグ埋め込み方法
<!-- HTML5対応しているブラウザならこれで良い。IEは10以降 -->
<script async src="http://somedomain.com/widget.js"></script>
@ryan5500
ryan5500 / extract_colors_from_css.rb
Last active August 29, 2015 14:06
Getting ColorScheme From Stylesheet
#!/usr/bin/env ruby
#
## How To Use
#
# $ ./extract_colors_from_css.rb style.css > out.html
# $ open out.html
#
#
@ryan5500
ryan5500 / ssh_wifi.rb
Created April 17, 2014 12:16
WAPM-APG300N / WAPM-AG300Nの設定コマンド入力を自動化するスクリプト
#!/usr/bin/env ruby
#
# Buffalo WAPM-APG300N / WAPM-AG300Nの設定を自動化するスクリプト
# sshでルーターに接続し、 コマンドを実行する。
#
require 'net/ssh'
host = ARGV[0] # ホスト名
@ryan5500
ryan5500 / classifier.rb
Created February 22, 2012 08:35
naive bayes classifier in "Programming Collective Intelligence" ruby implementation
# coding: utf-8
class Classifier
def initialize(get_features)
@feature_count = Hash.new {|h, k| h[k] = Hash.new {|h1, k1| h1[k1] = 0}}
@category_count = Hash.new {|h, k| h[k] = 0}
@get_features = get_features
end
def inc_feature_count(feature, category)
@ryan5500
ryan5500 / ssh.rb
Created January 19, 2012 06:14
use -ww option getting pid from ps with pty lib (because pty's terminal output width is narrow)
#!/usr/bin/env ruby
# conding: utf-8
#
# this script shows pid which contains 'some_process'
#
require 'pty'
require 'expect'
cmd = 'ssh username@somehost'
@ryan5500
ryan5500 / main.rb
Created January 19, 2012 02:39
get ruby process pid using pty lib
#!/usr/bin/env ruby
# conding: utf-8
#
# this script shows pid which contains 'ruby'
#
require 'pty'
cmd = 'ps aux | grep ruby'
PTY.spawn(cmd) do |reader, writer, pid|
@ryan5500
ryan5500 / dom_object.js
Created May 12, 2010 08:01
DOM <-> Object bridge with jQuery.fn.extend (Alex Sexton's way)
(function($) {
//papa crock's code
if (typeof Object.create !== 'function') {
Object.create = function(o) {
var F = function(){};
F.prototype = o;
return new F();
};
}
@ryan5500
ryan5500 / panning.html
Created May 1, 2010 09:05
zooming interface prototype
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.rightClick.js"></script>
<script type="text/javascript">
$(function() {
var zoom_ratio = 1;
$('#content').offset({top: $('#view_window').width() / 2, left: $('#view_window').height() / 2});