Skip to content

Instantly share code, notes, and snippets.

@jiskanulo
jiskanulo / apc_clear_cache.php
Created September 28, 2011 03:19
apc_clear_cache()をwebからたたく的な
<?php
$ip = (isset($_SERVER['REMOTE_ADDR'])) ? $_SERVER['REMOTE_ADDR'] : '';
$allowed_ips = array(
'127.0.0.1',
'192.168.11.*',
);
$validate = false;
foreach ($allowed_ips as $allowed_ip) {
if (preg_match('/^' . $allowed_ip . '$/', $ip)) {
@jiskanulo
jiskanulo / show-colour
Created February 9, 2012 07:21
http://blog.paz-para.com/?p=2327 を大いに参考にした
#!/bin/bash
echo " On Light Gray: On Black:"
echo -e "\033[47m\033[1;37m White \033[0m\
1;37m \
\033[40m\033[1;37m White \033[0m"
echo -e "\033[47m\033[37m Light Gray \033[0m\
37m \
\033[40m\033[37m Light Gray \033[0m"
echo -e "\033[47m\033[1;30m Gray \033[0m\
@jiskanulo
jiskanulo / gist:4023267
Created November 6, 2012 07:35
Homebrewでインストールしたphp53とphp54を切り替える
#!/bin/bash
if [ ! -x `which brew` ]; then
echo "Homebrew does not installed."
exit 1
fi
php_path=`which php`
php_real_path=`stat -F $php_path`
@jiskanulo
jiskanulo / gist:4023269
Created November 6, 2012 07:36
Mac OS Xか否か判別
#!/bin/bash
os_x=""
if [ -x `which sw_vers` ]; then
os_x="${sw_vers} | grep 'Mac OS X'"
fi
if [ -n "$os_x" ]; then
echo "Mac OS X"
else
@jiskanulo
jiskanulo / switch-subversion-servers
Last active December 18, 2015 00:48
.subversion/servers ファイルを予め2つ用意しておいてコマンド1つで切り替える
#!/bin/bash
subversion_base_config_path="${HOME}/.subversion"
config_file="${subversion_base_config_path}/servers"
function abort()
{
echo $1 2>&1
exit 1
}
server {
listen 8080;
server_name example.dev www.example.dev;
location / {
root /Users/Cobby/Sites/Example;
if ($host = 'www.example.dev' ) {
rewrite ^/(.*)$ http://example.dev:8080/$1 permanent;
}
@jiskanulo
jiskanulo / hoge.php
Created December 9, 2013 11:54
hogehoge
<?php
class Hoge
{
public $hoge = array(1,2,3);
private $_page = array('a','b','c');
}
function falsificate(& $property)
@jiskanulo
jiskanulo / gist:9173498
Last active August 29, 2015 13:56
初めて自分のために書いたphp
<?php
function h($var) {
return htmlspecialchars($var, ENT_QUOTES, 'Shift_JIS');
}
function r($key, $escape=true) {
$value = (!empty($_REQUEST[$key])) ? $_REQUEST[$key] : null;
if ($escape!==true) return $value;
return h($value);
update
# add repositories
tap homebrew/binary || true
tap homebrew/completions || true
tap homebrew/dupes || true
tap homebrew/versions || true
tap phinze/homebrew-cask || true
tap josegonzalez/php || true
@jiskanulo
jiskanulo / _homeshick
Created April 14, 2014 09:48
homeshick oh-my-zsh plugin
#compdef homeshick
_homeshick () {
local context state line curcontext="$curcontext" ret=1
_arguments -n : \
{-q,--quiet}'[Suppress status output]' \
'(-s --skip)'{-f,--force}'[Overwrite files that already exist]' \
'(-f --force)'{-s,--skip}'[Skip files that already exist]' \
{-b,--batch}'[Batch-mode: Skip interactive prompt]' \
{-h,--help}'[Help message]' \