Skip to content

Instantly share code, notes, and snippets.

View EkkoG's full-sized avatar

Ekko EkkoG

View GitHub Profile
@imk2o
imk2o / RxPublished.swift
Last active January 17, 2024 15:12
RxPublished (property wrapper)
import Foundation
import RxSwift
import RxCocoa
// NOTE
// 参考実装
// https://www.swiftbysundell.com/articles/property-wrappers-in-swift/
//
// Exclusively Enforcement問題
// (購読の仕方によって wrappedValue.setter 内で getter が呼ばれるケースがある)
// Original article here: https://www.fivestars.blog/code/swiftui-hierarchy-list.html
import SwiftUI
struct FileItem: Identifiable {
let name: String
var children: [FileItem]?
var id: String { name }
@catchdave
catchdave / replace_synology_ssl_certs.sh
Last active April 28, 2024 07:17
CLI script to programmatically replace SSL certs on Synology NAS
#!/bin/bash
#
# *** For DSM v7.x ***
#
# How to use this script:
# 1. Get your 3 PEM files ready to copy over from your local machine/update server (privkey.pem, fullchain.pem, cert.pem)
# and put into a directory (this will be $CERT_DIRECTORY).
# Personally, I use this script (https://gist.github.com/catchdave/3f6f412bbf0f0cec32469fb0c9747295) to automate steps 1 & 4.
# 2. Ensure you have a user setup on synology that has ssh access (and ssh access is setup).
# This user will need to be able to sudo as root (i.e. add this line to sudoers, <USER> is the user you create):
extension KeyedDecodingContainer {
func decode<T: NSCoding>(_ type: T.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> T? {
let data = try decode(Data.self, forKey: key)
return try NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data) as? T ?? nil
}
}
extension KeyedEncodingContainer {
@zthxxx
zthxxx / Activate Office 2019 for macOS VoL.md
Last active May 1, 2024 22:04
crack activate Office on mac with license file
@klzgrad
klzgrad / Traffic analysis survey.md
Last active March 17, 2024 09:49
流量分类调研

为什么流量可以进行分类

这里的“流量”一般定义为中间人观测到的一组由(时间,方向,包大小)元数据组成的序列 [Cai2014]。其源头是应用层的读写操作,经过传输层协议的变换(分片、协议状态机、加密等),流量序列产生一定变化。但是这种变化非常有限,因为流量的发生过程本质是确定性的,随机因素较小,因此对于特定环境中的特定应用(浏览器访问 google.com)各种流量特征体现出相当大的一致性和独特性,这就使“从流量特征识别应用”的监督学习问题成为可能。虽然有若干不利因素使得确定性下降,例如多层次上软件多版本的排列组合爆炸、有状态的缓存、流水线和连接复用、用户随机行为,但是因为版本的幂律分布、应用层读写操作间的依赖关系、流量特征和检测算法的改进等原因,分类依然具有相当的可行性。

分类的对象:流量应用分类与网站指纹攻击

根据分类的对象产生了两个相近但是不同的研究领域。从流量特征中分类应用类型的被称为流量分类(traffic classification),从流量特征中分类所访问网站或者网页的被称为网站指纹(website fingerprinting)。以机器学习的方法而论前者是比后者更弱但本质相同的一个问题。

这两类攻击的威胁类型不同。流量分类威胁的是可用性,如果GFW检出流量是隧道应用然后进行封锁,则破坏了可用性。而网站指纹威胁的是匿名性和隐私,如果从隐秘流量中检出是谁在访问哪个网站,则破坏了匿名性,丝绸之路就是这样被FBI破获的。

@tcalmant
tcalmant / socks5.py
Last active January 17, 2021 21:00
A working SOCKS5 server based on asyncio (TCP Connect only)
#!/usr/bin/env python3
"""
Asyncio-based SOCKS5 Proxy
:author: Thomas Calmant
:copyright: Copyright 2017, Thomas Calmant
:license: Apache License 2.0
:version: 0.0.1
"""
@phizaz
phizaz / async.py
Last active April 3, 2024 15:44
Python turn sync functions to async (and async to sync)
import functools
def force_async(fn):
'''
turns a sync function to async function using threads
'''
from concurrent.futures import ThreadPoolExecutor
import asyncio
pool = ThreadPoolExecutor()
@pofat
pofat / ProtocolNotofication.swift
Last active December 15, 2021 10:50
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.
protocol Notifiable {
var name: Notification.Name { get }
func observe(by observer: Any, withSelector selector: Selector, object: Any?)
func post(object: Any? ,userInfo: [AnyHashable: Any]?)
static func remove(observer: Any)

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?