Skip to content

Instantly share code, notes, and snippets.

View sunnycmf's full-sized avatar
🎯
Focusing

Sunny Chan sunnycmf

🎯
Focusing
  • Carousell
  • Hong Kong
View GitHub Profile
@sunnycmf
sunnycmf / mitmproxy pf
Created May 9, 2016 16:41 — forked from khapota/mitmproxy pf
/etc/pf.anchors/mitm
rdr pass on en0 inet proto tcp to any port 80 -> 127.0.0.1 port 8080
rdr pass on en0 inet proto tcp to any port 443 -> 127.0.0.1 port 8080
@sunnycmf
sunnycmf / pf.conf
Created May 9, 2016 16:41 — forked from khapota/pf.conf
pf conf mac os 10.10
scrub-anchor "com.apple/*"
nat-anchor "com.apple/*"
rdr-anchor "com.apple/*"
rdr-anchor "forwarding"
dummynet-anchor "com.apple/*"
anchor "com.apple/*"
load anchor "com.apple" from "/etc/pf.anchors/com.apple"
load anchor "forwarding" from "/etc/pf.anchors/mitm"
{
"title": "Apache and Tomcat Logs",
"services": {
"query": {
"list": {
"0": {
"query": "apache !tomcat !static",
"alias": "",
"color": "#7EB26D",
"id": 0,
@sunnycmf
sunnycmf / README.md
Created October 14, 2015 03:42 — forked from Luzifer/README.md
Strategies for persistent data storage on CoreOS-cluster

Persistent data storage on CoreOS-cluster

Storing the data on the host machine

Data directories are created in /home/coreos and mounted into the container using volume cli options of docker run. All data the container writes is stored on the host and as long as the host persists safe against container restarts / recreates.

  • Pro
    • No effort, just create the directories and mount them into the container
  • Contra
  • Container is bound to host (unable to failover)
@sunnycmf
sunnycmf / beaudev_docker_nginx_proxy_host.sh
Last active August 29, 2015 14:26 — forked from jmeyo/beaudev_docker_nginx_proxy_host.sh
Beaudev simple script to add a nginx vhost reverse proxying to a docker instance
#!/bin/bash
# add vhost reverse proxy for new docker instance for nginx and restart nginx
# use like this : do_nginx_proxy_vhost subdir.example.com http://192.168.0.20:8080
function do_nginx_proxy_vhost() {
[ -z $1 -o -z $2 ] && echo "Give host and address" && return
host=$1
address=$2
[ -f /etc/nginx/sites-available/proxy_reverse_$host ] && (echo "Updating proxy for host: $host" && sudo rm /etc/nginx/sites-enabled/proxy_reverse_$host) || echo "Creating proxy for host: $host"
@sunnycmf
sunnycmf / beaudev_docker_aliases.sh
Last active August 29, 2015 14:26 — forked from jmeyo/beaudev_docker_aliases.sh
Beaudev Docker alias and usefull functions
#!/bin/bash
# Get id, name and ip adresses of all active docker container
function do_get_ip_address() {
paste <(sudo docker ps | tail -n +2 | awk {'printf "%s\t%s\n", $1, $2 '}) <(sudo docker ps -q | xargs sudo docker inspect | tail -n +2 | grep \"IPAddress\" | awk '{ print $2 }' | tr -d ',"')
}
# stop and remove a container based on his id
function do_stop_rm_container() {
[ -z "$1" ] && echo "Give me a container ID" && return
@sunnycmf
sunnycmf / fix.rb
Last active August 29, 2015 14:26 — forked from tyler-sommer/fix.rb
Fix broken gitlab hooks in your project repositories
Dir.glob('/home/git/repositories/**/*.git') do |item|
hook = "#{item}/hooks"
if not File.symlink?(hook)
puts "Updating #{hook}"
File.rename(hook, "#{hook}.old")
File.symlink("/home/git/gitlab-shell/hooks", hook)
end
end
public class IncomingSms extends BroadcastReceiver {
     
    // Get the object of SmsManager
    final SmsManager sms = SmsManager.getDefault();
     
    public void onReceive(Context context, Intent intent) {
     
        // Retrieves a map of extended data from the intent.
        final Bundle bundle = intent.getExtras();
 
@sunnycmf
sunnycmf / solo.sh
Created April 21, 2015 03:43
Solo - Prevents multiple cron instances from running simultaneously. by Timothy Kay
#!/usr/bin/perl -s
#
# solo v1.6
# Prevents multiple cron instances from running simultaneously.
#
# Copyright 2007-2013 Timothy Kay
# http://timkay.com/solo/
#
# It is free software; you can redistribute it and/or modify it under the terms of either:
#
@sunnycmf
sunnycmf / docker_freq_use_cmd.md
Created April 20, 2015 08:29
docker cheat sheet

open a tty to the docker container docker exec -it [container-id] bash