Skip to content

Instantly share code, notes, and snippets.

# bashを起動するときに読み込まれる設定ファイル
PATH=$PATH:$HOME/local/bin
@edvakf
edvakf / php.conf
Last active April 28, 2016 02:07
nginx conf
# /etc/nginx/sites-enabled/php.conf
server {
listen 80;
server_name php.aws;
root /var/www/html;
location / {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
# apache2を再起動
sudo systemctl restart apache2
# apache2の設定を再読み込み
sudo systemctl reload apache2
# apache2を止める
sudo systemctl stop apache2
Host handson
User admin
Port 22
IdentityFile インスタンスを作るときにダウンロードしたpemファイル
HostName パブリックIPアドレス
ServerAliveInterval 300
// inspired by http://code.google.com/p/google-caja/source/browse/trunk/src/com/google/caja/plugin/html-sanitizer.js
// instead of doing with text, only use DOM1 and DocumentFragment
var dom_html_sanitize;
(function(html4){
// usage is similar to html_sanitize method of html-sanitizer.js
// but takes an html document and returns a DocumentFragment
// @param document a document that the output DocumentFragment belongs to (must implement createDocumentFragment method)
// @param htmlDoc an html document to sanitize (must implement DOM1)
#!/usr/bin/python
class List(list):
def dup(self):
def _dup(lst,ancestors):
for orig,copy in ancestors:
if lst == orig:
return copy
copy = lst[:]
_ancestors = ancestors+[(lst,copy)]
for i,x in enumerate(copy):
@edvakf
edvakf / gist:8434738
Created January 15, 2014 11:39
PHP5.5で想定通りに動かなくなったコード
/**
* 想定する文字列(UCS2)かどうか
* (parse_strした結果に適用される)
*/
private static function isValidString($str)
{
if (mb_strlen($str, 'UTF-8') > self::MAX_DETAIL_CHAR_LENGTH) {
return false;
}
$ucs2 = mb_convert_encoding($str, 'UCS-2', 'UTF-8');
@edvakf
edvakf / PRML.R
Created November 26, 2013 13:29
PRML p152-p154
# PRML p152-p154
library(ggplot2)
library(MASS)
# a0 and a1 are parameters to predict
a0 <- -0.3
a1 <- 0.5
f <- function(x) {a0 + a1 * x}
@edvakf
edvakf / nginx.conf
Last active December 27, 2015 14:29
isuconで使えそうなnginxのログ形式
log_format ltsv
"time:$time_iso8601"
"\treq_time:$request_time"
"\tapp_time:$upstream_response_time"
"\tres_size:$bytes_sent"
"\tstatus:$status"
"\tmethod:$request_method"
"\tpath:$request_uri"
"\thost:$remote_addr"
"\tua:$http_user_agent"
sort by avg_time
avg total count method path
9.46 2753.95 291 GET /ticket/1
5.28 1510.27 286 GET /artist/1
4.54 1329.08 293 GET /
4.37 454.62 104 POST /buy
3.82 3.82 1 GET /admin/order.csv
1.22 2.45 2 POST /admin
0.15 0.15 1 GET /artist/2
0.03 4.28 130 GET /js/jquery-ui-1.8.24.custom.min.js