Skip to content

Instantly share code, notes, and snippets.

View zdying's full-sized avatar

zhang zdying

View GitHub Profile
@jdneo
jdneo / run xvfb in background
Last active May 7, 2019 18:05
run xvfb background in linux
1 copy the file into /etc/init.d/xvfb
2 chmod +x /etc/init.d/xvfb
3 ./etc/init.d/xvfb start
4 # some headless test here
5 ./etc/init.d/xvfb stop
@jfsiii
jfsiii / fetch-chunked.js
Last active March 30, 2024 01:37
Quick example of using fetch to parse a chunked response
var chunkedUrl = 'https://jigsaw.w3.org/HTTP/ChunkedScript';
fetch(chunkedUrl)
.then(processChunkedResponse)
.then(onChunkedResponseComplete)
.catch(onChunkedResponseError)
;
function onChunkedResponseComplete(result) {
console.log('all done!', result)
}
@paulirish
paulirish / what-forces-layout.md
Last active July 24, 2024 03:23
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
China stock api
1.163_API(0-sh,1-sz):http://api.money.126.net/data/feed/1002151,0600036,hkHSI,hkHSCEI,hk00005
2.QQ_API(sh,sz,s_simple data):http://qt.gtimg.cn/r=0.8409869808238q=s_sz000559,s_sz002434,s_sz002472,s_sz002488,hk00700
3.sina_API(sh,sz,s_simple data):http://hq.sinajs.cn/list=sh600000,sh600004,hk00700,sz002594
# 4.xueqiu_API:http://xueqiu.com/v4/stock/quote.json?code=02318,01211,SH000001,DJI30,HKHSI
163
日内实时盘口(JSON):
http://api.money.126.net/data/feed/1000002,1000001,1000881,0601398,money.api
@nsimmons
nsimmons / ReactNative-Deep-Dive.md
Last active October 9, 2023 07:48
ReactNative Deep Dive
@ejoubaud
ejoubaud / simulate_keypress.js
Last active April 9, 2024 18:38
Simulate keypress that works in Google nav in Chrome
// Based on http://stackoverflow.com/a/10520017/1307721 and http://stackoverflow.com/a/16022728/1307721
Podium = {};
Podium.keydown = function(k) {
var oEvent = document.createEvent('KeyboardEvent');
// Chromium Hack
Object.defineProperty(oEvent, 'keyCode', {
get : function() {
@martinaglv
martinaglv / 01.js
Last active May 10, 2019 07:03
What do these functions do?
function whatDoesItDo(val){
return val ? 1 : 2;
}
func p_setupTextLayer(text: String) -> CAShapeLayer {
var letters = CGPathCreateMutable()
let font = CTFontCreateWithName("Helvetica-Bold", 72, nil)
let attrs = [kCTFontAttributeName: font]
var attrString = NSAttributedString(string: text, attributes: attrs)
let line = CTLineCreateWithAttributedString(attrString)
let runArray = CTLineGetGlyphRuns(line)
@patricksurry
patricksurry / README.md
Last active January 7, 2024 08:05
Imitate hand-drawn (imperfect) circles using cubic Bézier segments

Imitate hand-drawn (imperfect) circles using cubic Bézier segments, based on a Bézier approximation to a perfect circle. TLDR: a good approximation to a quarter circle of unit radius is a cubic Bézier curve with control points P0 = (0,1), P1 = (c,1), P2 = (1,c), P3 = (1,0) where c = 0.551915024494. By varying the points in a sensible way, we can do a good impression of hand-drawn circles.

@konklone
konklone / ssl.rules
Last active May 19, 2024 18:02
nginx TLS / SSL configuration options for konklone.com
# Basically the nginx configuration I use at konklone.com.
# I check it using https://www.ssllabs.com/ssltest/analyze.html?d=konklone.com
#
# To provide feedback, please tweet at @konklone or email eric@konklone.com.
# Comments on gists don't notify the author.
#
# Thanks to WubTheCaptain (https://wubthecaptain.eu) for his help and ciphersuites.
# Thanks to Ilya Grigorik (https://www.igvita.com) for constant inspiration.
server {