Skip to content

Instantly share code, notes, and snippets.

View lsongdev's full-sized avatar
👨‍💻

Lsong lsongdev

👨‍💻
View GitHub Profile
/*
* created by Rui Santos, http://randomnerdtutorials.com
*
* Complete Guide for Ultrasonic Sensor HC-SR04
*
Ultrasonic sensor Pins:
VCC: +5VDC
Trig : Trigger (INPUT) - Pin11
Echo: Echo (OUTPUT) - Pin 12
GND: GND
function (
a, // A Nodelist whichto use as root
b, // iterate-placeholder
c, // elem-placeholder
d, // tags-placeholder
e, // tag-placeholder
f // parent-placeholder
) {
for (b = 0; c = a[b++];
/**
* [BreakBlock description]
*/
function BreakBlock(row, col){
this.data = [];
this.position = [ 0, 0 ];
this.direction = BreakBlock.DIRECTION.NE;
};
BreakBlock.AXIS = {
@lsongdev
lsongdev / app.js
Last active August 28, 2018 05:46
微信小程序 wx.request 封装
App({
/**
* [request description]
* @param {[type]} method [description]
* @param {[type]} url [description]
* @param {[type]} data [description]
* @param {[type]} header [description]
* @return {[type]} [description]
*/
for(var n=8888,c=0; n; c+=(n=n>>1)&1){ c; };
<style>
body{
margin: 100px;
text-align: center;
}
[tooltip]{
position: relative;
}
//
// function fn(n){
// if(n > 100) return n;
// return fn(n + (n + 1));
// };
function pad(s, n){
while(n--) s = '0' + s;
return s;
};
for(var y=0;y<=10;y++){
var arr = [];
for(var x=0;x<5;x++) arr.push( Math.max(0, Math.round((y / 2) - x)) );
console.log('%j\t> ', y, arr);
}
<html>
<head>
<meta charset="utf8" />
<meta name="viewport" content="width=device-width">
<title>MaoYan Toolbox</title>
<style>
body{
width: 50%;
margin: auto;
text-align: center;
#!/bin/bash
#
# example:
#
# curl -s https://gist.githubusercontent.com/song940/332b80f24e7f203987eff11fc6765bd8/raw/progressbar.sh | sh
#
function ProgressBar(){
let max=$1