Skip to content

Instantly share code, notes, and snippets.

View song940's full-sized avatar
👨‍💻
Typing ...

Lsong song940

👨‍💻
Typing ...
View GitHub Profile
WeChat Alipay
@song940
song940 / github.png
Last active May 13, 2019 11:13
👨‍💻with ❤made by :octocat:
github.png
var expr = `(a.name == 'lsong' ? b : { c:2 }) + 30`;
const data = {
a: {
name: 'lsong'
},
b: 1,
};
const getValue = (expr, data) => {
const beijing = {
social_fund: {
min: 2820,
max: 14096,
// rate: .105
rate: {
medical: .02,
endowment: .08,
unemployment: .005
const quicksort = arr => {
if(arr.length <= 1) return arr;
const pivotIndex = arr.length / 2;
const pivot = arr.splice(pivotIndex, 1)[0];
const left = [];
const right = [];
for(var i = 0; i < arr.length; i++){
if(arr[i] < pivot){
left.push(arr[i]);
'use strict';
const PENDING = Symbol();
const FULFILLED = Symbol();
const REJECTED = Symbol();
function Promise(fn) {
if (typeof fn != 'function') {
throw new Error('resolver should be a function!');
}
const tasks = [
1,1,1,1,,1,1,1,1
,1,1,1,2,2,2,2,3,
3,,3,43,4343,43,
,43,4,3,4,34,3,4,3
]
.filter(Boolean)
.map(t => cb => {
setTimeout(cb, 1000, 1,2);
import React from 'react';
class LineChart extends React.Component {
render() {
const lines = [];
const { data } = this.props;
data.reduce((y, y2, x) => {
lines.push({ x, y, y2 });
return y2;
}, 0);
@song940
song940 / test.js
Last active August 31, 2018 04:21
/**
* super tiny testing framework
*
* @author Liu song <hi@lsong.org>
* @github https://github.com/song940
*/
function color(str, c){
return "\x1b[" + c + "m" + str + "\x1b[0m";
};
@song940
song940 / LiveTV.xspf
Last active August 26, 2018 06:35
VLC Live TV Play List
<?xml version="1.0" encoding="UTF-8"?>
<playlist xmlns="http://xspf.org/ns/0/" xmlns:vlc="http://www.videolan.org/vlc/playlist/ns/0/" version="1">
<title>Playlist</title>
<trackList>
<track>
<location>http://ivi.bupt.edu.cn/hls/cctv1hd.m3u8</location>
<title>CCTV1 HD</title>
<extension application="http://www.videolan.org/vlc/playlist/0">
<vlc:id>0</vlc:id>
<vlc:option>network-caching=1000</vlc:option>