Skip to content

Instantly share code, notes, and snippets.

View chernjie's full-sized avatar

CJ (curl | jq) chernjie

View GitHub Profile
@chernjie
chernjie / git-gh-setup.sh
Created February 9, 2015 09:25
Fetch Github's Pull Request as a remote branch
#!/usr/bin/env bash
git remote -v | grep fetch | grep github | \
while read remote url _; do
if ! git config --get-all "remote.$remote.fetch" | grep -q refs/pull
then
git config --add "remote.$remote.fetch" \
'+refs/pull/*/head:refs/remotes/'"$remote"'/pull/*'
fi
done
#!/usr/bin/env bash
use() {
for i do
if ! command -v $i > /dev/null
then
echo command $i not found
exit 1
fi
done
@chernjie
chernjie / 10-magento-filter.conf
Created March 19, 2015 04:59
Logstash multiline filter for Magento
filter {
if [type] == "magento" {
multiline{
pattern => "^%{TIMESTAMP_ISO8601:timestamp}"
what => "previous"
negate=> true
}
grok {
match => [
"message",
@chernjie
chernjie / logrotate.d-docker
Created April 17, 2015 17:31
Logrotate docker logs, copy this file to /etc/logrotate.d/docker
/var/lib/docker/containers/*/*-json.log {
dateext
daily
rotate 365
compress
delaycompress
missingok
}
#!/usr/bin/env bash
_usage () {
echo Cherry pick merge commits >&2
exit 1
}
_error () {
echo "$@" >&2
exit 1
@chernjie
chernjie / paypal-payout.sh
Last active August 29, 2015 14:22
HackerspaceSG membership payment via PayPal Rest API
#!/usr/bin/env bash
##
# Update your configuration here
# You may get your `client_id` and `client_secret` from developer.paypal.com
# For membership level, please refer to http://hackerspace.sg/membership
##
endpoint=api.paypal.com
client_id=$client_id

git-gh-setup


This scripts will find all github remotes in the current repository and add a new configuration that allows you to fetch pull request heads and merge-heads

+refs/pull/*/head
+refs/pull/*/merge

Example:

@chernjie
chernjie / .gitignore
Last active June 10, 2016 06:14
hsg-door
success
@chernjie
chernjie / hostname.sh
Created June 26, 2015 03:47
hostname.sh - Set hostname based on /etc/hostname
#! /bin/sh
### BEGIN INIT INFO
# Provides: hostname
# Required-Start:
# Required-Stop:
# Should-Start: glibc
# Default-Start: S
# Default-Stop:
# Short-Description: Set hostname based on /etc/hostname
# Description: Read the machines hostname from /etc/hostname, and
#!/usr/bin/env bash
# Set the following SSH configurations to no:
# ChallengeResponseAuthentication
# PasswordAuthentication
# UsePAM
test -f /etc/ssh/sshd_config || exit 1
sed -i -r -e \