Skip to content

Instantly share code, notes, and snippets.

View angelochen960's full-sized avatar

angelochen960

View GitHub Profile
@angelochen960
angelochen960 / use dirty db in a module
Created September 1, 2018 06:05
use dirty db in a module
first, create a mydb.js
```
var dirty = require('dirty');
let MyDB = class {
constructor(dbname) {
this.dbname = dbname
}
@angelochen960
angelochen960 / gist:8763400
Created February 2, 2014 05:15
avoid scrolling over top line (HELLO)
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- Le styles -->
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">
@angelochen960
angelochen960 / angularjs_1
Created February 1, 2014 08:17
json with "$content" property works in angularjs 1.0.7, but disappear in 1.2.10
<html ng-app="app">
<head>
<!--
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular-resource.min.js"></script>
-->
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.10/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.10/angular-resource.min.js"></script>
<script type="text/javascript">
@angelochen960
angelochen960 / gist:5915127
Created July 3, 2013 03:03
Interface for javascript
// https://docs.google.com/presentation/d/1dp0GOtvl2-pZoxkyzvGvq5zmPdMIDQIBzr2Vv_3JzQo/pub?start=false&loop=false&delayms=3000#slide=id.gd2fff574_099
// Clients is an interface
var Clients = {
get : function(id) {},
save : function(client) {},
list : function() {},
msg : function() {}
}
var kue = require('kue')
var redis = require('redis')
kue.redis.createClient = function () {
var client = redis.createClient();
client.select(2, function (status) {
console.log(status)
})
return client;
};
@angelochen960
angelochen960 / gist:4188293
Created December 2, 2012 11:29
AngularJS using [[]] as data binding symbols
<!doctype html>
<html ng-app="myApp">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.min.js"></script>
<script type="text/javascript">
var myApp = angular.module('myApp', [], function ($interpolateProvider) {
$interpolateProvider.startSymbol('[[');
$interpolateProvider.endSymbol(']]');
});
@angelochen960
angelochen960 / gist:2904717
Created June 10, 2012 09:52
CoffeeScript sample using expressjs 3 and Swig template
express = require 'express'
routes = require './routes'
http = require 'http'
cons = require 'consolidate'
app = express()
app.engine 'html', cons.swig
app.configure ( ->
@angelochen960
angelochen960 / gist:2762149
Created May 21, 2012 12:44
putting two boxes with span6 side by side
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>untitled</title>
<link href='http://twitter.github.com/bootstrap/assets/css/bootstrap.css'
rel='stylesheet' type='text/css'>
<style type="text/css">
.box2 {
@angelochen960
angelochen960 / app.coffee
Created April 12, 2012 13:37
express and coffeescript
express = require 'express'
routes = require './routes'
app = module.exports = express.createServer()
# Configuration
app.configure ->
app.set 'views', __dirname + '/views'
app.set 'view engine', 'jade'
@angelochen960
angelochen960 / app.coffee
Created April 12, 2012 12:45
index.coffee
express = require('express')
routes = require('./routes')
app = module.exports = express.createServer()
# Configuration
app.configure ->
app.set 'views', __dirname + '/views'
app.set 'view engine', 'jade'