Skip to content

Instantly share code, notes, and snippets.

@chrishan17
chrishan17 / .eslintrc.json
Created June 9, 2018 08:45
eslint config
{
"extends": ["airbnb"],
"parser": "babel-eslint",
"rules": {
"semi": [2, "never"],
"no-unused-vars": [
1,
{
"argsIgnorePattern": "res|next|^err"
}
@chrishan17
chrishan17 / .editorconfig
Created June 9, 2018 08:43
editorconfig
root = true
indent_size = 2
indent_style = space
tab_width = 2
end_of_line = lf
insert_final_newline = true
@chrishan17
chrishan17 / gulp_package.json
Created April 10, 2015 09:52
package.json for gulpfile.coffee
{
"name": "workflow",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
@chrishan17
chrishan17 / gulfile.coffee
Created April 10, 2015 09:50
a gulp workflow in coffeescript
gulp = require 'gulp'
gutil = require 'gulp-util'
del = require 'del'
sass = require 'gulp-sass'
coffee = require 'gulp-coffee'
uglify = require 'gulp-uglify'
browserSync = require 'browser-sync'
autoprefixer = require 'gulp-autoprefixer'
browserify = require 'browserify'
@chrishan17
chrishan17 / isArray.js
Created April 9, 2015 02:37
JavaScript If a variable is an array
var is_array = function (value) {
return value &&
typeof value === 'object' &&
typeof value.length === 'number' &&
typeof value.splice === 'function' &&
!(value.propertyIsEnumerable('length'));
};
@chrishan17
chrishan17 / firebase_presence.js
Last active August 29, 2015 14:17
firebase_presence
// since I can connect from multiple devices or browser tabs, we store each connection instance separately
// any time that connectionsRef's value is null (i.e. has no children) I am offline
var myConnectionsRef = new Firebase('https://<your-firebase>.firebaseio.com/users/joe/connections');
// stores the timestamp of my last disconnect (the last time I was seen online)
var lastOnlineRef = new Firebase('https://<your-firebase>.firebaseio.com/users/joe/lastOnline');
var connectedRef = new Firebase('https://<your-firebase>.firebaseio.com/.info/connected');
connectedRef.on('value', function(snap) {
if (snap.val() === true) {
@chrishan17
chrishan17 / moment-zh-cn.js
Created March 4, 2015 05:02
moment.js chinese configuration
// moment.js locale configuration
// locale : chinese (zh-cn)
// author : suupic : https://github.com/suupic
// author : Zeno Zeng : https://github.com/zenozeng
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['moment'], factory); // AMD
} else if (typeof exports === 'object') {
module.exports = factory(require('../moment')); // Node
@chrishan17
chrishan17 / mithril-init.js
Created March 4, 2015 04:55
mithril-file-separation
//app.model.js
var app = {};
app.PageList = function() {
return m.request({method: "GET", url: "pages.json"});
};
app.vm = {};
app.vm.init = function() {
this.pages = new app.PageList();
@chrishan17
chrishan17 / block_hover_when_scroll
Created September 13, 2014 06:19
Block hover when scroll to improve user experience
// Used to track the enabling of hover effects
var enableTimer = 0;
/*
* Listen for a scroll and use that to remove
* the possibility of hover effects
*/
window.addEventListener('scroll', function() {
clearTimeout(enableTimer);
removeHoverClass();