Skip to content

Instantly share code, notes, and snippets.

View sue71's full-sized avatar

Sue sue71

View GitHub Profile
#!/bin/sh
grunt jshint
if [ $? -ne 0 ]; then
echo \"can not commit for jshint fails\"
exit 1
fi
exit 0
class LinkedList {
constructor(...values) {
this.head = null;
this.tail = null;
this.size = 0;
if (values.length > 0) {
values.forEach(this.add.bind(this));
}
}
function asyncTask(count, gen) {
setTimeout(() => {
gen.next(count);
}, 1000);
}
const generator = (function* () {
let count = 0;
console.log(yield asyncTask(count++, generator));
console.log(yield asyncTask(count++, generator));
function asyncTask(count, next) {
setTimeout(() => {
next(count);
}, 1000);
}
const async = function(generator) {
let gen = generator(function (value) {
gen.next(value);
});
function asyncTask(count) {
return new Promise(resolve => {
setTimeout(() => {
resolve(count);
}, 1000);
});
}
const async = function(generator) {
@sue71
sue71 / LUDecomposition.js
Created October 4, 2017 10:52
LU decomposition logic written in Javascript
let matA = [
[1, 1, 0, 3],
[2, 1, -1, 1],
[3, -1, -1, 2],
[-1, 2, 3, -1]
];
let N = matA.length;
console.log("matA", matA);
const spdy = require('spdy');
const express = require('express');
const fs = require('fs');
const path = require('path');
const app = express();
const publicPath = path.join(__dirname, ".");
app.use(express.static(publicPath));
@sue71
sue71 / parser.ts
Last active February 2, 2018 03:08
simple LL-parser
declare const process: any;
const stdin = process.openStdin();
enum TokenType {
VarName = 'VarName',
Assign = 'Assign',
Plus = 'Plus',
Minus = 'Minus',
Multi = 'Multi',
Divi = 'Divi',
@sue71
sue71 / typed-vuex.d.ts
Created March 29, 2018 01:00
vuex type definition
import {
WatchOptions,
DispatchOptions,
CommitOptions,
MutationPayload,
} from 'vuex';
export interface ActionConvertible {
[key: string]: {
payload: string;
@sue71
sue71 / simple-cookie-browser.ts
Created September 18, 2018 07:35
simple cookie storage for browser