Skip to content

Instantly share code, notes, and snippets.

View zhanglun's full-sized avatar
🎯
Focusing

zhanglun zhanglun

🎯
Focusing
View GitHub Profile
@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 / 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();
@zhanglun
zhanglun / gulpfile.js
Last active August 29, 2015 14:27 — forked from vincent-zurczak/gulpfile.js
Copy minified Bower dependencies with Gulp (better solution)
// Include our plug-ins
var gulp = require('gulp');
var mainBowerFiles = require('main-bower-files');
var exists = require('path-exists').sync;
// Create some task
gulp.task( 'copy-bower-dep', function() {
// Replace files by their minified version when possible
var bowerWithMin = mainBowerFiles().map( function(path, index, arr) {
@zhanglun
zhanglun / clone.js
Last active August 29, 2015 14:08 — forked from hacke2/clone.js
//浅克隆
/*Object.prototype.clone = function (){
var obj = {};
for(var key in this) {
if(this.hasOwnProperty(key)) {
obj[key] = this[key];
}
}