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
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
mingfang / screensaver.sh
Created Aug 31, 2017
script to turn off and on Raspberry Pi Display by detecting IP or bluetooth device
View screensaver.sh
#!/bin/bash
while true
do
if ping -c 1 -w 3 192.168.2.67 &> /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
else
echo "you're gone. turning screen off"
echo 1 | sudo tee /sys/class/backlight/rpi_backlight/bl_power
@mingfang
mingfang / pgcalc.sh
Created Aug 31, 2017
script to calculate ceph pg number
View pgcalc.sh
#!/bin/bash
#Computes the suggested PG count similar to this http://ceph.com/pgcalc/
#Reguirements:
# - must run on ceph admin
# - depends on awk, wc and bc commands
#Limitations:
# - Assumes same OSD# for all pools
View gulpfile.js
// DO NOT CHANGE //
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
lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL
View public ip
curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
@mingfang
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 https://rudd-o.com/linux-and-free-software/a-better-way-to-block-brute-force-attacks-on-your-ssh-server
@mingfang
mingfang / convert id_rsa to pem
Last active Sep 17, 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
View docker registry search
You can’t perform that action at this time.