Skip to content

Instantly share code, notes, and snippets.

View WooodHead's full-sized avatar

WooodHead

  • Hangzhou
View GitHub Profile
@WooodHead
WooodHead / api.js
Created July 12, 2016 07:26 — forked from fwielstra/api.js
An example NodeJS / Mongoose / Express application based on their respective tutorials
/* The API controller
Exports 3 methods:
* post - Creates a new thread
* list - Returns a list of threads
* show - Displays a thread and its posts
*/
var Thread = require('../models/thread.js');
var Post = require('../models/post.js');
var application_root = __dirname,
express = require("express"),
path = require("path"),
mongoose = require('mongoose');
var app = express.createServer();
// database
mongoose.connect('mongodb://localhost/ecomm_database');
@WooodHead
WooodHead / gist:497ef6a99ef4a038d68653916044b8b2
Created August 20, 2016 05:34 — forked from asabaylus/gist:3071099
Github Markdown Heading Anchors

Anchors in Markdown

To create an anchor to a heading in github flavored markdown. Add - characters between each word in the heading and wrap the value in parens (#some-markdown-heading) so your link should look like so:

[create an anchor](#anchors-in-markdown)

@WooodHead
WooodHead / chrome.md
Created August 31, 2016 12:57 — forked from 0xjjpa/chrome.md
Understanding Google Chrome Extensions

#Introduction

Developing Chrome Extensions is REALLY fun if you are a Front End engineer. If you, however, struggle with visualizing the architecture of an application, then developing a Chrome Extension is going to bite your butt multiple times due the amount of excessive components the extension works with. Here are some pointers in how to start, what problems I encounter and how to avoid them.

Note: I'm not covering chrome package apps, which although similar, work in a different way. I also won't cover the page options api neither the new brand event pages. What I explain covers most basic chrome applications and should be enough to get you started.

Table of Contents

  1. Understand the Chrome Architecture
  2. Understand the Tabs-Extension Relationship
  3. Picking the right interface for the job
@WooodHead
WooodHead / createOutline.js
Created September 16, 2016 02:07 — forked from nmiddleweek/createOutline.js
This one popped up in the Chrome debugger, saving and referring to these is a good way to learn how vendors implement their JS code and we can learn from any patterns used.
/**
* This code contains an implementation of HTML5 outlining algorithm, as described by WHATWG at [1]
*
* The copyright notice at [2] says:
* (c) Copyright 2004-2009 Apple Computer, Inc., Mozilla Foundation, and Opera Software ASA.
* You are granted a license to use, reproduce and create derivative works of this document.
*
* [1] http://www.whatwg.org/specs/web-apps/current-work/multipage/sections.html#outlines
* [2] http://www.whatwg.org/specs/web-apps/current-work/multipage/index.html
*/
@WooodHead
WooodHead / gettopprojects.py
Created December 24, 2016 11:46 — forked from mallamanis/gettopprojects.py
Get top projects from GHTorrent
#!/usr/bin/python
import csv, sys, os
import numpy as np
# Get the top X non-fork projects for the GHTorrent dump (without using SQL)
# The dumps should be available at http://ghtorrent.org/downloads.html
if len(sys.argv) < 5:
print "Usage <dir> <language> <topX> <outcsv>"
sys.exit(-1)
@WooodHead
WooodHead / JavaScript.md
Created February 18, 2017 14:34 — forked from aaronshaf/JavaScript.md
All Things JavaScript
@WooodHead
WooodHead / generate-hn-uri.sh
Created March 16, 2017 03:38 — forked from aaronhoffman/generate-hn-uri.sh
hacker news firebase download
#!/bin/bash
# generate file containing all URIs to execute to retrieve data from hacker news firebase API
# api docs: https://github.com/HackerNews/API
echo generating file hn-uri.txt
URICOUNT=10000000
echo file will contain $URICOUNT lines
@WooodHead
WooodHead / download_egghead_videos.md
Created March 25, 2017 13:12 — forked from ldong/download_egghead_videos.md
download egghead videos

Download videos from egghead

Go to the egghead website, i.e. Building a React.js App

run

$.each($('h4 a'), function(index, video){
  console.log(video.href);
});
@WooodHead
WooodHead / introrx.md
Created April 15, 2017 04:05 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing