Skip to content

Instantly share code, notes, and snippets.

View fangpsh's full-sized avatar
🌴
On vacation

fangpsh fangpsh

🌴
On vacation
View GitHub Profile
@fangpsh
fangpsh / otp
Created June 14, 2021 01:44 — forked from wr0ngway/otp
#!/bin/bash
# brew install oath-toolkit
#
# ~/.otpkeys:
# name1=secret
# name2=secret
scriptname=`basename $0`
if [ -z $1 ]
@fangpsh
fangpsh / rsyncd
Last active September 29, 2018 02:17
/etc/init.d/rsyncd for centos
#! /bin/sh
### BEGIN INIT INFO
# Provides: rsyncd
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Should-Start: $named
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: fast remote file copy program daemon
@fangpsh
fangpsh / nginx.conf
Last active July 31, 2018 09:29
whoami.fangpeishi.com (whoami.akamai.com) based on openresty
worker_processes 1;
daemon on;
master_process on;
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log debug;
#pid logs/nginx.pid;
@fangpsh
fangpsh / dynamic_quality.py
Created June 8, 2017 04:36 — forked from thebostik/dynamic_quality.py
Python Dynamic Image Quality Example
import cStringIO
import PIL.Image
from ssim import compute_ssim
def get_ssim_at_quality(photo, quality):
"""Return the ssim for this JPEG image saved at the specified quality"""
ssim_photo = cStringIO.StringIO()
# optimize is omitted here as it doesn't affect
# quality but requires additional memory and cpu
@fangpsh
fangpsh / 30_haproxy_stats.sh
Last active June 10, 2022 13:24
open-falcon agent haproxy plugin
#!/bin/bash
#requires: socat
#author: fangpsh
#关于采集的Haproxy指标和报警阈值设置请参考:https://github.com/iask/haproxymon
set -eu
STATS_SOCKET="/var/lib/haproxy/stats"
HOST=`cat /etc/hostname`
DATE=`date +%s`
tmp_info="/tmp/haproxy_info"
#!/bin/sh
# command | bash time-stramp.sh
if [ $# -gt 0 ];then
exec 0<$1;
fi
while read line
do
echo `date "+%Y-%m-%d %H:%M:%S"` $line;
done<&0;
#!/bin/bash
# Cronic v2 - cron job report wrapper
# Copyright 2007 Chuck Houpt. No rights reserved, whatsoever.
# Public Domain CC0: http://creativecommons.org/publicdomain/zero/1.0/
set -eu
OUT=/tmp/cronic.out.$$
ERR=/tmp/cronic.err.$$
TRACE=/tmp/cronic.trace.$$
@fangpsh
fangpsh / zypper.sh
Last active January 10, 2018 15:17
Enable zypper to auto-complete package names for bash
# zypper bash completion script
#
# A hackweek gift from Marek Stopka <mstopka@opensuse.org>
# Major rewrite by Josef Reidinger <jreidinger@suse.cz>
# 2009/02/19 Allow empty spaces in repos names, Werner Fink <werner@suse.de>
# 2014/12/15 Complete package names for install/remove/update/info/download , Fang Peishi <fangpeishi@gmail.com>
_strip()
{
local s c o
#!/bin/bash
if [ $# -eq 1 ]
NM=`uname -a && date`
NAME=`echo $NM | md5sum | cut -f1 -d" "`
then
ppa_name=`echo "$1" | cut -d":" -f2 -s`
if [ -z "$ppa_name" ]
then
echo "PPA name not found"
echo "Utility to add PPA repositories in your debian machine"