Skip to content

Instantly share code, notes, and snippets.

View EkkoG's full-sized avatar

Ekko EkkoG

View GitHub Profile
@EkkoG
EkkoG / test.sh
Last active October 27, 2024 16:51
git clone https://github.com/MetaCubeX/mihomo.git
git -C mihomo checkout 3e966e82c793ca99e3badc84bf3f2907b100edae
git -C mihomo rev-parse HEAD
git -C mihomo config tar.xz.command "xz -c"
git -C mihomo archive --output=mihomo.tar.xz HEAD
sha256sum mihomo/mihomo.tar.xz
@EkkoG
EkkoG / network.java
Last active September 10, 2024 10:07
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;
public class NetworkUtils {
/**
* 获取系统为指定目的 IPv6 地址和端口选择的本地源 IPv6 地址
*
@EkkoG
EkkoG / main.py
Created December 19, 2023 03:34
import transmissionrpc
import argparse
def main(tc):
# get session stats
stats = tc.session_stats()
def printttt(s):
print(f"总活动时间: {s['secondsActive'] / 86400:.2f} 天")
print(f"总上传量: {s['uploadedBytes'] / 1024 / 1024 / 1024:.2f} GB")
@EkkoG
EkkoG / clash_example.yaml
Created March 24, 2023 15:18
clash_example.yaml
# Port of HTTP(S) proxy server on the local end
port: 7890
# Port of SOCKS5 proxy server on the local end
socks-port: 7891
# Transparent proxy server port for Linux and macOS (Redirect TCP and TProxy UDP)
# redir-port: 7892
# Transparent proxy server port for Linux (TProxy TCP and TProxy UDP)
@EkkoG
EkkoG / upgrade_cfw_core.sh
Last active July 10, 2022 08:49
A script used to replace Clash core with Clash.Meta core for Clash For Windows.
#!/bin/bash
DEST="/Applications/Clash for Windows.app/Contents/Resources/static/files/darwin/x64/clash-darwin"
VERSION=v1.12.0
ARCH=
if [[ $(uname -m) == 'arm64' ]]; then
ARCH=arm64
else
ARCH=amd64
@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()
#!/bin/bash
check_cmd() {
if ! command -v $1 > /dev/null
then
echo "<$1> could not be found"
if ! command -v brew > /dev/null
then
echo "<brew> could not be found"
echo "Please install Homebrew first"
@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)
extension KeyedEncodingContainer {
public mutating func encode<T>(_ value: T, forKey key: KeyedEncodingContainer<K>.Key) throws where T : NSCoding {
let data = try NSKeyedArchiver.archivedData(withRootObject: value, requiringSecureCoding: false)
try encode(data, forKey: key)
}
}
extension KeyedDecodingContainer {
public func decode<T>(_ type: T.Type, forKey key: KeyedDecodingContainer<K>.Key) throws -> T? where T : NSCoding {
svn propset svn:ignore -F .svnignore .