Skip to content

Instantly share code, notes, and snippets.

View horitaku1124's full-sized avatar

Horimatsu Takuya horitaku1124

  • Tokyo
View GitHub Profile
@horitaku1124
horitaku1124 / log_to_q.rb
Last active August 29, 2015 14:11
httpdのログをq用に整形
require 'date'
file = ARGV[0] == nil ? STDIN : open(ARGV[0])
puts "ip\ta1\ta1\tdate\tmethod\tquery\tprotocol\trespond\tlength\treffer\tua\n"
while line = file.gets
line = line.gsub(/[\r\n ]$/, "")
len = line.length
inQuato = false
inCase = false
values = []
@horitaku1124
horitaku1124 / config.php
Last active August 29, 2015 14:10
PHP settings
<?php
ini_set('display_errors', 1);
set_error_handler(function ($errorNo, $errorMessage, $errorFile, $errorLine) {
throw new ErrorException($errorMessage, 0, $errorNo, $errorFile, $errorLine);
});
@horitaku1124
horitaku1124 / align_canvas.sh
Created November 25, 2014 05:45
キャンバスの大きさを揃える
ls *.png | xargs -I FILE convert \
FILE \
-thumbnail '46x32>' \
-gravity northwest \
-extent 46x32 \
s_FILE
@horitaku1124
horitaku1124 / trick.js
Created October 24, 2014 11:31
JavaScriptの技
var pureArray = Array.apply(null, $( "#table tr" ));
curl -b "PHPSESSID=abcdefg" -i -s http://localhost/ | head -n 20

作成

GRANT usage ON `database1`.* TO 'user'@'localhost' IDENTIFIED BY 'password';
GRANT insert,select ON `database1`.comments TO 'user'@'localhost';
FLUSH PRIVILEGES;

権限削除

REVOKE ALL on *.* from 'user'@'%';
@horitaku1124
horitaku1124 / CMakeLists.txt
Created September 11, 2014 14:54
OpenCVを使用したときのCMakeの書き方
cmake_minimum_required(VERSION 2.8.4)
project(test1)
FIND_PACKAGE( OpenCV REQUIRED )
set(SOURCE_FILES main.cpp)
add_executable(main ${SOURCE_FILES})
@horitaku1124
horitaku1124 / my_ror_tips.md
Last active August 29, 2015 14:06
Ruby on Railsの覚え書き
  • 2000年1月1日のフォーマット
<%==
   sprintf(
   f.date_select(
     :open_day ,
     :use_month_numbers => true,
     :date_separator => '%s'
 ), '年', '月'); %&gt;
@horitaku1124
horitaku1124 / convert_option.md
Last active November 9, 2016 00:37
ImageMagickのconvertコマンドのオプション

基本

convert INPUT OUTPUT

リサイズ

convert -resize 150x150 INPUT OUTPUT
@horitaku1124
horitaku1124 / mkpassword.php
Last active August 29, 2015 14:03
パスワードもどきを簡単に生成
<?php
function makePass($length = 8) {
$base = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
$str = "";
while($length--) {
$str .= $base[mt_rand(0, strlen($base) - 1)];
}
return $str;
}
var_dump(makePass(20));