Skip to content

Instantly share code, notes, and snippets.

@joeylin
joeylin / api.js
Created April 14, 2014 13:51 — forked from fwielstra/api.js
node, mongoose, express example
/* 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');
@joeylin
joeylin / debug-on-a.txt
Last active August 29, 2015 13:57
浏览器跳转对js调试的影响
<a class="no-href" href="">test</a>;
$('.no-href').on('click', function(){
// do some stuff
// some error happens
return false;
});
bug: 没有在href上面加内容时,会造成发生错误时候自动跳转,错误被忽略,偶尔会出现断点也无法跟踪的现象。
解决方法: 在href上面加个#使之不跳转。
@joeylin
joeylin / focus-issue.txt
Last active August 29, 2015 13:57
focus事件绑定的坑和带后缀事件的绑定解绑
marker.$element.on('focus', function() {
$doc.on('keydown.' + marker._id, function(e) {
var key = e.keyCode || e.which;
if (key === 46) {
self.del(marker);
}
});
}).on('blur', function() {
$doc.off('keydown.' + marker._id);
});
@joeylin
joeylin / jquery插件规划.txt
Last active April 27, 2016 12:05
UI库插件规划
1, tooltip
简介: 弹出提示框功能
功能: hover 或 click 触发
ajax加载内容
与弹出框交互功能(interactive)
自定调整弹出框位置(autoPosition)
动画效果 'fade' 'zoom'
2, colorInput
简介: 功能强大的颜色选择器功能
@joeylin
joeylin / scraping-with-casperjs.js
Created February 21, 2014 02:39 — forked from imjared/scraping-with-casperjs.js
A CasperJS script that crawled a list of links on then scraped the relevant content on each page and output it to a nicely formatted XML file. Sure beats database dumps/SQL manipulation, in my opinion.
/*jshint strict:false*/
/*global CasperError console phantom require*/
/**
* grab links and push them into xml
*/
var casper = require("casper").create({
});
@joeylin
joeylin / notes
Created February 11, 2014 09:31
notes lists
for recording some notes
@joeylin
joeylin / angular-input-test.js
Created February 10, 2014 06:12
a test example of input directive in angular
'use strict';
describe('green.inputmask4angular', function () {
beforeEach(module('green.inputmask4angular'));
var $scope, $compile, elm,$timeout;
beforeEach(inject(function ($rootScope, _$compile_,_$timeout_) {
$scope = $rootScope;
@joeylin
joeylin / copy.js
Last active August 29, 2015 13:56
nodejs file copy
var fs = require('fs'),
url = require('url'),
when = require('when'),
errors = require('../errorHandling'),
path = require('path'),
paths = require('./paths'),
appRoot = paths().appRoot,
configExample = paths().configExample,
configFile = process.env.GHOST_CONFIG || paths().config,
@joeylin
joeylin / askPassword.js
Created February 8, 2014 07:44
nodejs input password in Terminal
function askPassword(callback) {
var stdin = process.openStdin(),
stdio = process.binding("stdio");
stdio.setRawMode();
console.log('Enter your password:');
var password = "";
stdin.on("data", function(c) {
c = c + "";
@joeylin
joeylin / HowToCode.js
Last active January 2, 2016 08:49
a complete jQuery Plugin patterns
// initialied plugin
$('.element').pluginName();
$('.element').pluginName({
skin:'your skin',
// config
.....
});
// callback method after initialied
$('.element').pluginName('disable'); // call disable method