Skip to content

Instantly share code, notes, and snippets.

View hSATAC's full-sized avatar
🐈
Cataholic

Ash Wu hSATAC

🐈
Cataholic
View GitHub Profile
@hSATAC
hSATAC / postgresql-template1-encodinf.pp
Last active January 3, 2019 22:09
Set postgresql template1 encoding to UTF8 in Puppet.
exec { "postgresql-template1-utf8":
command => "psql -c \"update pg_database set datistemplate=false where datname='template1';\" &&
psql -c 'drop database Template1;' &&
psql -c \"create database template1 with owner=postgres encoding='UTF-8' lc_collate='en_US.utf8' lc_ctype='en_US.utf8' template template0;\"
",
user => "postgres",
path => "/usr/bin",
unless => "/usr/bin/psql -Atc \"select pg_encoding_to_char(encoding) from pg_database where datname='template1'\" | /bin/grep -c UTF8"
}
@hSATAC
hSATAC / tmate-slave-ubuntu-1604.md
Created December 11, 2018 16:17 — forked from xinzweb/tmate-slave-ubuntu-1604.md
Tmate-slave on Ubuntu 16.04

Install dependincies

apt-get install  git-core build-essential pkg-config libtool libevent-dev libncurses-dev zlib1g-dev automake libssh-dev cmake ruby

Install msgpack >= 1.2.0

git clone https://github.com/msgpack/msgpack-c.git
cd msgpack-c
cmake .
@hSATAC
hSATAC / send_to_kindle.md
Last active March 20, 2018 04:09
Send Mobi to Kindle on MacOS Terminal
@hSATAC
hSATAC / sf.rb
Created December 21, 2015 18:02
#!/usr/bin/env ruby
def upload_and_generate_mobi(source_file, output_file, title)
puts "Dealing #{source_file} ..."
# get key
key = `curl -s http://ebook.cdict.info/mobi/ | grep progress_key`.match(/progress_key=([a-zA-Z0-9]+)/)[1]
`curl -s "http://ebook.cdict.info/mobi/revalid.php?progress_key=#{key}"`
`curl -s \
@hSATAC
hSATAC / gist:4712835
Created February 5, 2013 07:22
puppet stage example
# Append this at the bottom of /etc/puppetlabs/puppet/manifests/site.pp
node 'devm3' {
stage { 'pre': }
class {
"archfix": stage => "pre";
}
Stage["pre"] -> Stage["main"]
include common
@hSATAC
hSATAC / .vimrc
Created December 19, 2011 09:05
runtime php syntax check without saving file
set errorformat=%m\ in\ %f\ on\ line\ %l
if !exists('*PHPsynCHK')
function! PHPsynCHK()
ccl
let winnum = winnr()
let linenum = line('.')
let colnum = col('.')
silent execute "%!php -l -f /dev/stdin | sed 's/\\/dev\\/stdin/".bufname("%")."/g' >.vimerr; cat"
silent cf .vimerr
cw
@hSATAC
hSATAC / G300
Created November 21, 2011 05:09
Disable Logitech G300 keyboard to make it working correctly.
#!/bin/sh
DEVICE_ID=`xinput list | grep "Logitech Gaming Mouse G300" | grep keyboard | sed 's/.*id=\([0-9]*\).*/\1/'`
if xinput -list-props $DEVICE_ID | grep "Device Enabled" | grep "1$" > /dev/null
then
xinput set-int-prop $DEVICE_ID "Device Enabled" 8 0
fi
@hSATAC
hSATAC / gist:3246217
Created August 3, 2012 09:17
Check git branch been merged or not
#!/usr/bin/env ruby
require 'rubygems'
require 'active_support'
merged = `cd /home/m/git/repositories/miiicasa.git && git branch --merged master | grep -v master`
not_merged_cmd = 'cd /home/m/git/repositories/miiicasa.git && git branch | grep -v master | grep -v support | grep -v qa'
for line in merged.split("\n")
not_merged_cmd += '| grep -v ' + line
end
puts "This is a regular check of miiiCasa.git branches\n"
@hSATAC
hSATAC / gist:2880516
Created June 6, 2012 07:49
aws ec2 dynamic dns for route 53 (CNAME)
#!/bin/sh
# Setup dynamic dns on Route 53 for aws ec2 (CNAME)
#
# Modified from Johan Lindh's script
#
# Script requirements:
#
# wget
# grep