Skip to content

Instantly share code, notes, and snippets.

import collections
import csv
from datetime import datetime
def analytic_1():
site_dict = collections.defaultdict(set)
largest_number, site_ids = 0, []
with open('SWE sample data - Q3 data.csv') as csv_file:
csv_reader = csv.reader(csv_file)
for row in csv_reader:
def equalsWhenOneCharRemoved(x, y):
i, j = len(x), len(y)
if abs(i - j) == 1:
for k in range(max(i, j)):
if x[k] != y[k]:
return equalsWhenOneCharRemoved(x[k+1:], y[k:]) or \
equalsWhenOneCharRemoved(x[k:], y[k+1:])
elif i == j:
for k in range(i):
if x[k] != y[k]:
@lightwindy
lightwindy / fetch-api-examples.md
Created August 24, 2018 19:03 — forked from justsml/fetch-api-examples.md
JavaScript Fetch API Examples
@lightwindy
lightwindy / latency.txt
Created June 12, 2017 00:20 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@lightwindy
lightwindy / gist:e88568ae29d4abcd81f3397bb0c078ce
Created March 19, 2017 23:22 — forked from Atem18/gist:4696071
Tutorial to seting up a django website in production.

Set up Django, Nginx and Gunicorn in a Virtualenv controled by Supervisor

Steps with explanations to set up a server using:

  • Virtualenv
  • Virtualenvwrapper
  • Django
  • Gunicorn
@lightwindy
lightwindy / deploy-flask-gunicorn-supervisor-nginx.md
Created March 17, 2017 00:04 — forked from binderclip/deploy-flask-gunicorn-supervisor-nginx.md
Flask Gunicorn Supervisor Nginx 项目部署小总结

Flask Gunicorn Supervisor Nginx 项目部署小总结

服务器的基本连接和配置

SSH 连接

使用公钥私钥来登陆而不是账号密码,公钥私钥需要简单的在本地生成一下。Github 的生成 SSH 公钥私钥的教程:Generating SSH keys

可能需要使用 -i 参数选择一下本地的私钥,一个示例的 ssh 连接如下:

@lightwindy
lightwindy / python-smtp-send-qq-mail.py
Created March 7, 2017 23:46 — forked from binderclip/python-smtp-send-qq-mail.py
Python & Email,附上用 Python 发送 QQ 邮箱邮件的代码
import smtplib
from getpass import getpass
def prompt(prompt):
return input(prompt).strip()
fromaddr = prompt("From: ")
toaddrs = prompt("To: ").split()
subject = prompt("Subject: ")
print("Enter message, end with ^D (Unix) or ^Z (Windows):")