Skip to content

Instantly share code, notes, and snippets.

View orangle's full-sized avatar
🎯
Focusing

orangleliu orangle

🎯
Focusing
View GitHub Profile
@congdonglinux
congdonglinux / purge.lua
Created December 5, 2016 03:32 — forked from titpetric/purge.lua
Delete NGINX cached items from a PURGE request
-- Tit Petric, Monotek d.o.o., Thu 27 Oct 2016 10:43:38 AM CEST
--
-- Delete nginx cached assets with a PURGE request against an endpoint
--
local md5 = require 'md5'
function file_exists(name)
local f = io.open(name, "r")
if f~=nil then io.close(f) return true else return false end
import json
import pickle
import msgpack
TEST_REDIS = False
if TEST_REDIS:
import redis
rconn = redis.StrictRedis()
dataset = [(('key:%d' % i), {'a': 1, 'b': list(range(100)), 'c': ('z' * 25)}) for i in range(1000000)]
@swenson
swenson / explore.py
Created August 10, 2016 22:09
Ctags + Pygments static source generator
from collections import defaultdict
import json
import os
import os.path
import shutil
from pygments.formatters import HtmlFormatter
from pygments.lexers import get_lexer_for_filename
from pygments import highlight
@oysteinmoseng
oysteinmoseng / au-all.js
Created July 20, 2016 10:19
Highmaps Node Demo
module.exports = {"title":"Australia","version":"1.1.2","type":"FeatureCollection","copyright":"Copyright (c) 2015 Highsoft AS, Based on data from Natural Earth","copyrightShort":"Natural Earth","copyrightUrl":"http://www.naturalearthdata.com","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG:3112"}},"hc-transform":{"default":{"crs":"+proj=lcc +lat_1=-18 +lat_2=-36 +lat_0=0 +lon_0=134 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs","scale":0.000158093982027,"jsonres":15.5,"jsonmarginX":-999,"jsonmarginY":9851.0,"xoffset":-2082021.85219,"yoffset":-1210304.51735}},
"features":[{"type":"Feature","id":"AU.NT","properties":{"hc-group":"admin1","hc-middle-x":0.48,"hc-middle-y":0.58,"hc-key":"au-nt","hc-a2":"NT","labelrank":"2","hasc":"AU.NT","alt-name":null,"woe-id":"2344701","subregion":null,"fips":"AS03","postal-code":"NT","name":"Northern Territory","country":"Australia","type-en":"Territory","region":null,"longitude":"133.78","woe-name":"Northern Territory","latitude":"-20.102
@vasanthk
vasanthk / System Design.md
Last active May 24, 2024 06:19
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
import socket
import sys
import time
import struct
host = 'localhost'
port = 8888
buffersize = 1024
N = 1000000
server_address = (host, port)
@tawateer
tawateer / parallel_timed_rotating_handler.py
Last active January 11, 2021 06:07
重写 Python logging 的 TimedRotatingFileHandler doRollover 方法,解决多进程切割日志的问题。
#!/bin/env python
# -*- coding: utf-8 -*-
import os
import time
import logging
from logging.handlers import TimedRotatingFileHandler
LOG_DIR = "/tmp/"
local redis_c = require "resty.redis"
local ok, new_tab = pcall(require, "table.new")
if not ok or type(new_tab) ~= "function" then
new_tab = function (narr, nrec) return {} end
end
local _M = new_tab(0, 155)
@joyrexus
joyrexus / README.md
Last active April 9, 2023 22:43
golang web dev