Skip to content

Instantly share code, notes, and snippets.

View oh-sky's full-sized avatar

Yoshihiro Ohsuka oh-sky

View GitHub Profile
@oh-sky
oh-sky / atagitaiwohsc.php
Created April 26, 2013 03:28
PHPで <a> タグ以外をhtmlspecialcharsする関数 何の役に立つか?つまんねー事聞くなよ!
<?php
// <a> </a> タグ以外をhtmlspecialcharsする関数
function atagigaiwohsc($src,$flags = ENT_QUOTES){
// encode including <a></a>
$sanitized = htmlspecialchars($src,$flags);
// decode all <a>
if(preg_match_all('@&lt;a.*?&gt;@', $sanitized, $matches, PREG_SET_ORDER)){
foreach($matches as $match){

$ mysql -u root -p < /usr/local/mysql/share/innodb_memcached_config.sql

mysql> install plugin daemon_memcached soname "libmemcached.so";

$ telnet localhost 11211

@oh-sky
oh-sky / mkchmodall.rb
Last active December 12, 2015 00:08
カレントディレクトリ以下のファイル、ディレクトリ(.gitを除く)のパーミッションをchmodall.shというファイルに記録しておく。git clone 後にsh chmodall.sh すれば、各ファイルのパーミッションをコピーできる。
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
class FileList
def initialize(filelist)
@filelist = filelist
@disposedlist = nil
end
def disposeList()
@oh-sky
oh-sky / README.md
Last active December 11, 2015 22:49
http.conf を、同階層の{domain.example.com}.conf へのソフトリンクにするスクリプト
$ ls -l /opt/local/apache2/conf
bar.example.com.conf
foo.example.com.conf 
httpd.conf@ -> bar.example.com.conf

$ sudo a2ensite foo.example.com
$ls -l /opt/local/apache2/conf
bar.example.com.conf
foo.example.com.conf 
@oh-sky
oh-sky / fb_2month_token_getter.php
Last active December 11, 2015 14:49
Facebook GraphAPIのOAuthAccessToken(Expire: 2month)をgetするためのプログラム。 $client_id,$client_secret,$redirect_uriに適切な文字列をセット。 $redirect_uriにてアクセスできる場所に設置し、ブラウザから$redirect_uriにアクセスすると、Expire:2monthのAccessTokenを入手できる。
<?php
//SETTINGS
//Facebook APP ID
$client_id = 'YOUR_APP_ID';
//Facebook APP SECRET
$client_secret = 'YOUR_APP_SECRET';
//WebURI to access this script
$redirect_uri = 'http://YOUR.DOMAIN/PATH/TO/this_script.php';
//Scopes U need
//Scopes: https://developers.facebook.com/docs/authentication/permissions/