Skip to content

Instantly share code, notes, and snippets.

@pockry
pockry / Linux cheatsheet.md
Last active August 29, 2015 14:11
Linux Command Line Cheat Sheet
@pockry
pockry / install.md
Last active March 10, 2018 14:15
Ubuntu14.10 64bit服务器下安装Node.js、MongoDB、Nginx
@pockry
pockry / fetch HN API.js
Created November 27, 2014 10:14
抓取Hacker News API示例 使用NodeStarter。
var superagent = require('superagent');
var async = require('async');
/**
* GET /
* Home page.
*/
exports.index = function(req, res) {
superagent.get('https://hacker-news.firebaseio.com/v0/topstories.json')
@pockry
pockry / blockquote style.css
Created November 26, 2014 06:50
blockquote引号样式
blockquote {
margin-left: 50px;
border: none;
font: 18px/1.8 "times new roman", "微软雅黑";
margin-top: -150px;
margin-bottom: -160px;
}
blockquote:before {
content: open-quote;
font-size: 100px;

##初始配置

  • git config --global user.name "pockry"
  • git config --global user.email [email protected]

##个人开发

  1. git托管服务上创建repo
  2. git clone
  3. 本地开发
@pockry
pockry / passport function.js
Created November 21, 2014 05:49
passport.js高阶函数实现
function Authenticator(){
this._serializers = [];
}
Authenticator.prototype.serializeUser = function(fn, req, done) {
if (typeof fn === 'function') {
return this._serializers.push(fn);
}
var user = fn;
if (typeof req === 'function') {
done = req;
@pockry
pockry / Angular App Structure.md
Last active August 29, 2015 14:10
Angular App目录结构最佳实践 - Best Practice Recommendations for Angular App Structure https://docs.google.com/document/d/1XXMvReO8-Awi1EZXAXS4PzDzdNvV6pGcuaF4Q9821Es/pub

##Proposal:

Change angular-seed, yeoman/generator-angular, (the Google-internal example go/nghellostyle), and other demo apps to model the following directory structure. Eventually, develop tooling to make development more efficient using assumptions based on these conventions. Motivation:

Our toy and demo apps currently group files functionally (all views together, all css together, etc...) rather than structurally (all elements of a view together, all common elements together, etc...)

When used in a real larger scale app (e.g. Doubleclick For Advertisers), readability is improved by making the directory and app structure consistent with the architectural design of the app. We also want to be able to develop tools to make app creation and management easier, and this is simplified with a common structure.

This proposal outlines a more functional structure based on a repeating hierarchy and some use-case examples.

@pockry
pockry / content.html
Last active August 29, 2015 14:09
创建博文目录
<div id="content">
<div id="content-nav">目录</div>
<div class="content-core">
<p>文章正文</p>
<h2>小标题</h2>
<p>dddd</p>
</div>
</div>
@pockry
pockry / passport-github example.js
Created November 13, 2014 08:25
passport-github 官方示例
var express = require('express')
, passport = require('passport')
, util = require('util')
, GitHubStrategy = require('passport-github').Strategy;
var GITHUB_CLIENT_ID = "--insert-github-client-id-here--"
var GITHUB_CLIENT_SECRET = "--insert-github-client-secret-here--";
// Passport session setup.
// To support persistent login sessions, Passport needs to be able to
// serialize users into and deserialize users out of the session. Typically,
// this will be as simple as storing the user ID when serializing, and finding
@pockry
pockry / Insert Array.js
Last active August 29, 2015 14:07
例程:对象数组的二维比较和插入
/**
* 例程:对象数组的二维比较和插入
* Author: pockry
* 说明:需要插入的数组已经是排序好的
*/
var arr = [
{y: 2014, m: 10},
{y: 2014, m: 7},
{y: 2014, m: 1},