Skip to content

Instantly share code, notes, and snippets.

View athurg's full-sized avatar
🐵

Athurg Gooth athurg

🐵
View GitHub Profile
@athurg
athurg / crypt3.rb
Last active August 29, 2015 14:09 — forked from trans/crypt3.rb
独立于操作系统平台的Crypt函数(在各平台,比如OS X、Linux都可获得一致的结果)。
# Crypt3
#
# A ruby version of crypt(3), a salted one-way hashing of a password.
#
# The Ruby version was written by Poul-Henning Kamp.
#
# Copyright (c) 2002 Poul-Henning Kamp
#
# Adapted by guillaume__dot__pierronnet_at__laposte__dot_net based on
# * http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/325204/index_txt
@athurg
athurg / zerossl.com-zh_CN-localize.txt
Last active September 29, 2016 03:31
zerossl.com 's zh_CN localizition text
#SECTION P#
#Item 1#
邮箱地址 (可选)
#Item 2#
域名列表 (仅当您没有CSR文件时输入)
#Item 3#
请粘贴您的Let's Encrypt key文件内容,或者留空由我们自动生成
@athurg
athurg / sc_state_grid.go
Created September 28, 2016 11:38
国网四川省电力公司电费查询工具
/*
掌上川电客户端
@description 可以查询用户信息近期用电详情
使用方式:
1. 先以`-listen port`参数启动本程序,建立一个HTTP代理服务器
2. 设置手机使用这个代理服务器,并打开“掌上川电”客户端进行登陆
3. 登陆成功后,本代理服务器会自动检测到会话编号并输出,此时可以关闭手机代理的设置
4. 以`-sid 会话编号`为参数启动本程序,即可查询
@athurg
athurg / non_ascii_string_align.go
Created September 28, 2016 11:49
非ASCII字符串对其输出代码
package main
import (
"fmt"
"strings"
"unicode/utf8"
)
func main() {
a := "中文A是不是很长啊对的很"
@athurg
athurg / openssh_keygen.go
Created September 28, 2016 11:49
生成OpenSSH兼容的密钥对代码
package main
import(
"fmt"
"io/ioutil"
"bytes"
"encoding/binary"
"crypto/rsa"
"crypto/rand"
"crypto/x509"
@athurg
athurg / ovpn_server.conf
Created October 8, 2016 08:40
OpenVPN服务器配置范例
#由于采用用户名密码认证
#所以服务器配置只需要通过
# 1. source ./vars
# 2. `./build-ca` 生成CA根证书(服务器客户端一致)
# 3. `./build-key-server servername` 生成服务器证书对(cert/key)
# 4. `openvpn --genkey --secret ta.key` 生成TLS私钥(服务器客户端一直)
# 即可,无需生成客户端的cert证书和key私钥
# 设置监听IP,默认是监听所有IP
local x.x.x.x
@athurg
athurg / openvpn_mysql_pam.conf
Created October 8, 2016 08:42
PAM配置文件,用于OpenVPN通过PAM方式认证
# Authentication
users.host=192.81.133.165
users.db_user=athurg
users.db_passwd=bZrYmtV7SzScJxe
users.database=athurg_wendangku
users.table=bs_user
users.user_column=email
users.password_column=passwd
users.password_crypt=1
users.where_clause=expire_time>now() and email like '%@%'
@athurg
athurg / git_branch_sync.sh
Created October 14, 2016 06:14
Pull all branch to local and set track
#!/bin/sh
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
@athurg
athurg / p12_to_pem.sh
Created October 31, 2016 11:05
macOS证书助理导出的p12证书包转换成PEM的命令
#!/bin/sh
openssl pkcs12 -in source.p12 -clcerts -nodes
@athurg
athurg / silece_log.rb
Created May 9, 2017 08:55
用于将部分Rails请求日志屏蔽掉的代码
# encoding: utf-8
# Place into Rails.root/config/initializers
Rails::Rack::Logger.class_eval do
def call_with_quiet_assets(env)
previous_level = Rails.logger.level
Rails.logger.level = Logger::FATAL if env['PATH_INFO']=="/silence/request"
call_without_quiet_assets(env).tap do
Rails.logger.level = previous_level
end
end