Skip to content

Instantly share code, notes, and snippets.

@pexcn
pexcn / ChinaDNS Flow.md
Last active February 6, 2023 03:03
记录一下 ChinaDNS 的工作原理和一些 DNS 相关的想法

ChinaDNS 的工作流程

ChinaDNS 的上游 DNS 分为 国内 DNS可信 DNS

工作流程

  1. ChinaDNS 会同时向上游的 DNS 发送请求。
  2. 如果 可信 DNS 先返回,则直接采用 可信 DNS 的结果。
  3. 如果 国内 DNS 先返回,分两种情况:如果返回的结果是国内的 IP, 则采用;否则丢弃并转而采用 可信 DNS 的结果。
@SimonTart
SimonTart / .npmrc
Last active November 19, 2022 09:57
npmrc config for china
registry=https://registry.npm.taobao.org
disturl=https://npm.taobao.org/dist
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
phantomjs_cdnurl=https://npm.taobao.org/mirrors/phantomjs/
electron_mirror=https://npm.taobao.org/mirrors/electron/
chromedriver_cdnurl=https://npm.taobao.org/mirrors/chromedriver
operadriver_cdnurl=https://npm.taobao.org/mirrors/operadriver
selenium_cdnurl=https://npm.taobao.org/mirrors/selenium
node_inspector_cdnurl=https://npm.taobao.org/mirrors/node-inspector
fsevents_binary_host_mirror=http://npm.taobao.org/mirrors/fsevents/
@rynffoll
rynffoll / surfingkeys.js
Last active December 1, 2016 13:27
Surfingkeys Config
// mapping like vimum
map('u', 'e');
mapkey('p', "Open the clipboard's URL in the current tab", function() {
Front.getContentFromClipboard(function(response) {
window.location.href = response.data;
});
});
map('P', 'cc');
map('gi', 'i');
map('F', 'af');
@pierdom
pierdom / plot_precounted_hist.py
Last active August 3, 2023 11:56
[Plot histograms with pre-computed counters] Plot histograms with Marplotlib hist function or Seaborn distplot function using pre-counted values using 'weights' argument. Very useful for plotting distributions of values queried from a very large dataset, where it is impossible to retrieve and load in memory every element of the distribution inde…
#!/usr/bin/env python3
import matplotlib.pyplot as plt
import seaborn as sns
# dictionary with pre-counted bins
test = {1:1,2:1,3:1,4:2,5:3,6:5,7:4,8:2,9:1,10:1}
# with matplotlib
plt.hist(list(test.keys()), weights=list(test.values()))
# lifted cool stuff from:
# https://github.com/fish-shell/fish-shell/blob/master/share/functions/fish_prompt.fish
# https://github.com/fish-shell/fish-shell/blob/master/share/tools/web_config/sample_prompts/robbyrussell.fish
function fish_prompt
# define git functions if not already defined
if not set -q -g __fish_git_functions_defined
set -g __fish_git_functions_defined
function _git_branch_name
@andrewgiessel
andrewgiessel / gist:5684769
Created May 31, 2013 12:52
fit a sigmoid curve, python, scipy
# good discussion here: http://stackoverflow.com/questions/4308168/sigmoidal-regression-with-scipy-numpy-python-etc
# curve_fit() example from here: http://permalink.gmane.org/gmane.comp.python.scientific.user/26238
# other sigmoid functions here: http://en.wikipedia.org/wiki/Sigmoid_function
import numpy as np
import pylab
from scipy.optimize import curve_fit
def sigmoid(x, x0, k):
y = 1 / (1 + np.exp(-k*(x-x0)))
@jsundram
jsundram / colors.py
Created June 7, 2011 14:39
Expose D3 Colors for matplotlib
from matplotlib.colors import hex2color
# color schemes Courtesy of the excellent mbostock's D3.js project
d3_10 = ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf']
d3_20 = ['#1f77b4', '#aec7e8', '#ff7f0e', '#ffbb78', '#2ca02c', '#98df8a', '#d62728', '#ff9896', '#9467bd', '#c5b0d5', '#8c564b', '#c49c94', '#e377c2', '#f7b6d2', '#7f7f7f', '#c7c7c7', '#bcbd22', '#dbdb8d', '#17becf', '#9edae5']
d3_20b = ['#393b79', '#5254a3', '#6b6ecf', '#9c9ede', '#637939', '#8ca252', '#b5cf6b', '#cedb9c', '#8c6d31', '#bd9e39', '#e7ba52', '#e7cb94', '#843c39', '#ad494a', '#d6616b', '#e7969c', '#7b4173', '#a55194', '#ce6dbd', '#de9ed6']
d3_20c = ['#3182bd', '#6baed6', '#9ecae1', '#c6dbef', '#e6550d', '#fd8d3c', '#fdae6b', '#fdd0a2', '#31a354', '#74c476', '#a1d99b', '#c7e9c0', '#756bb1', '#9e9ac8', '#bcbddc', '#dadaeb', '#636363', '#969696', '#bdbdbd', '#d9d9d9']