Skip to content

Instantly share code, notes, and snippets.

@luqizheng
luqizheng / DHT11.cs
Created June 19, 2018 04:45 — forked from Injac/DHT11.cs
DHT11 Sensor driver for Windows 10 IoT Core - C#
//An exact copy of the adafruit DTH-11 driver in C#
//Example usage:
//var gpio = GpioController.GetDefault();
//var dataPin = gpio.OpenPin(5);
@luqizheng
luqizheng / latency.txt
Created June 6, 2016 10:02 — 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
@luqizheng
luqizheng / tab离开显示.js
Last active April 7, 2016 09:43
当焦点离开浏览器tab的时候,就产生一个事件
var hiddenProperty = 'hidden' in document ? 'hidden' :
'webkitHidden' in document ? 'webkitHidden' :
'mozHidden' in document ? 'mozHidden' :
null;
var visibilityChangeEvent = hiddenProperty.replace(/hidden/i, 'visibilitychange');
var onVisibilityChange = function(){
if (!document[hiddenProperty]) {
document.title = 'test';
@luqizheng
luqizheng / guid
Created December 31, 2015 00:40
create guid by js
//http://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript
function guid() {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
s4() + '-' + s4() + s4() + s4();
}
@luqizheng
luqizheng / autostart.bat
Last active December 10, 2015 08:28
程序一旦关闭,会在5秒内自动重启
@echo on
:loop
echo Start checking
rem :请把下面的 check.bat* 更换你想要的windowtitle,不支持模糊查询,只能在后面*来区别
for /F "tokens=2 delims=," %%a in ('tasklist /fo csv /v /fi "windowTitle eq loopCheck.bat*"') do (
echo Infinity is exist, wait 5 sechond and re-check.
ping -n 5 127.1>nul
@luqizheng
luqizheng / 0_reuse_code.js
Created December 6, 2015 07:04
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console