Skip to content

Instantly share code, notes, and snippets.

View chiwent's full-sized avatar
:octocat:
Focusing

chiwent

:octocat:
Focusing
View GitHub Profile
@chiwent
chiwent / mini-express.js
Created October 18, 2018 15:03 — forked from Saul-Mirone/mini-express.js
Just An Express Style Framework
const http = require('http')
const url = require('url')
const path = require('path')
const fs = require('fs')
const mime = {
"html": "text/html",
"css": "text/css",
"js": "text/javascript",
"json": "application/json",
"gif": "image/gif",
@chiwent
chiwent / ajax.js
Last active October 18, 2018 13:24 — forked from yangfch3/ajax.js
ajax 请求封装
var Ajax = (function() {
var methodsList = ['get', 'post', 'head', 'options', 'put', 'connect', 'trace', 'delete'];
/**
* Ajax
* @param {String} url
* @param {Function} callback
* @param {Object/String} data
* @param {Object} options
*
@chiwent
chiwent / qiniu-upload.js
Created September 14, 2018 06:11
上传文件到七牛
// 将文件上传到七牛
// from: https://www.ntweet.net/article/59c21ef05d46937dd8491992
//qiniuConfig.js
exports.conf = {
accessKey: 'xxx',
secretKey: 'xxx',
bucket: 'xxx' // 要上传的空间
}
@chiwent
chiwent / wechat-hugin-agent.json
Created August 31, 2018 08:09
wechat-rss-agent
{
"schema_version": 1,
"name": "微信公众号",
"description": "No description provided",
"source_url": false,
"guid": "c0be876a712baf52fa4270d6b1744432",
"tag_fg_color": "#ffffff",
"tag_bg_color": "#00b050",
"icon": "leaf",
"exported_at": "2018-08-31T08:09:17Z",
@chiwent
chiwent / learn_Promise.md
Created August 7, 2018 15:49
learn_JavaScript

学习Promise

Promise是异步编程的一种解决方法,相比起传统的回调函数以及事件,有了更好的可读性

Promise有3种状态,分别是pendingresolved(准确来说应该叫fulfilled)、rejected,状态的转换不可逆转,也就是说,一旦状态从pending转变为其他两个状态中的任意一个,那么状态就是固定不变的。

有了promise对象,我们可以通过then的操作链来传入回调,在一个操作链中,前面的then回调执行完毕之后会将执行结果传递到下一个then,我们就可以将异步编程以同步编程的编程习惯表达(generator和async在这方面可以更彻底)。

promise一旦创建后立即执行,无法中途取消,并且内部抛出的错误无法传递到外部,因此无法在外部捕获

考前

移位寄存器

p137

library ieee;
use ieee.std_logic_1164.all;
entity shft is
    port( clk, load : in std_logic;
@chiwent
chiwent / polyfill.md
Last active May 19, 2018 12:08
polyfill

自己搜集的一些polyfill

原生JavaScript实现$(document).ready

function ready(fn){
    if(document.addEventListener) {
        document.addEventListener('DOMContentLoaded', function(){
            document.removeEventListener('DOMContentLoaded',arguments.callee,false);
            fn();