Skip to content

Instantly share code, notes, and snippets.

View horitaku1124's full-sized avatar

Horimatsu Takuya horitaku1124

  • Tokyo
View GitHub Profile
@horitaku1124
horitaku1124 / scalar-objects-test.php
Created May 4, 2014 17:26
PHP Scalar Objectのテスト
<?php
class StringExtension {
public function replace($search, $replace) {
return str_replace($search, $replace, $this);
}
public function preg_replace($pattern, $replacement) {
return preg_replace($pattern, $replacement, $this);
}
data = [7,13,17,24]
primes = [3,11]
pubkey1 = primes[0] * primes[1]
pubkey2 = (primes[0] - 1) * (primes[1] - 1)
key2 = 3
encd = data.map do |e|( e ** key2 )% pubkey1 end
p encd
@horitaku1124
horitaku1124 / laravel.md
Last active August 29, 2015 14:02
Laravel

Blade

return View::make('posts.index', ['id' => '<b>123</b>']);
Direct output : {{ $id }}

Escaped output : {{{ $id }}}
@horitaku1124
horitaku1124 / httpd.conf
Created June 22, 2014 04:31
Apache 2.4の設定
<Directory />
AllowOverride All
Require all granted
</Directory>
@horitaku1124
horitaku1124 / htdigest.md
Last active August 29, 2015 14:03
ダイジェスト認証

.htaccess

AuthType Digest
AuthName "Secret Zone"
AuthUserFile /etc/httpd/.htdigest
Require valid-user
htdigest -c /etc/httpd/.htdigest 'Secret Zone' username
@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));
@horitaku1124
horitaku1124 / convert_option.md
Last active November 9, 2016 00:37
ImageMagickのconvertコマンドのオプション

基本

convert INPUT OUTPUT

リサイズ

convert -resize 150x150 INPUT OUTPUT
@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 / 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})

作成

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'@'%';