Skip to content

Instantly share code, notes, and snippets.

Avatar
🐈
Cataholic

Ash Wu hSATAC

🐈
Cataholic
View GitHub Profile
@hSATAC
hSATAC / gist:5343225
Created Apr 9, 2013
Http Redirect in Golang
View gist:5343225
package main
import (
"log"
"net/http"
)
func redirect(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "http://www.google.com", 301)
@hSATAC
hSATAC / install redis-cli.sh
Created Jun 7, 2022
Install redis-cli with tls in alpine
View install redis-cli.sh
export REDIS_VERSION="6.0.4"
export REDIS_DOWNLOAD_URL="http://download.redis.io/releases/redis-${REDIS_VERSION}.tar.gz"
apk add --update --no-cache --virtual build-deps gcc make linux-headers musl-dev tar openssl-dev pkgconfig
wget -O redis.tar.gz "$REDIS_DOWNLOAD_URL"
mkdir -p /usr/src/redis
tar -xzf redis.tar.gz -C /usr/src/redis --strip-components=1
cd /usr/src/redis/src
make BUILD_TLS=yes MALLOC=libc redis-cli
View gist:2909583
/*
example of c equivalent to php
<?php
// Create the keypair
$res=openssl_pkey_new();
// Get private key
openssl_pkey_export($res, $privkey);
// Get public key
View 256color.pl
#!/usr/bin/perl
# Author: Todd Larason <jtl@molehill.org>
# $XFree86: xc/programs/xterm/vttests/256colors2.pl,v 1.2 2002/03/26 01:46:43 dickey Exp $
# use the resources for colors 0-15 - usually more-or-less a
# reproduction of the standard ANSI colors, but possibly more
# pleasing shades
# colors 16-231 are a 6x6x6 color cube
for ($red = 0; $red < 6; $red++) {
View gist:3810421
#!/bin/sh
# /usr/local/bin/vpn-pppssh
#
# This script initiates a ppp-ssh vpn connection.
# see the VPN PPP-SSH HOWTO on http://www.linuxdoc.org for more information.
#
# revision history:
# 1.6 11-Nov-1996 miquels@cistron.nl
# 1.7 20-Dec-1999 bart@jukie.net
# 2.0 16-May-2001 bronson@trestle.com
@hSATAC
hSATAC / jenkins_build_docker.bash
Created May 27, 2014
Docker run does not pass exit code back to jenkins. This is a workaround for that.
View jenkins_build_docker.bash
docker build --rm -t $JOB_NAME/$BUILD_NUMBER .
docker run $JOB_NAME/$BUILD_NUMBER | perl -pe '/Failed examples:/ && `echo "fail" > docker-tests-failed`'
if [ ! -f docker-tests-failed ]; then
echo -e "No docker-tests-failed file. Apparently tests passed."
else
echo -e "docker-tests-failed file found, so build failed."
rm docker-tests-failed
exit 1
fi
@hSATAC
hSATAC / reviewer.sh
Last active Aug 19, 2019
Jenkins postbuild script assign github reviewer
View reviewer.sh
#!/bin/bash
rand() {
echo $(( $1 * RANDOM / 32768 ))
}
rand_element () {
local -a th=("$@")
echo "${th[$( rand ${#th[@]} )]}"
}
reviewers=(hSATAC poga aar0nTw hanklin kerkerj)
View bluetooth-restart.sh
#!/bin/bash
echo "Restarting bluetooth service..."
blueutil -p 0 && sleep 1 && blueutil -p 1
echo "Waiting bluetooth service to be restored..."
until blueutil -p | grep "1" >/dev/null; do sleep 1; done
echo "Searching for devices not connected..."
devices=($(blueutil --paired | grep "not connected" | awk -F '[ ,]' '{print $2}'))
@hSATAC
hSATAC / postgresql-template1-encodinf.pp
Last active Jan 3, 2019
Set postgresql template1 encoding to UTF8 in Puppet.
View postgresql-template1-encodinf.pp
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"
}
View tmate-slave-ubuntu-1604.md

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 .