Skip to content

Instantly share code, notes, and snippets.

View suruseas's full-sized avatar

yukihiro amadatsu suruseas

View GitHub Profile
@suruseas
suruseas / open_file.sh
Created September 2, 2016 07:53
読み込んだファイルを一行づつechoする
#!/bin/sh
OUTPUTFILE=$1
while read line || [[ -n $line ]]; do
echo $line
done < $OUTPUTFILE
exit 0
@suruseas
suruseas / table_sort_2.js
Created February 12, 2014 16:13
テーブル(id=#table)の行をソートするよ。その二。
$('#table tr').sort(function(a, b){return ( Number( $('input:first-child', $('td:eq(1)', a) ).val()) - Number( $('input:first-child', $('td:eq(1)', b) ).val() ) );}).each(function(){$('#table').append($(this));});
@suruseas
suruseas / table_sort_1.js
Created February 12, 2014 16:11
テーブル(id=#table)の行をソートするよ。その一。
$('#table tr').sort(function(a, b){return ( Number( $('td:eq(0)', a).text() ) - Number( $('td:eq(0)', b).text() ) );}).each(function(){$('#table').append($(this));});
@suruseas
suruseas / convert.rb
Created September 13, 2012 05:44
\xxx\xxxの8進数形式で文字が表記されているテキストをそのままバイナリ変換して新たにファイルに保存する
while argv = ARGV.shift
File::open(argv, "r") do |rf|
File::open("#{File::realpath(rf)}.cnv", "w") do |wf|
while line = rf.gets
wf.puts line.gsub(/\\([0-9]+)/){
[$1.oct].pack("C*")
}
end
end
end
@suruseas
suruseas / config.ru
Created August 27, 2012 14:57
デザイン作成時等、静的HTMLサーバをたてるときに。publicフォルダにリソース突っ込んでくれればOK.
require 'sinatra'
helpers do
def directory_index(path)
['index.html', 'index.htm' ].map{|i| "./public/#{path}/#{i}" }
end
end
get '*/' do
path = request.path_info
p path
@suruseas
suruseas / server.rb
Last active June 26, 2023 07:47
Sinatra(WEBrick)でsslサーバをたてる
# -*- coding: utf-8 -*-
require 'sinatra/base'
require 'pp'
require 'webrick'
require 'webrick/https'
require 'openssl'
CRT_FILE_NAME = 'server.crt'
RSA_FILE_NAME = 'server.key'