Skip to content

Instantly share code, notes, and snippets.

@nkwhr
nkwhr / jenkins_docker.sh
Created July 27, 2015 09:06
A sample script for running rspec on docker
#!/bin/bash
set -x
uuid=$(uuidgen)
docker build -t myapp .
docker run -d --name mysql-${uuid} --env MYSQL_ROOT_PASSWORD=xxxxxx mysql:5.6
docker run -d --name memcached-${uuid} memcached
# ・8-18文字であること
# ・大文字小文字アルファベットと数字が含まれていること
# ・.@_- (ドット、アットマーク、アンダースコア、ハイフン)のうち少なくとも1
# つ含まれていること
class PasswordGeneratorAttributeError < StandardError; end
class PasswordGenerator
NUMBERS = [*0..9]
UPPER_CHARS = [*'A'..'Z']
LOWER_CHARS = [*'a'..'z']
(unless (>= 24 emacs-major-version)
(error "requires Emacs 24 or later."))
(deftheme heroku "A color theme inspired by Heroku's old dashboard")
(custom-theme-set-variables
'heroku
'(linum-format "%4d\u2502 "))
(let ((*background* "#1b1b24")
@nkwhr
nkwhr / stop_sidekiq.rake
Created May 1, 2015 06:25
Safely stop Sidekiq process
require 'sidekiq/api'
namespace :sidekiq do
task 'stop' do
ps = Sidekiq::ProcessSet.new
abort 'Sidekiq process not running' if ps.count == 0
ps.first.quiet!
puts "SIGUSR1 sent\nWaiting 10sec for status update"
@nkwhr
nkwhr / activity_logger.rb
Last active August 29, 2015 14:14
Custom Logger Example on Rails
# lib/activity_logger.rb
class ActivityLogger < Logger
def format_message(severity, timestamp, progname, msg)
base_log = {
timestamp: timestamp,
severity: severity
}
base_log.merge(msg).to_json + "\n"
end
end
@nkwhr
nkwhr / docker_registry_howto.md
Last active August 29, 2015 14:13
How to setup and run private docker registry with Nginx and fig on CentOS6

Download registry container

$ docker pull registry

Install fig

$ sudo yum install python-pip
@nkwhr
nkwhr / manual_gc.txt
Created December 11, 2014 09:54
Manual GC command for RabbitMQ Server
rabbitmqctl eval '[garbage_collect(P) || P <- processes()].'
#!/bin/bash
PATH=/usr/bin:/bin:/usr/sbin:/sbin
export PATH
function pushover() {
curl -s -X POST \
--form-string "token=$PUSHOVER_TOKEN" \
--form-string "user=$PUSHOVER_USER" \
--form-string "title=RabbitMQ Restart Attempted" \
@nkwhr
nkwhr / install_kernel.sh
Created October 29, 2014 09:12
Build and installs vanilla kernel on CentOS 6. You can specify a version with `$VERSION` environment variable.
#!/bin/bash
set -e
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
export LANG=C
if [ $UID -ne 0 ] ; then
echo "You must be root to run this script."
exit 1
#!/usr/bin/env perl
use sane;
use Redis::Fast;
use Time::Piece;
use DDP;
my $user_id = 100;
my $u = UserLastAccess->new(user_id => $id);