Skip to content

Instantly share code, notes, and snippets.

View hrstt's full-sized avatar

sato hiroyuki hrstt

View GitHub Profile
@hrstt
hrstt / string_array_outer_product.rb
Created August 30, 2011 08:17
Ruby: 配列同士の総当り組み合わせ
# Array#map
def cross(a, b)
a.map{|elem_a| b.map{|elem_b| elem_a.to_s + elem_b.to_s}}.flatten
end
# Array#product
def cros(a,b)
a.product(b).map{|elem| elem.join()}
end
@hrstt
hrstt / jquery_indices_object_reverse.js
Created September 5, 2011 02:42
jQuery: 複数オブジェクトの逆順並べ
$(function(){
// same class name jQuery object
$('div.some_class');
// these reverse indices jQuery object
// Once get indexed objects to array,
// Then use Array.reverse() to descending order.
// At last, convert array object to jQuery object.
$($('div.some_class').get().reverse());
});
@hrstt
hrstt / format_decimal.js
Created September 5, 2011 06:34
javascript: 数字の桁揃え
// repeat character
String.prototype.repeat = function(num) {
return new Array(num + 1).join(this);
}
// convert strings and filling zero
String.prototype.decimalf = function(num) {
if (isNaN(this) || isNaN(num) || num < 0){ return this;};
ary = this.split(".");
if(num == 0) { return ary[0]; };
ary[1] = (((ary.length>2)? ary[1] : "") + "0".repeat(num)).substring(0,num);
@hrstt
hrstt / script_engine_check.js
Created October 7, 2011 04:55
JScript: IEのJScript.dll バージョン表示
// JScript.dll(IE) version check script
function getScriptEngineInfo(){
var s = ScriptEngine() + " Version ";
s += ScriptEngineMajorVersion() + "." + ScriptEngineMinorVersion() + "." + ScriptEngineBuildVersion();
return(s);
}
alert(getScriptEngineInfo());
@hrstt
hrstt / monotone_print.xls
Created October 12, 2011 05:20
Excel VBA: シートまたぎの印刷をすべて白黒にするマクロ
Sub MonotonePrint()
Dim Current As Worksheet
For Each Current In Worksheets
' 印刷設定を白黒に
Current.PageSetup.BlackAndWhite = True
Next
' ブック印刷
ActiveWorkbook.Worksheets.PrintOut
@hrstt
hrstt / git-diff-zip.sh
Created October 30, 2011 22:12 — forked from func09/git-diff-zip.sh
Gitで特定のコミットからの差分ファイルだけ抜き出してZipにする
git archive --format=zip --prefix=projectname/ HEAD `git diff --name-only <commit>` -o archive.zip
@hrstt
hrstt / rmagick_bench_mark_test.rb
Created November 14, 2011 07:34
rmagick bench mark test
#-*- coding: utf-8 -*-
require 'benchmark'
# When you convert a jpg image using ImageMagick,
# convert command options combination make a big difference in performance.
# so i try to do a benchmark test about parameter combination.
#
# Fastest combination : when given define option with width and height.
# Secondary combination : when given define with either width or height, debug option make faster.
@hrstt
hrstt / ubuntu_tweak.sh
Created November 25, 2011 00:03
Ubuntu tweak (11.10)
# gnome-tweak
sudo add-apt-repository ppa:tualatrix/next
sudo apt-get update
sudo apt-get install ubuntu-tweak
# icon set
sudo add-apt-repository ppa:tiheum/equinox
sudo apt-get update
sudo apt-get install faenza-icon-theme
@hrstt
hrstt / .sh
Created February 16, 2012 00:52
redmine でgem のバージョンが高すぎるときの対応 ref: http://qiita.com/items/2536
$ gem install -v 1.3.7 rubygems-update
$ update_rubygems
@hrstt
hrstt / .sh
Created February 16, 2012 00:58
Ubuntu 11.10 でsynapticを使うと出てくるアレ. ref: http://qiita.com/items/2537
$ sudo apt-get install gtk2-engines-pixbuf