Skip to content

Instantly share code, notes, and snippets.

View athurg's full-sized avatar
🐵

Athurg Gooth athurg

🐵
View GitHub Profile
import SwiftUI
import MapKit
struct Point: Identifiable {
var id = UUID()
var latitude, longitude: Double
func coordinate() -> CLLocationCoordinate2D {
CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
}
}
@athurg
athurg / openwrt_hotplug_for_qcloud.sh
Created October 8, 2018 14:50
用于OpenWRT的腾讯云DNS自动更新脚本
#!/bin/sh
#
# Howto
# 1. Install pkgs by run `opkg install ca-bundle openssl-util libustream-openssl`
# 1. Upload this script to your OpenWRT router.
# 2. Save as /etc/hotplug.d/iface/99-ddns.
# 3. Replace the VARIABLES below.
# 4. Enjoy!
# variables should be changed
@athurg
athurg / traceroute_with_geo.go
Created April 13, 2018 06:20
带地理位置信息的traceroute
package main
import (
"errors"
"fmt"
"golang.org/x/net/icmp"
"golang.org/x/net/ipv4"
"net"
"os"
"regexp"
@athurg
athurg / fluentd.conf
Created March 8, 2018 05:59
Fluentd采集Docker日志配置范例
<source>
@type forward
port 24224
</source>
<filter docker.**>
@type record_transformer
<record>
log ${time} ${record["container_name"]} ${record["log"]}
</record>
@athurg
athurg / walk_go-git_inmemory_worktree.go
Created December 1, 2017 07:50
遍历go-git内存文件系统的工作区
package main
import (
"fmt"
"io/ioutil"
"os"
"gopkg.in/src-d/go-billy.v3"
"gopkg.in/src-d/go-billy.v3/memfs"
"gopkg.in/src-d/go-git.v4"
@athurg
athurg / golang_image_filter.go
Created October 31, 2017 03:25
Golang版本的图像二值化分析范例
package main
import(
"fmt"
"os"
"image"
"image/jpeg"
"image/draw"
)
@athurg
athurg / rating_analysis.py
Created October 17, 2017 09:18
Coursera《用Python玩转数据》编程作业《男女电影评分差异分析编程》代码
# Cousera课程《用Python玩转数据 Data Processing Using Python》第4.2章编程作业《男女电影评分差异分析编程》
#
#分析数据集,找出男性女性用户评分的标准差,并输出两位小数部分
#提示:先分别计算每个人电影评分的平均分,再按性别求标准差
#使用方法:
# python work.py > result.txt
import pandas
@athurg
athurg / add_ca_certificate_for_docker_in_ubuntu.sh
Created May 22, 2017 09:16
如何在Ubuntu下添加信任的CA证书,并让Docker pull也信任
#!/bin/sh
#说明:
# 在Ubuntu中,Docker在pull image时,所使用的CA证书和ubuntu系统的一致。
# 所以,要想docker pull时使用自己的CA证书签名的证书,最简单的方式就是在系统中添加CA。
# 当然,Docker文档中也提到了一些仅仅添加到Docker(而不是全系统)的方式,实测下来貌似没用。
# 直接将CA添加到Ubuntu系统中,并让Docker pull生效,需要三个步骤
# 第一步,添加CA文件,注意,这里目标文件名必须以crt结束
cp path/to/your_ca.crt /usr/local/share/ca-certificates/xxx.crt
@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
@athurg
athurg / p12_to_pem.sh
Created October 31, 2016 11:05
macOS证书助理导出的p12证书包转换成PEM的命令
#!/bin/sh
openssl pkcs12 -in source.p12 -clcerts -nodes