Skip to content

Instantly share code, notes, and snippets.

@yaegashi
yaegashi / gist:2361136
Created April 11, 2012 18:22
Git pre-commit hook script to verify file encodings.
#!/usr/bin/env perl
# Git pre-commit hook script to verify file encodings.
# Works with Perl 5.8. The bundled perl in msysgit is also supported.
# Copyright (C) 2012 Takeshi Yaegashi
# Encodings allowed to be committed.
my @allowed = qw/ascii utf8/;
# Encodings possible to be seen - optional.
@yaegashi
yaegashi / monitrc
Created July 13, 2012 01:11
Minimal monit config example
# /etc/monit/monitrc
set daemon 60
set logfile /var/log/monit.log
set idfile /var/lib/monit/id
set statefile /var/lib/monit/state
set eventqueue basedir /var/lib/monit/events slots 100
set mailserver mail.example.com
set alert [email protected]
set httpd port 2812 and use address localhost allow localhost
include /etc/monit/conf.d/*
@yaegashi
yaegashi / setup-redmine.sh
Created November 12, 2012 12:36
Set up a redmine instance with sub-uri: http://localhost:8080/redmine
#!/bin/sh -x
export RAILS_ENV=production
export REDMINE_LANG=ja
git clone https://github.com/redmine/redmine
cd redmine
rm config.ru
echo 'gem "unicorn"' >Gemfile.local
cat <<EOF >config/database.yml
$RAILS_ENV:
adapter: sqlite3
#!/bin/sh
# Start ssh-agent and register environment variables permanently in HKCU.
# Copyright (C) 2013 YAEGASHI Takeshi <[email protected]>
# Use a fixed path for the ssh-agent socket endpoint.
# SSH_FIXED_SOCK="/tmp/ssh-agent-$(id -u).sock"
eval $(ssh-agent -k)
@yaegashi
yaegashi / hosts
Last active August 29, 2015 14:05
https://github.com/ansible/ansible/issues/8633 test case on a role with only library modules
# /hosts
localhost ansible_connection=local
#!/bin/sh
if test $# -lt 2; then
echo "Usage: $0 <common name> <output> [ca options ...]" >&2
exit 1
fi
cn=$1
out=$2
shift 2
#!/bin/sh
set -e
if test $# -lt 2; then
echo "Usage: $0 <common name> <output> [<start> <end>]" >&2
exit 1
fi
cn=$1
@yaegashi
yaegashi / card.sh
Last active August 29, 2015 14:23
Card hand generator & matcher http://unix.stackexchange.com/a/211717/116972
#!/bin/bash
# This version conforms to Bash 3.2.53 on OS X.
stab=('\e[0;31;47m ♦' '\e[0;31;47m ♥' '\e[0;30;47m ♠' '\e[0;30;47m ♣')
ntab=(2 3 4 5 6 7 8 9 10 J Q K A)
match() {
for i; do
printf " ${stab[$((i/13))]}${ntab[$((i%13))]}\e[0m"
@yaegashi
yaegashi / playbook.yml
Created October 14, 2015 12:05
Ansible SSH connection using paramiko
---
- hosts: all
connection: paramiko
vars:
ansible_ssh_private_key_file: /path/to/private_key
ansible_ssh_pass: passphrase_for_private_key
tasks:
- debug:
msg: hello
$ ansible-playbook -i localhost, basicexp-playbook.yml
PLAY [localhost] **************************************************************
TASK: [OK: ['a', 'b', 'c']] ***************************************************
ok: [localhost] => {
"msg": [
"a",
"b",
"c"