Skip to content

Instantly share code, notes, and snippets.

View hrstt's full-sized avatar

sato hiroyuki hrstt

View GitHub Profile
# Array#transpose
a = [[1,2,3],[4,5,6],[7,8,9]]
a.transpose
#=> [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
# same return
a[0].zip(*a[1..-1])
#=> [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
@hrstt
hrstt / jquery_indices_object_reverse.js
Created March 8, 2012 02:00
複数オブジェクトの逆順並べ ref: http://qiita.com/items/3062
$(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 / hash_memorize_sample.rb
Created March 22, 2012 07:17
hash memorize
# recursive call with hash
# calcuation procedure define in block of constractor.
# this hash return response first, but its key size is limited about 1,000 keys
# => occur SystemStackError
h = Hash.new{|hash, value| hash[value] = 1 + hash[value -1] + hash[value -2]}
h[0] = 1
h[1] = 1
puts h[3] #=> 5
puts h[100] #=> 1146295688027634168201
Option Explicit
Function nslookup(ip As String) As String
Dim wsh, exec, cmd, res As String, i As Integer
Dim buf() As String
Set wsh = CreateObject("WScript.Shell")
cmd = "nslookup " & ip
SELECT * FROM INFORMATION_SCHEMA.TABLES
SELECT * FROM INFORMATION_SCHEMA.COLUMNS
@hrstt
hrstt / select_operation_test.html
Created June 14, 2012 06:41
select 要素 の操作(隠したりdisableにしたり
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<script>
$(function(){
var target = $("select#test");
/** 単純に操作不可にする方法
target.change(function() {
target.attr("disabled","disabled");
@hrstt
hrstt / git_rm_all.sh
Created June 19, 2012 04:59
ファイル削除後にgit rm を一括でする
git status | grep deleted: | awk '{print $3}' | xargs git rm
# ただしカラースキーム付きの場合は保証しない.
@hrstt
hrstt / Mastermind.java
Created July 4, 2012 12:57
mastermindゲームの課題回答用
package jp.hrst.sample;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class Mastermind {
@hrstt
hrstt / ghci_color_conf.sh
Created October 18, 2012 04:35
coloring the code in ghci
# ------
# > sudo cabal install hscolour
# > vi ~/.profile
if [ -f "$HOME/.profile" ]; then
. $HOME/.profile
fi
alias ghci='ghci 2>&1 | HsColour -tty '
@hrstt
hrstt / sublime_user_settings.json
Created November 14, 2012 05:22
sublime text 2 user settings
// Settings in here override those in "Default/Preferences.sublime-settings", and
// are overridden in turn by file type specific settings.
{
"draw_white_space" : "all",
"highlight_line": true,
"tab_size": 4,
"line_padding_top": 4,
"font_size": 12,
"font_face": "Consolas",
"word_wrap" : true,