Skip to content

Instantly share code, notes, and snippets.

Avatar

YangLe smilingpoplar

View GitHub Profile
View xq_launch.js
/* quantumultx remove xueqiu launch ad, using Charles to analyze network activities
[rewrite_local]
^https?://(101\.201\.175\.228|182\.92\.251\.113)\/brand\/search\/v1.json* url script-response-body https://gist.githubusercontent.com/smilingpoplar/ab74f2e176b91a0ca597b4222971f5a2/raw/xxxxx/xq_launch.js
[mitm]
hostname = 101.201.175.228, 182.92.251.113
*/
$done(JSON.stringify({"data":{},"result_code":0,"message":""}));
@smilingpoplar
smilingpoplar / ddns
Created Apr 30, 2019
ddns for dnspod
View ddns
#!/bin/sh
token='<dnspod_id>,<dnspod_token>'
domain='<your_domain>'
sub_domain='<your_subdomain>'
new_ip=${3:-$(curl -s 'https://api.ip.sb/geoip/' | sed 's/.*"ip":"\([0-9.]*\)".*/\1/')}
api_call() {
local param="login_token=${token}&format=json&domain=${domain}&${2}"
curl -s -k -XPOST -o- -A'shdns/0.1(php@html.js.cn)' -d $param https://dnsapi.cn/${1}
}
View normalise.py
# -*- coding: utf-8 -*-
import unicodedata
""" Normalise (normalize) unicode data in Python to remove umlauts, accents etc. """
data = u'naïve café'
normal = unicodedata.normalize('NFKD', data).encode('ASCII', 'ignore')
print normal
@smilingpoplar
smilingpoplar / string_util.cpp
Last active Oct 7, 2015
string with format
View string_util.cpp
string stringWithFormat(const char *fmt, ...) {
int desiredLength= 1024;
string str;
str.resize(desiredLength);
va_list ap;
while (true) {
va_start(ap, fmt);
int printedLength= vsnprintf((char *)str.c_str(), str.size()+1, fmt, ap);
va_end(ap);
// '-1' means the buffer was too small.
@smilingpoplar
smilingpoplar / ColourUtils.h
Created May 12, 2012
convert color between RGBA and HSV
View ColourUtils.h
/*
* ColourUtils.h
*
* Copyright 2012 Stewart Hamilton-Arrandale.
* http://creativewax.co.uk
*
* Modified by Yannick Loriot.
* http://yannickloriot.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@smilingpoplar
smilingpoplar / gitit.conf
Created Feb 13, 2012
nginx端口转发gitit
View gitit.conf
server {
listen 80;
server_name wiki.49px.com;
location / {
proxy_pass http://127.0.0.1:5001;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
@smilingpoplar
smilingpoplar / .screenrc
Created Feb 6, 2012
screen配置文件
View .screenrc
# ~/.screenrc
# kill splash screen
# startup_message off
# replace C-a with C-j
escape ^Jj
# show original screen when exit from emacs/vi
altscreen on
@smilingpoplar
smilingpoplar / gist:1728823
Created Feb 3, 2012
找出test开头的函数
View gist:1728823
import types
for k,v in vars().items():
if k.startswith('test') and isinstance(v, types.FunctionType):
print k, v
View gist:1728818
import time
time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
@smilingpoplar
smilingpoplar / DefaultKeyBinding.dict
Created Feb 3, 2012
xcode keybindings for emacs emulation
View DefaultKeyBinding.dict
{
/* Keybindings for emacs emulation. Compiled by Jacob Rus.
*
* To use: copy this file to ~/Library/KeyBindings/
* after that any Cocoa applications you launch will inherit these bindings
*
* This is a pretty good set, especially considering that many emacs bindings
* such as C-o, C-a, C-e, C-k, C-y, C-v, C-f, C-b, C-p, C-n, C-t, and
* perhaps a few more, are already built into the system.
*
You can’t perform that action at this time.