Skip to content

Instantly share code, notes, and snippets.

Ming Fang mingfang

Block or report user

Report or block mingfang

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
mingfang / shell.go
Created Nov 10, 2019
Cadence activity to execute shell commands
View shell.go
package main
import (
View Alluxio.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
mingfang /
Created Aug 31, 2017
script to turn off and on Raspberry Pi Display by detecting IP or bluetooth device
while true
if ping -c 1 -w 3 &> /dev/null || hcitool scan | grep -q -E "ming-macbook|Ming's iPhone" ; then
echo "welcome back. turning screen on"
echo 0 | sudo tee /sys/class/backlight/rpi_backlight/bl_power
echo "you're gone. turning screen off"
echo 1 | sudo tee /sys/class/backlight/rpi_backlight/bl_power
mingfang /
Created Aug 31, 2017
script to calculate ceph pg number
#Computes the suggested PG count similar to this
# - must run on ceph admin
# - depends on awk, wc and bc commands
# - Assumes same OSD# for all pools
View gulpfile.js
const gulp = require('gulp');
const webpack = require('webpack');
const WebpackDevServer = require('webpack-dev-server');
const gwebpack = require('webpack-stream');
const browserSync = require('browser-sync');
const runSequence = require('run-sequence');
const debug = require('gulp-debug');
const cache = require('gulp-cached');
View show vm ip
virt-cat -d vm1 /var/lib/dhcp/dhclient.eth0.leases
View gist:dcc5203c78775b9f4f8f
View public ip
curl -s | sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
mingfang / gist:d7668c6a54079d613f89
Created Feb 10, 2015
Iptables rules to defend against brute force ssh attack
View gist:d7668c6a54079d613f89
iptables -A INPUT -p tcp -m tcp --dport 22 -m state --state NEW -m recent --set --name SSH --rsource
iptables -A INPUT -p tcp -m tcp --dport 22 -m recent --rcheck --seconds 30 --hitcount 4 --rttl --name SSH --rsource -j REJECT --reject-with tcp-reset
iptables -A INPUT -p tcp -m tcp --dport 22 -m recent --rcheck --seconds 30 --hitcount 3 --rttl --name SSH --rsource -j LOG --log-prefix "SSH brute force "
iptables -A INPUT -p tcp -m tcp --dport 22 -m recent --update --seconds 30 --hitcount 3 --rttl --name SSH --rsource -j REJECT --reject-with tcp-reset
iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
#based on
mingfang / convert id_rsa to pem
Last active Dec 7, 2019
Convert id_rsa to pem file
View convert id_rsa to pem
openssl rsa -in ~/.ssh/id_rsa -outform pem > id_rsa.pem
chmod 700 id_rsa.pem
You can’t perform that action at this time.