Skip to content

Instantly share code, notes, and snippets.

View EkkoG's full-sized avatar

Ekko EkkoG

View GitHub Profile
@EkkoG
EkkoG / gist:7da9cfe60d3bee32f40248da5066f964
Created May 17, 2022 07:15 — forked from amelnikov78/gist:9f74971b591cd837e0690208ef86849f
Swift extensions *can* add stored properties
/////////////////////////////////////////////////////
import Foundation
func associatedObject<ValueType: AnyObject>(
base: AnyObject,
key: UnsafePointer<UInt8>,
initialiser: () -> ValueType)
-> ValueType {
if let associated = objc_getAssociatedObject(base, key)
as? ValueType { return associated }
let associated = initialiser()
@EkkoG
EkkoG / ProtocolNotofication.swift
Created December 15, 2021 10:50 — forked from pofat/ProtocolNotofication.swift
Deal with notification with protocol-oriented programing in Swift
//: Playground - noun: a place where people can play
import UIKit
// This is for dmoe, you can use a generice type to limit your observer to an UIViewController for common usage.
typealias NotifiableExecuteBlock = (Notification) -> Void
protocol Notifiable {
var name: Notification.Name { get }
func observe(by observer: Any, withSelector selector: Selector, object: Any?)
func observe(with object: Any?, using block: @escaping NotifiableExecuteBlock)
@EkkoG
EkkoG / sshd_config
Last active June 18, 2019 07:56 — forked from HacKanCuBa/sshd_config
Modern secure SSH daemon config
# Modern secure (OpenSSH Server 7+) SSHd config by HacKan
# Refer to the manual for more info: https://www.freebsd.org/cgi/man.cgi?sshd_config(5)
# Server fingerprint
# Regenerate with: ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa -b 4096
HostKey /etc/ssh/ssh_host_rsa_key
# Regerate with: ssh-keygen -f /etc/ssh/ssh_host_ed25519_key -N '' -t ed25519
HostKey /etc/ssh/ssh_host_ed25519_key
# Log for audit, even users' key fingerprint
@EkkoG
EkkoG / turbo-qiniu.sh
Created February 21, 2017 07:03 — forked from trawor/turbo-qiniu.sh
本脚本解决部分地区七牛上传速度慢的问题
#!/bin/bash
#
# 通过对比 ping 响应时间,找到本机最快的上传ip
# Travis@fir.im
#
# 使用方法:
# sh -c "$(curl -sSL https://gist.githubusercontent.com/trawor/5dda140dee86836b8e60/raw/turbo-qiniu.sh)"
echo "# 这个脚本理论上可以帮你获取任意域名的最快速的IP"
echo "# 获取IP列表的服务由 17ce.com 提供, 非常感谢有这么好的免费服务!"
@EkkoG
EkkoG / surf.conf
Last active August 24, 2016 16:51 — forked from networkextension/surf.conf
surf.conf
# A.BIG.T rule config
# 用编辑器编辑后,再通过 iTunes, URL, AirDrop 或者 iCloud Drive 复制回 iOS 设备
# Version 2.0
[General]
# 日志等级: error,warning, notify, info, verbose (默认值: info)
loglevel = info
# 跳过某个域名或者 IP 段,这些目标主机将不会由 A.BIG.T 处理。
skip-proxy = 127.0.0.1, 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12, 100.64.0.0/10, localhost, *.local
# 强制使用特定的 DNS 服务器
@EkkoG
EkkoG / homebrew.mxcl.pdnsd.plist
Created September 24, 2015 04:00 — forked from fujimogn/homebrew.mxcl.pdnsd.plist
Installing pdnsd from Homebrew

Installing pdnsd from homebrew as root user.

$ brew install pdnsd

$ sudo chown -R nobody /usr/local/var/cache/pdnsd

$ curl -L http://goo.gl/kMlyQ -o pdnsd.conf
$ mv pdnsd.conf /usr/local/etc
$ sudo chown root /usr/local/etc/pdnsd.conf
@EkkoG
EkkoG / git.md
Last active February 5, 2018 16:32 — forked from suziewong/git.md

1.同一台电脑可以有2个git账号(不同网站的)

首先不同网站,当然可以使用同一个邮箱,比如我的github,gitlab,bitbucket的账号都是monkeysuzie[at]gmail.com 这时候不用担心密钥的问题,因为这些网站push pull 认证的唯一性的是邮箱 比如我的windows 上 2个账号一个gitlab 一个github (用的都是id_rsa)

host github
  hostname github.com
  Port 22

host gitlab.zjut.com

@EkkoG
EkkoG / 0_reuse_code.js
Created June 13, 2014 16:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
#weasel.custom.yaml
patch:
"preset_color_schemes/Solarized_Lite":
author: "五磅兔 zcunlin@foxmail.com, based on Aben's 曬經石\solarized_Rock, original artwork by ethanschoonover‘s solarized"
back_color: 0xe3f6fd #底色
border_color: 0xd5e8ee #边框色
candidate_text_color: 0x837b65 #候选项颜色
comment_text_color: 0xd28b26 #编码提示颜色
hilited_back_color: 0xd5e8ee #编码底色
hilited_candidate_back_color: 0x98a12a #首选项高亮背景色