Skip to content

Instantly share code, notes, and snippets.

View lepture's full-sized avatar
💭
I'm working on Typlog.com now

Hsiaoming Yang lepture

💭
I'm working on Typlog.com now
View GitHub Profile
@lepture
lepture / gist.js
Created May 12, 2022 13:26
Gist in Shadow DOM, for react, vue, svetle, and etc.
const iframeCode = `
<style>html,body{margin:0;padding:0}</style>
<script>
window.addEventListener("message", (e) => {
if (e.ports) {
const channel = e.ports[0]
const timestamp = e.data.init
channel.postMessage({'height': document.body.scrollHeight, 'timestamp': timestamp})
}
})

Keybase proof

I hereby claim:

  • I am lepture on github.
  • I am lepture (https://keybase.io/lepture) on keybase.
  • I have a public key whose fingerprint is 72F8 E895 A70C EBDF 4F2A DFE0 7E55 E3E0 118B 2B4C

To claim this, I am signing this object:

@lepture
lepture / hitch.rb
Last active September 7, 2017 07:24
Homebrew brew formula for Varnish'es Hitch TLS Proxy Server
class Hitch < Formula
desc "A scalable TLS proxy by Varnish Software"
homepage "https://github.com/varnish/hitch"
url "https://github.com/varnish/hitch/archive/hitch-1.4.6.tar.gz"
sha256 "fecc0604a2574e50e99573536eade96769b3435aa787d2095ed9115434a6f003"
head "https://github.com/varnish/hitch.git"
depends_on "automake" => :build
depends_on "autoconf" => :build
depends_on "pkg-config" => :build
@lepture
lepture / index.html
Created July 10, 2017 05:39
test-golang-fetch
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test Upload</title>
</head>
<body>
<form action="/upload" method="post" enctype="multipart/form-data">
<input type="file">
<button>Submit</button>
@lepture
lepture / README.md
Last active April 13, 2024 11:11
Is in China

Detecting if current browser is in China

Use the script below:

isInChina(function(inChina) {
  console.log('In china: ' + inChina);
})
@lepture
lepture / cloudflare.conf
Last active October 23, 2017 22:09
Cloudflare for Nginx
map $http_cf_visitor $cf_scheme {
'{"scheme":"http"}' http;
'{"scheme":"https"}' https;
default $http_x_forwarded_proto;
}
set_real_ip_from 103.21.244.0/22;
set_real_ip_from 103.22.200.0/22;
set_real_ip_from 103.31.4.0/22;
set_real_ip_from 104.16.0.0/12;
@lepture
lepture / export-june.py
Created July 28, 2015 15:10
export june database to JSON
# code: utf-8
import json
import datetime
import pymysql
class JSONEncoder(json.JSONEncoder):
def default(self, o):
if isinstance(o, datetime.datetime):
#!/usr/bin/env python
import os
import re
import sys
import json
import requests
def parse_junit(filepath):
@lepture
lepture / slack-logger.py
Created December 15, 2014 07:24
Send logging to slack by webhook
# coding: utf-8
import json
import logging
import requests
class SlackHandler(logging.Handler):
def __init__(self, url, channel, username='error', emoji='scream'):
super(SlackHandler, self).__init__()
@lepture
lepture / backup2qiniu.py
Last active August 31, 2015 07:55
Backup Database to Qiniu
#!/usr/bin/env python
import os
import sys
import hmac
import json
import time
import hashlib
import datetime
import requests