Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Sunny Chan sunnycmf

🎯
Focusing
View GitHub Profile
@sunnycmf
sunnycmf / mitmproxy pf
Created May 9, 2016 — forked from khapota/mitmproxy pf
/etc/pf.anchors/mitm
View mitmproxy pf
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 — forked from khapota/pf.conf
pf conf mac os 10.10
View pf.conf
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"
View apache-and-tomcat-logs.json
{
"title": "Apache and Tomcat Logs",
"services": {
"query": {
"list": {
"0": {
"query": "apache !tomcat !static",
"alias": "",
"color": "#7EB26D",
"id": 0,
@sunnycmf
sunnycmf / README.md
Created Oct 14, 2015 — forked from Luzifer/README.md
Strategies for persistent data storage on CoreOS-cluster
View README.md

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 Aug 29, 2015 — forked from jmeyo/beaudev_docker_nginx_proxy_host.sh
Beaudev simple script to add a nginx vhost reverse proxying to a docker instance
View beaudev_docker_nginx_proxy_host.sh
#!/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 Aug 29, 2015 — forked from jmeyo/beaudev_docker_aliases.sh
Beaudev Docker alias and usefull functions
View beaudev_docker_aliases.sh
#!/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 Aug 29, 2015 — forked from tyler-sommer/fix.rb
Fix broken gitlab hooks in your project repositories
View fix.rb
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
View android_read_sms.java
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 Apr 21, 2015
Solo - Prevents multiple cron instances from running simultaneously. by Timothy Kay
View solo.sh
#!/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:
#
View docker_freq_use_cmd.md

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

You can’t perform that action at this time.