Skip to content

Instantly share code, notes, and snippets.

View netmarkjp's full-sized avatar

BABA Toshiaki netmarkjp

View GitHub Profile
@netmarkjp
netmarkjp / Application.java
Created October 28, 2012 08:19
PlayFramework 2.0.4 WS.get() sync/async
package controllers;
import java.util.Date;
import org.codehaus.jackson.node.ObjectNode;
import play.libs.F.Promise;
import play.libs.Json;
import play.libs.WS;
import play.mvc.Controller;
@netmarkjp
netmarkjp / gist:4180740
Created December 1, 2012 05:59
wordpress quick install for AmazonLinux
# Database Name: wp_db
# Database User: wp_user
# Database Pass: wp_pass
sudo yum -y install mysql mysql-server
sudo chkconfig mysqld on
sudo service mysqld start
#coding: utf-8
#usage: python qmail_log_parser.py maillog | grep "_too_many_hops" | sed 's/.*@//' | sort | uniq -c
import sys
MAILLOG=sys.argv[1]
FULL_LINES=''
FAILED=[]
FAILED_TMP={}
from fabric.api import *
from fabric.contrib.files import *
import json
import os,sys,time
def list_vm(displayname="scale"):
resp=local("idcf-compute-api listVirtualMachines",capture=True)
retval = json.loads(resp, 'UTF-8')
for vm in retval['listvirtualmachinesresponse']['virtualmachine']:
print vm['displayname'],
# pip install redis
import redis
QUEUE="scale:sclgrp:up"
LOCK_KEY="scale:sclgrp:lock"
INCRD_KEY="scale:sclgrp:incrd"
def scaleout():
r = redis.StrictRedis()
queue_count=r.llen(QUEUE)
locked=r.get(LOCK_KEY)
print locked
"""neobundle
" install
" install -d ~/.vim/bundle
" git clone git://github.com/Shougo/neobundle.vim ~/.vim/bundle/neobundle.vim
"
" when add new NeoBundle, exec
" vim -c 'NeoBundleInstall'
"
" to update plugins
" vim -c 'NeoBundleInstall!'
@netmarkjp
netmarkjp / .screenrc
Created April 4, 2013 13:20
vim like screen window handling
bindkey ^w^j eval 'focus down'
bindkey ^w^k eval 'focus up'
bindkey ^w^h eval 'focus left'
bindkey ^w^l eval 'focus right'
bindkey ^w^c eval 'screen'
bindkey ^w^x eval 'remove'
bindkey ^w^o eval 'only'
@netmarkjp
netmarkjp / install_openshift.sh
Last active December 16, 2015 11:49
install openshift to Fedora18
#!/bin/bash
MYHOSTNAME=$(uname -n)
if [ "${MYDOMAIN}x" == "x" ];then
echo 'MUST DO: export MYDOMAIN="example.com"'
exit 1
fi
if [ `grep -c -w "${MYHOSTNAME:?}" /etc/hosts` -eq 0 ];then
    echo "127.0.0.1 ${MYHOSTNAME:?} ${MYHOSTNAME:?}.${MYDOMAIN:?}" >> /etc/hosts
fi
@netmarkjp
netmarkjp / web_kernel_parameters.rb
Created May 1, 2013 08:05
kernel parameter check for generic web server by using serverspec
require 'spec_helper'
describe 'Linux kernel parameters' do
context 'fs.file-max' do
its(:value) { should >= 2097152 }
end
context 'kernel.core_uses_pid' do
its(:value) { should eq 1 }
@netmarkjp
netmarkjp / gist:5506586
Created May 3, 2013 01:11
virtualenv.vim properly activate virtualenv
[baba@bbair2012 ~]$ mkvirtualenv --python=python2.6 --no-site-packages sandbox2.6
Running virtualenv with interpreter /usr/local/bin/python2.6
New python executable in sandbox2.6/bin/python2.6
Also creating executable in sandbox2.6/bin/python
Installing setuptools............................done.
Installing pip...............done.
(sandbox2.6)[baba@bbair2012 ~]$ /usr/bin/python -V
Python 2.7.2
(sandbox2.6)[baba@bbair2012 ~]$ python -V
Python 2.6.8