Skip to content

Instantly share code, notes, and snippets.

View netmarkjp's full-sized avatar

BABA Toshiaki netmarkjp

View GitHub Profile
@netmarkjp
netmarkjp / wait.py
Last active December 28, 2015 20:49
import time
def check_hoge(**args):
print "args:",
print args
return False
def wait(function_name, retry=5, interval=1, **args):
@netmarkjp
netmarkjp / CentOS-Base.repo.patch
Created November 15, 2013 09:40
patch for centos 4.x use yum with vault.centos.org http://d.hatena.ne.jp/tmatsuu/20120324/1332578375
--- /etc/yum.repos.d/CentOS-Base.repo.orig
+++ /etc/yum.repos.d/CentOS-Base.repo
@@ -13,8 +13,9 @@
[base]
name=CentOS-$releasever - Base
-mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
+#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
+baseurl=http://vault.centos.org/4.9/os/$basearch/
@netmarkjp
netmarkjp / move.sh
Last active December 23, 2015 03:49
1. detect duplicate file(raw and jpg)2. move raw to raw/ dir
rm -f /tmp/all_pics.txt /tmp/dup_pics.txt /tmp/cmds.txt
find /Volumes/BBFS1/toshi-photo -type f -maxdepth 2 | sed -E "s/(.*)\..*/\1/" | sort | uniq -c | grep -v "^ \+1" | sed "s@.*.*[0-9] /@/@" > /tmp/dup_pics.txt
iconv -f utf8 -t utf8-mac /tmp/dup_pics.txt | while read line; do ls $line.* >> /tmp/all_pics.txt ; done
grep -iE "\.(pef|arw|cr2)$" /tmp/all_pics.txt | sed -E "s@(.*)/(.*)@mv \1/\2 \1/raw/\2@" > /tmp/cmds.txt
iconv -f utf8 -t utf8-mac /tmp/dup_pics.txt | sed -E "s@(.*/).*@\1@" | uniq | while read line; do mkdir ${line}raw ;done
bash /tmp/cmds.txt
#cloud-config
hostname: myhostname
runcmd:
- [ echo, 'Setting custom hostname' ]
- [ sed, -i, 's/^HOSTNAME=.*/HOSTNAME=myhostname/', /etc/sysconfig/network ]
- [ hostname, 'myhostname' ]
@netmarkjp
netmarkjp / minion production config
Last active December 22, 2015 12:28
mozilla minion production config files
MINION_HOME=/home/minion/minion
SUPERVISOR_CONFDIR=/etc/supervisor/conf.d
MINION_CONFDIR=/etc/minion
MINION_FRONTEND_HOST=localhost
MYHOSTNAME=$(hostname)
# nginx
sudo cp ${MINION_HOME:?}/minion-frontend/etc/minion-dev-server.nginx.conf /etc/nginx/conf.d/minion.conf
sudo sed -i "s/minion-dev\.mozillalabs\.com/${MINION_FRONTEND_HOST:?}/g" /etc/nginx/conf.d/minion.conf
@netmarkjp
netmarkjp / envwrapper.sh
Created September 7, 2013 02:34
wapper for supervisord + gunicorn/celery with virtualenv
#!/bin/sh
# from http://d.hatena.ne.jp/heavenshell/20121122/1353597292
VENV=$1
echo $VENV
if [ -z $VENV ]; then
echo "usage: runinenv [virtualenv_path] CMDS"
exit 1
fi
. ${VENV}/bin/activate
shift 1
@netmarkjp
netmarkjp / minion configs
Last active February 20, 2017 23:31
example of mozilla minion production config files. /etc/minion/frontend.json /etc/nginx/conf.d/minion.conf /etc/supervisor/conf.d/minion-*.supervisor.conf
# ls /etc/minion/frontend.json /etc/nginx/conf.d/minion.conf /etc/supervisor/conf.d/minion-*.supervisor.conf | while read f; do echo ---$f ; cat $f ; done
---/etc/minion/frontend.json
{
"session-secret":"50131647012122764715049",
"backend-api":{
"url":"http://127.0.0.1:8383"
}
}
---/etc/nginx/conf.d/minion.conf
# This Source Code Form is subject to the terms of the Mozilla Public
@netmarkjp
netmarkjp / gist:6384187
Last active July 25, 2017 12:24
workaround to rerun cloud-init with user-data on amazon linux (want to run 'once per instance' )
sudo rm -f /var/lib/cloud/sem/*{defaults,runcmd,userdata,user-scripts}* /var/lib/cloud/data/cache/obj.pkl
@netmarkjp
netmarkjp / example.rb
Created August 15, 2013 09:02
serverspec(rspec) :if example
require 'spec_helper'
def exist?(filename)
File.exist?(filename)
end
def bigger_than?(filename,size)
File.size?(filename) >= size
end
#coding: utf-8
import csv
import re
reader=csv.reader(open('data.csv'),dialect='excel')
fixed=[]
for row in reader:
data={ 'waku':row[3],
'title':row[4],
'description':row[5],