Skip to content

Instantly share code, notes, and snippets.

View nakajijapan's full-sized avatar

Daichi Nakajima nakajijapan

View GitHub Profile
@nakajijapan
nakajijapan / gist:2340563
Created April 9, 2012 00:42
SQLログをカラー表示
#!/bin/perl
#$str = $_;
#$str =~ s/\[SQL\]/\033\[1;36m$&\033\[0m/g;
#$str =~ s/INSERT.+\n/\033\[1;32m$&\033\[0m/g;
#$str =~ s/SELECT.+\n/\033\[1;33m$&\033\[0m/g;
#print $str;
use strict;
use warnings;
while(<>) {
@nakajijapan
nakajijapan / nakajijapan
Created April 18, 2012 04:19
[private] search image number by diretory
# config data
#dir_path = '/home/hogemoge/'
# change dir
Dir.chdir(dir_path)
p Dir.pwd
analyze = Hash.new
Dir.open(dir_path).each_with_index do |f, index|
@nakajijapan
nakajijapan / gist:2593275
Created May 4, 2012 08:25
get female high-school student's image from naver
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
def save_image(url, index)
suffix = 'jpg' if url.index('jpg') || url.index('jpeg')
suffix = 'png' if url.index('png')
suffix = 'gif' if url.index('gif')
open("/tmp/desktop#{index}.#{suffix}", 'wb') do |file|
open(url) do |data|
@nakajijapan
nakajijapan / gist:2593294
Created May 4, 2012 08:28
test program for rest connection
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'rest_client'
url = "http://localhost:5000/upload_file"
filename = File.expand_path('./test.jpg', File.dirname(__FILE__))
f = File.new(filename, "rb")
@nakajijapan
nakajijapan / gist:3003800
Created June 27, 2012 12:32
あれをCoffeeScriptで書いてみる
$ ->
setTimeout ->
$('#notice').faceOut 'slow',
800
@nakajijapan
nakajijapan / gist:3004054
Created June 27, 2012 13:25
あれをCoffeeScriptで書いてみる。修正版
# あらかじめ「config/enviroments.rb」に
# Tilt::CoffeeScriptTemplate.default_bare = true
$ ->
setTimeout(
-> $('#notice').fadeOut('slow')
800
)
@nakajijapan
nakajijapan / gist:3175165
Created July 25, 2012 08:48
GestureRecognizerの処理(カメラ拡大時)
//--------------------------------------------------------------------------------
#pragma mark -
#pragma mark GestureRecognizer
//--------------------------------------------------------------------------------
// scale image depending on users pinch gesture
- (void)handlePinchGesture:(UIPinchGestureRecognizer *)recognizer
{
NSLog(@"-------------------------------");
NSLog(@"%s", __FUNCTION__);
NSLog(@"scale = %f", recognizer.scale);
@nakajijapan
nakajijapan / gist:3799322
Created September 28, 2012 11:40
backbone-rails backbone_rails_sync.js
(function() {
var methodMap = {
'create': 'POST',
'update': 'PUT',
'delete': 'DELETE',
'read' : 'GET'
};
var getUrl = function(object) {
if (!(object && object.url)) return null;
@nakajijapan
nakajijapan / gist:4982564
Created February 19, 2013 02:21
./logs/ディレクトリの中にあるaccess_logのデータをDBに入れるだけの処理
# ./logs/ディレクトリの中にあるaccess_logのデータをDBに入れるだけの処理
require 'mysql2'
require 'active_record'
#
# query
#
def query(sql)
my = Mysql2::Client.new(:host => "localhost", :username => "root", :password => '', :database => 'web_analyze')
my.query("set character set utf8")

ヒューマンエラーを許容する

  • 「きをつけよう」は意味ない
  • 実装、プラクティス、プロセスに落とし込む

バグ、ミスオペの混入を防ぐ

  • コードレビュー
  • 二人で作業
  • テストケース