Skip to content

Instantly share code, notes, and snippets.

View thash's full-sized avatar
🌵
⭐️ ⭐️ ⭐️ ⭐️ ⭐️

Takuya Hashimoto thash

🌵
⭐️ ⭐️ ⭐️ ⭐️ ⭐️
View GitHub Profile
var remote_down = false;
socket.on('message', function(data) {
switch (data.act) {
case "down":
remote_down = true;
ctx.strokeStyle = data.color;
ctx.beginPath();
ctx.moveTo(data.x, data.y);
@thash
thash / gathercsv.rb
Created June 25, 2011 15:51
GatherCSV for MongoDB 2d index
# -*- coding: utf-8 -*-
# 次のように加工する
# rr_cd,line_cd,station_cd,line_sort,station_sort,station_g_cd,r_type,rr_name,line_name,station_name,pref_cd,lon,lat,f_flag
# 28,28001,2800101,28001,2800101,2100201,2,東京メトロ,東京メトロ銀座線,浅草,13,139.797592,35.710733,1
# ↓
# 28,28001,2800101,28001,2800101,2100201,2,東京メトロ,東京メトロ銀座線,浅草,13,"{ lon : 139.797592, lat : 35.710733 }",1
require 'pp'
% wget localhost
--2011-07-20 23:16:07-- http://localhost/
localhost (localhost) をDNSに問いあわせています... 失敗しました: nodename nor servname provided, or not known.
wget: ホストアドレス `localhost' を解決できませんでした。
% wget localhost
--2011-07-20 23:16:07-- http://localhost/
localhost (localhost) をDNSに問いあわせています... 失敗しました: nodename nor servname provided, or not known.
wget: ホストアドレス `localhost' を解決できませんでした。
@thash
thash / md.md
Created October 27, 2011 07:10

-bash: warning: setlocale: LC_ALL: cannot change locale (ja_JP.UTF-8)

という表示が出る問題を解決。

まず/etc/default/localeに

# cat /etc/default/locale
LANG="ja_JP.UTF-8"
LC_ALL="ja_JP.UTF-8"

LANGUAGE="ja_JP:ja"

@thash
thash / cap_notify.rb
Created November 1, 2011 11:53 — forked from johnthethird/cap_notify.rb
Capistrano deployment email notifier for Rails 3
=begin
Capistrano deployment email notifier for Rails 3
Do you need to send email notifications after application deployments?
Christopher Sexton developed a Simple Capistrano email notifier for rails. You can find details at http://www.codeography.com/2010/03/24/simple-capistrano-email-notifier-for-rails.html.
Here is Rails 3 port of the notifier.
The notifier sends an email after application deployment has been completed.
source 'http://rubygems.org'
# --- Rails 3.1 -----------------------------------
gem 'rails', '3.1.1'
group :assets do
gem 'sass-rails', '~> 3.1.4'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
openssl genrsa -des3 -out oreore.key 1024
openssl req -new -key oreore.key -out oreore.csr
cp oreore.key oreore.key.org
openssl rsa -in oreore.key.org -out oreore.key
openssl x509 -req -days 3650 -in oreore.csr -signkey oreore.key -out oreore.crt
*filter
:INPUT DROP [0:0] # drop every input packets by default.
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
# ssh, http, https
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
# IMPORTANT: Change ssh port for better security.
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
source 'http://rubygems.org'
# --- Rails 3.1 -----------------------------------
gem 'rails', '3.1.1'
gem 'jquery-rails'
group :assets do
gem 'sass-rails', '~> 3.1.4'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'