Skip to content

Instantly share code, notes, and snippets.

@joeylin
joeylin / notes
Created February 11, 2014 09:31
notes lists
for recording some notes
@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 / jquery插件规划.txt
Last active April 27, 2016 12:05
UI库插件规划
1, tooltip
简介: 弹出提示框功能
功能: hover 或 click 触发
ajax加载内容
与弹出框交互功能(interactive)
自定调整弹出框位置(autoPosition)
动画效果 'fade' 'zoom'
2, colorInput
简介: 功能强大的颜色选择器功能
@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 / 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 / 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 / random.js
Last active August 29, 2015 14:04
mongoose random search code
module.exports = function (options) {
var randFn = (options && options.fn) || Math.random;
function random(schema, options) {
var path = (options && options.path) || 'random';
var field = {};
field[path] = {
type: { type: String, default: 'Point' },
coordinates: { type: [Number], default: function () { return [randFn(), randFn()] } }
};
@joeylin
joeylin / mail.js
Created August 6, 2014 16:08
nodemail config
var nodemailer = require('nodemailer');
var config = require('../config/config.js');
// Create a SMTP transport object
var transport = nodemailer.createTransport("SMTP", {
service: config.email.service,
auth: {
user: config.email.user,
pass: config.email.pass
}
@joeylin
joeylin / transitionend_name.js
Last active August 29, 2015 14:05
正确取得transitionend事件的可用名字
function getTransitionEndEventName() {
var obj = {
TransitionEvent: "transitionend",
WebKitTransitionEvent: "webkittransitionEnd",
OTransitionEvent: "OTransitionEnd",
otransitionEvent: "otransitionEnd",
MSTransitionEvent: "MSTransitionEnd"
}
// var ev = document.createEvent("TransitionEvent"); // FIXME: un-specified
// ev.initTransitionEvent("transitionend", true, true, "some-unknown-prop", -4.75);
@joeylin
joeylin / broswer.js
Created August 25, 2014 23:57
浏览器检测代码
Client = (function() {
var d = {engine: {ie: 0,gecko: 0,webkit: 0,opera: 0,khtml: 0},browser: {ie: 0,firefox: 0,chrome: 0,opera: 0,safari: 0,konq: 0}};
var b = navigator.userAgent;
var c = d.engine;
var a = d.browser;
if (window.opera) {
a.version = c.version = window.opera.version();
a.opera = c.opera = parseFloat(c.version)
} else {
if (/AppleWebKit\/(\S+)/.test(b)) {