Skip to content

Instantly share code, notes, and snippets.

Avatar

Kevin cielpy

View GitHub Profile
View Codable+.swift
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 {
View allow_folx.sh
defaults write com.google.Chrome URLAllowlist -array-add -string "openinfolx3://*"
defaults write com.microsoft.Edge URLAllowlist -array-add -string "openinfolx3://*"
View PSW.rules
:PSW - [0:0]
:PSW_OUTPUT - [0:0]
-A PREROUTING -p tcp -j PSW
-A OUTPUT -p tcp -j PSW_OUTPUT
-A PSW -m set --match-set laniplist dst -j RETURN
-A PSW -m set --match-set vpsiplist dst -j RETURN
-A PSW -m set --match-set whitelist dst -j RETURN
-A PSW -m mark --mark 0xff -j RETURN
-A PSW -d 11.1.1.1/32 -p tcp -m comment --comment "\'默认\'" -j REDIRECT --to-ports 1041
-A PSW -p tcp -m comment --comment "\'默认\'" -m set --match-set shuntlist dst -j REDIRECT --to-ports 1041
@cielpy
cielpy / set.sh
Last active Apr 30, 2021
command to allow open folx without alert
View set.sh
defaults write com.google.Chrome URLAllowlist -array-add -string "openinfolx3://*"
View All_Capture.sgmodule
#!name=All Capture
#!desc=Capture the request body and save permanently.
[MITM]
hostname = *
@cielpy
cielpy / cmd.py
Last active Dec 9, 2020
A snippet code to call pipeline command line in Python programming language
View cmd.py
import subprocess
def _call(c, stdin=subprocess.PIPE):
command = subprocess.Popen(c,
stdin = stdin,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
return command.stdout, command.stderr, command
@cielpy
cielpy / query.py
Created Jun 25, 2019
河南省高考成绩查询
View query.py
import requests
import time
from bs4 import BeautifulSoup
for i in range(1000):
headers = {
'Proxy-Connection': 'keep-alive',
'Pragma': 'no-cache',
'Cache-Control': 'no-cache',
@cielpy
cielpy / sshd_config
Last active Jun 18, 2019 — forked from HacKanCuBa/sshd_config
Modern secure SSH daemon config
View sshd_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
@cielpy
cielpy / publish_auto.sh
Last active Jan 16, 2019
git flow publish script
View publish_auto.sh
#!/bin/bash
git_current_branch () {
local ref
ref=$(command git symbolic-ref --quiet HEAD 2> /dev/null)
local ret=$?
if [[ $ret != 0 ]]
then
[[ $ret == 128 ]] && return
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return