Skip to content

Instantly share code, notes, and snippets.

View zhanglun's full-sized avatar
🎯
Focusing

zhanglun zhanglun

🎯
Focusing
View GitHub Profile
@zhanglun
zhanglun / lettura-update-info.json
Last active August 2, 2023 05:25
lettura-update-info.json
{
"version": "0.1.7",
"notes": "",
"pub_date": "2023-08-02T03:11:25.878Z",
"platforms": {
"darwin-x86_64": {
"signature": "dW50cnVzdGVkIGNvbW1lbnQ6IHNpZ25hdHVyZSBmcm9tIHRhdXJpIHNlY3JldCBrZXkKUlVSMThyUloxUEVjcUF5OE9scUFIdnZTUFRZd1phK2JROXpwQloxU01iamZQdzNPcUFkRDZUbHgyenAzeEwrSmdybGVmcG03RGxSOERPMXJyUStMNkp1NjBzS2MvTFNDSGdjPQp0cnVzdGVkIGNvbW1lbnQ6IHRpbWVzdGFtcDoxNjkwOTQ1NzEwCWZpbGU6TGV0dHVyYS5hcHAudGFyLmd6CmpXYTdMa09lWGhwZFZjcHRJZWg2Q3BQOWlSTzhibTJHOUt5NlRzRzB2WUlrSHBML0tpNEJOaUFGdWdRaEwvM0dra0h3TndXUnovdFZ3ZlZHbDZpdkNBPT0K",
"url": "https://github.com/zhanglun/lettura/releases/latest/download/Lettura_x64.app.tar.gz"
},
"darwin-aarch64": {
@zhanglun
zhanglun / debounce&throttle.js
Last active September 20, 2020 06:57
debounce&throttle
function debounce (fn, wait, imediate) {
let timer = null;
return function (...args) {
clearTimeout(timer);
if (imediate && !timer) {
fn.apply(this.args);
}
@zhanglun
zhanglun / wrapPromiseWithAbort.js
Created July 19, 2020 01:47
wrapPromiseWithAbort.js
let wrapPromiseWithAbort = function (promise) {
let _abort = null
let pAbort = new Promise ((resolve, reject) => {
_abort = function (reason = 'abort!') {
console.warn(reason)
rej(reason)
}
})
let race = Promise.rece([promise, pAbort])
@zhanglun
zhanglun / git-key.md
Last active March 11, 2016 02:07 — forked from yisibl/git-key.md
如何创建 Git 公钥

如何创建公钥

  1. 首先启动一个Git Bash窗口(非Windows用户直接打开终端)

  2. 执行:

    cd ~/.ssh

    如果返回“… No such file or directory”,说明没有生成过SSH Key,直接进入第4步。否则进入第3步备份!

@zhanglun
zhanglun / restAPI.markdown
Created February 10, 2016 10:52 — forked from iksose/restAPI.markdown
Creating a REST API using Node.js, Express, and MongoDB

###Creating a REST API using Node.js, Express, and MongoDB

####Installing Node.js

Go to http://nodejs.org, and click the Install button. Run the installer that you just downloaded. When the installer completes, a message indicates that Node was installed at /usr/local/bin/node and npm was installed at /usr/local/bin/npm. At this point node.js is ready to use. Let’s implement the webserver application from the nodejs.org home page. We will use it as a starting point for our project: a RESTful API to access data (retrieve, create, update, delete) in a wine cellar database.

Create a folder named nodecellar anywhere on your file system. In the wincellar folder, create a file named server.js.

@zhanglun
zhanglun / index.js
Created February 10, 2016 09:07 — forked from jfensign/index.js
NodeJS User Registration and Authentication
//index.js
var express = require('express'),
app = module.exports = express.createServer(),
mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/nodeAuth');
//configure app
app.configure(function() {
app.set('views', __dirname + '/views');
@zhanglun
zhanglun / jquery.ba-tinypubsub.js
Created November 9, 2015 03:00 — forked from creamidea/jquery.ba-tinypubsub.js
这是一个用js实现的订阅/发布系统,写的很简洁,但是非常的完美。
/* jQuery Tiny Pub/Sub - v0.7 - 10/27/2011
* http://benalman.com/
* Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT, GPL */
(function($) {
var o = $({});
$.subscribe = function() {
o.on.apply(o, arguments);
@zhanglun
zhanglun / route.js
Created September 16, 2015 08:06
route.js v0.1.1
(function() {
//一个储存路径的哈希表
var routes = {};
//路径注册函数
function route(path, templateurl, controller) {
routes[path] = {
templateurl: templateurl,
controller: controller
};
@zhanglun
zhanglun / How to use Backbone.js.md
Last active September 4, 2015 13:39 — forked from nightire/How to use Backbone.js.md
How to use Backbone.js

Simple Starting Point

创建 Model

var Person = Backbone.Model.extend();

UUID(版本4)的形式为:

xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx

其中,x 是任意十六进制字符,y 是 8,9,a,b,A,B 其中之一。它的正则表 达式可以写作:

/[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}/