Skip to content

Instantly share code, notes, and snippets.

@t-cyrill
t-cyrill / pdf.sh
Last active September 28, 2015 01:55
Process Diff
ssh $HOSTNAME "ps -e -o comm= | sort | uniq" > /tmp/processlist
diff -u <(ps -e -o comm= | sort | uniq) /tmp/processlist | egrep "^[-+]"
rm /tmp/processlist
@t-cyrill
t-cyrill / upgrade.sh
Created September 25, 2015 07:33
Upgrade system-wide rbenv ruby
sudo sh -c "cd /usr/local/src/ruby-build && git pull origin master && ./install.sh && cd /usr/local/rbenv && git pull origin master && source /etc/profile && eval $(rbenv init -) && rbenv install 2.2.3 && rbenv shell 2.2.3 && gem install bundler --no-ri --no-rdoc && rbenv rehash"
@t-cyrill
t-cyrill / build_dep.sh
Created June 25, 2015 09:25
Setup ffmpeg
#!/bin/bash
apt-get update
apt-get -y install autoconf automake build-essential libass-dev libfreetype6-dev libgpac-dev \
libtheora-dev libtool libvorbis-dev pkg-config texi2html zlib1g-dev
apt-get install -y yasm
## install lame
apt-get install -y libmp3lame-dev
apt-get install -y unzip
@t-cyrill
t-cyrill / README.md
Created March 2, 2015 07:27
nginx pagecache cleaner

Setup

sudo cpanm install Sys::PageCache
@t-cyrill
t-cyrill / commands.sh
Last active August 29, 2015 14:16
useful shell commands
# ionice
sudo ionice -c2 -n7 nice -n19 du -sh *
# check current running unicorn ruby version
pgrep -f unicorn -l | grep master | cut -d' ' -f1 | sudo xargs -I{} readlink -f /proc/{}/exe | xargs -I{} sh -c "{} -v"
# curl view header (not HEAD)
curl -D - -s -o /dev/null "http://google.com"
@t-cyrill
t-cyrill / git-command
Last active August 29, 2015 14:16
useful git operation
git push origin `git rev-parse --abbrev-ref HEAD`
git branch --merged | egrep -v 'master|\*' | xargs -n1 git branch -d
@t-cyrill
t-cyrill / waiting_for_process.rb
Created September 12, 2014 02:26
Waiting for other spawned process with timeout
require 'timeout'
require 'shellwords'
cmd = "foo"
out = "bar.out"
cmd = "#{cmd} -o #{Shellwords.escape(out)}"
timeout = 1
# puts cmd
.level = WARNING
handlers= java.util.logging.FileHandler
java.util.logging.FileHandler.pattern = client_log_%u.log
java.util.logging.FileHandler.limit = 50000
java.util.logging.FileHandler.count = 1
java.util.logging.FileHandler.append = true
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
@t-cyrill
t-cyrill / example.php
Last active August 29, 2015 14:04
FluentPDO example
<?php
$db = new PDO("sqlite:test.db")
$fpdo = new FluentPDO($db);
$fpdo->from('hogehoge_table')
->where(['id >= ?' => $id])
->select(null)
->select('column, value');
// SELECT column, value FROM hogehoge_table WHERE id >= ?;
$data = $fpdo->fetchAll();
@t-cyrill
t-cyrill / index.php
Created July 23, 2014 04:30
Klein.php sample2
<?php
header('Content-type: application/json');
$klein->respond('GET', '/users/[:id].[json:format]?', function ($req, $res, $serv, $app) {
$id = $req->param('id');
return json_encode(['id' => $id]);
});