Skip to content

Instantly share code, notes, and snippets.

@longkey1
longkey1 / nagoyaphp-160416-sample.php
Created April 16, 2016 07:12
nagoyaphp-160416-sample
<?php
$input = '1->4';
$expected = 'mo';
// parse
list($one, $two) = explode('
package main
import (
"fmt"
"sync"
"time"
"math/rand"
)
type member struct {
@longkey1
longkey1 / main.go
Last active October 29, 2015 15:59
go-routine-sample
package main
import (
"log"
"time"
"os"
"os/exec"
"syscall"
)
CREATE OR REPLACE FUNCTION to_tsquery_ungm(text) RETURNS tsquery AS $$
select to_tsquery(array_to_string(regexp_split_to_array($1, E'\\s*'),'&'));
$$ language sql;
CREATE OR REPLACE FUNCTION to_tsvector_ungm(text) RETURNS tsvector AS $$
select to_tsvector('simple', array_to_string(regexp_split_to_array($1, E'\\s*'),' '));
$$ immutable language sql;
# libevent
wget https://github.com/downloads/libevent/libevent/libevent-2.0.17-stable.tar.gz
tar zxvf libevent-2.0.17-stable.tar.gz
cd libevent-2.0.17-stable
./configure --prefix=$HOME/local/libevent
make && make install
# tmux
wget http://downloads.sourceforge.net/project/tmux/tmux/tmux-1.7/tmux-1.7.tar.gz
tar zxvf tmux-1.7.tar.gz
@longkey1
longkey1 / pg-conn
Created January 25, 2013 04:16
connect to postgres database by psql
#!/bin/sh
## setting area
SETTING_LIST="hoge1 hoge2 hoge3"
hoge1="user1 database1 xxx.xxx.xxx.xxx"
hoge2="user1 database2 localhost"
hoge3="user1 database3 host3"
## setting area
if [ "$1" ] ; then
@longkey1
longkey1 / setup_screen.sh
Last active October 12, 2015 08:28
How to install screen in development version
$ cd ~/local
$ git clone git://git.savannah.gnu.org/screen.git screen
$ cd screen/src
$ ./autogen.sh
$ sudo apt-get install autoconf2.64
$ ./configure --prefix=$HOME/local \
--enable-colors256
$ make
$ make install
@longkey1
longkey1 / setup_vim73.sh
Last active October 10, 2015 13:08
How to install vim7.3 in my home directory for debian squeeze
$ sudo apt-get install ncurses-dev python-dev
$ cd ~/local/src
$ wget ftp://ftp.vim.org/pub/vim/unix/vim-7.3.tar.bz2
$ tar jxf vim-7.3.tar.bz2
$ mkdir vim73/patches
$ cd vim73/patches/
$ curl -O 'ftp://ftp.vim.org/pub/vim/patches/7.3/7.3.[001-783]'']'
$ cd ../src/po
$ wget https://vim.googlecode.com/hg/src/po/nl.po
@longkey1
longkey1 / createSaltAndCipherSeed.php
Created July 31, 2012 00:59
Create Security.salt & Security.cipherSeed for CakePHP
<?php
echo 'please input string: ';
$stdin = fgets(STDIN,4096);
// salt
$salt = sha1($stdin);
// seed
$seed = '';
for ($i = 0; $i < 30; $i++) {