Skip to content

Instantly share code, notes, and snippets.

@cute
cute / filer.js
Last active August 8, 2019 08:18
weibo intl launch screen ad filter
/*
* weibo intl launch screen ad filter
* @author Li Guangming
*
* add rule: DOMAIN,weibointl.api.weibo.com,DIRECT,script-filter
*
*/
function scriptFilterExecute(args) {
if (args.url.indexOf('get_coopen_ads') > 0) {
@cute
cute / openssl_commands.md
Created May 31, 2019 06:56 — forked from p3t3r67x0/openssl_commands.md
Some list of openssl commands for check and verify your keys

openssl

Install

Install the OpenSSL on Debian based systems

sudo apt-get install openssl
@cute
cute / mime.txt
Created May 29, 2019 02:14
MIME types and file extensions
application/pkcs8 .p8 .key
application/pkcs10 .p10 .csr
application/pkix-cert .cer
application/pkix-crl .crl
application/pkcs7-mime .p7c
application/x-x509-ca-cert .crt .der
application/x-x509-user-cert .crt
application/x-pkcs7-crl .crl
@cute
cute / JavaScriptCore+fetch.swift
Created April 26, 2019 22:59 — forked from yycking/JavaScriptCore+fetch.swift
add fetch, console.log and Promise.then/catch to JavaScriptCore on iOS/Mac
import JavaScriptCore
extension JSContext {
subscript(key: String) -> Any {
get {
return self.objectForKeyedSubscript(key)
}
set{
self.setObject(newValue, forKeyedSubscript: key as NSCopying & NSObjectProtocol)
}
@cute
cute / NSTextStorageSubclass.swift
Created April 18, 2019 12:59 — forked from preble/NSTextStorageSubclass.swift
Base subclass of NSTextStorage in Swift
import Cocoa
@objc
class SomeTextStorage: NSTextStorage {
private var storage: NSMutableAttributedString
override init() {
storage = NSMutableAttributedString(string: "", attributes: nil)
super.init()
// Similar to defer in Swift
#define pspdf_defer_block_name_with_prefix(prefix, suffix) prefix ## suffix
#define pspdf_defer_block_name(suffix) pspdf_defer_block_name_with_prefix(pspdf_defer_, suffix)
#define pspdf_defer __strong void(^pspdf_defer_block_name(__LINE__))(void) __attribute__((cleanup(pspdf_defer_cleanup_block), unused)) = ^
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-function"
static void pspdf_defer_cleanup_block(__strong void(^*block)(void)) {
(*block)();
}
#pragma clang diagnostic pop
@cute
cute / convert id_rsa to pem
Created November 20, 2018 00:28 — forked from mingfang/convert id_rsa to pem
Convert id_rsa to pem file
openssl rsa -in ~/.ssh/id_rsa -outform pem > id_rsa.pem
chmod 700 id_rsa.pem
#source http://code.activestate.com/recipes/491264/
#edited by Guangming Li
import socket
class DNSQuery:
def __init__(self, data):
self.data = data
self.dominio = ''
@cute
cute / route_wifi.sh
Created September 26, 2018 05:58 — forked from cpthooch/route_wifi.sh
Routing all traffic to particular IP address via wifi network interface on MacOS
#!/bin/bash
# NOTE: wifi network interface is: en1
wifi_router=192.168.200.1
wifi_address=en1:ec.35.86.4f.00.bc
TOADDR=`ifconfig en1 inet | sed -nl 's/\w*inet \([^ ]*\).*/\1/p'`
TO=`echo -n ${TOADDR//[[:space:]]}`
echo "ADDING ROUTE TO $1 VIA en1 (wi-fi): $TO"
route -n add -host $1 $wifi_router -ifp $wifi_address -ifa $TO -static