Skip to content

Instantly share code, notes, and snippets.

YangLe smilingpoplar

Block or report user

Report or block smilingpoplar

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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.
*
@smilingpoplar
smilingpoplar / ghs.conf
Created Jan 21, 2012
nginx反向代理ghs
View ghs.conf
upstream ghs {
ip_hash;
server ghs.google.com;
}
server {
listen 80;
server_name ghs.49px.com xxx.49px.com;
location / {
proxy_pass http://ghs;
proxy_redirect off;
You can’t perform that action at this time.