Skip to content

Instantly share code, notes, and snippets.

View huanglong-zz's full-sized avatar
🎯
Focusing

Scott Dong huanglong-zz

🎯
Focusing
View GitHub Profile
@paolorossi
paolorossi / html5-video-streamer.js
Created March 7, 2012 13:21
Node.js HTML5 video streamer
/*
* Inspired by: http://stackoverflow.com/questions/4360060/video-streaming-with-html-5-via-node-js
*/
var http = require('http'),
fs = require('fs'),
util = require('util');
http.createServer(function (req, res) {
var path = 'video.mp4';
@bclinkinbeard
bclinkinbeard / referenced_mongo_json.md
Created March 15, 2013 16:56
Populating referenced collections in MongoDB from JSON files using Node.js and Mongoose

Populating referenced collections in MongoDB from JSON files using Node.js and Mongoose

I recently began working with Node and MongoDB for a small personal project, largely just to learn the technologies. One thing that is fairly simple but that I found far from obvious and lacking in concrete examples was how to populate the part of my database that used referenced collections from the sample JSON data I was starting with. This post attempts to fill that gap using the following code snippets, which are heavily commented inline. You will notice I am using the awesome Mongoose library which makes working with MongoDB very easy.

http.createServer( app ).listen( app.get( 'port' ), function() {

    mongoose.connect( 'mongodb://localhost/{YOUR_DB_NAME}' );

	var db = mongoose.connection;
@revolunet
revolunet / angular-google-analytics.js
Last active December 16, 2015 23:30
Sample angular-google-analytics usage
var app = angular.module('app', ['angular-google-analytics'])
.config(function(AnalyticsProvider) {
// initial configuration
AnalyticsProvider.setAccount('UA-XXXXX-xx');
// track all routes (or not)
AnalyticsProvider.trackPages(true);
}))
.controller('SampleController', function(Analytics) {
// create a new pageview event
@hanksudo
hanksudo / i18n-express-jade-app.js
Created July 14, 2013 12:34
express@3.2.5 + i18n-node@0.4.1 + jade@0.33.0
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, user = require('./routes/user')
, http = require('http')
, path = require('path')
@robmiller
robmiller / .gitconfig
Created July 17, 2013 07:52
Some useful Git aliases that I use every day
#
# Working with branches
#
# Get the current branch name (not so useful in itself, but used in
# other aliases)
branch-name = "!git rev-parse --abbrev-ref HEAD"
# Push the current branch to the remote "origin", and set it to track
# the upstream branch
publish = "!git push -u origin $(git branch-name)"
@maggiben
maggiben / minimustache.functional.js
Last active February 23, 2022 15:02
Mini Mustache
/*
Bare bones template engine
*/
const hydrate = function(template, scope) {
if (
template.constructor === String &&
template.length &&
scope.constructor === Object &&
Object.keys(scope).length
) {
@yisibl
yisibl / HTML-tags.md
Last active January 26, 2024 06:58
常用的 HTML 头部标签

常用的 HTML 头部标签

详细介绍参见原文:yisibl/blog#1

<!DOCTYPE html> <!-- 使用 HTML5 doctype,不区分大小写 -->
<html lang="zh-cmn-Hans"> <!-- 更加标准的 lang 属性写法 http://zhi.hu/XyIa -->
<head>
    <meta charset='utf-8'> <!-- 声明文档使用的字符编码 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <!-- 优先使用 IE 最新版本和 Chrome -->
@jy00295005
jy00295005 / my_google_map_heler.js
Last active April 15, 2016 01:37
create google map for my project
// need two files
// <script language="JAVASCRIPT" src="../js/infobox.js"></script>
// <script language="JAVASCRIPT" src="../js/markerwithlabel.js"></script>
var helper = {};
//map style array
var style_pale = [{"featureType":"water","stylers":[{"visibility":"on"},{"color":"#acbcc9"}]},{"featureType":"landscape","stylers":[{"color":"#f2e5d4"}]},{"featureType":"road.highway","elementType":"geometry","stylers":[{"color":"#c5c6c6"}]},{"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":"#e4d7c6"}]},{"featureType":"road.local","elementType":"geometry","stylers":[{"color":"#fbfaf7"}]},{"featureType":"poi.park","elementType":"geometry","stylers":[{"color":"#c5dac6"}]},{"featureType":"administrative","stylers":[{"visibility":"on"},{"lightness":33}]},{"featureType":"road"},{"featureType":"poi.park","elementType":"labels","stylers":[{"visibility":"on"},{"lightness":20}]},{},{"featureType":"road","stylers":[{"lightness":20}]}];
//helper中map会需要的函数放在此处
helper.map = {
@jikeytang
jikeytang / [ CSS ] - 20140612-题目1
Last active August 29, 2015 14:02
[ CSS ] - 20140612-题目1
用html,css实现以下三种情况的布局:
1. 2列布局:左固定,右自适应。
2. 3列布局:左右固定,中自适应。
3. 2行上下布局,下是左右布局:
a. 头部高固定且位置固定,
b. 下左宽度固定,下右宽度自适应且实现iframe高度自适应,
c. 全屏无横向滚动条,下左,下右内容超出高度时出现纵向滚动条 (可以不考虑ie6,用纯css实现)。
PS:
1. 回复时注意加上下面这句话,才会有语法高亮或格式缩进。
@sofish
sofish / urlparser.js
Last active March 18, 2021 11:31
URL Parser
var parser = function(url) {
var a = document.createElement('a');
a.href = url;
var search = function(search) {
if(!search) return {};
var ret = {};
search = search.slice(1).split('&');
for(var i = 0, arr; i < search.length; i++) {