Skip to content

Instantly share code, notes, and snippets.

@watert
watert / composite-sparkline.js
Created July 25, 2013 09:49
带环比的sparkline视图。based on jquery.sparkline.min.js
$(".sparkline").each(function(idx){
var data = _.map(_.range(60*5),function(i){return 5*i+1000*0.5*Math.sin(i*0.1/Math.PI);});
var data2 = _.map(data,function(r){return r*(Math.random()+2);});
var allData = data.concat(data2);
var config = {chartRangeMin:_.min(allData),chartRangeMax:_.max(allData)};
console.log(config);
$(this).sparkline(data2,_.extend({width:"100%",height:80,lineColor:"hsla(30,100%,60%,0.6)",fillColor:"transparent"},config));
$(this).sparkline(data,_.extend({width:"100%",height:80,lineColor:"hsla(200,100%,60%,0.6)",fillColor:"hsla(200,100%,60%,0.2)",composite: true},config));
});
@watert
watert / readme.md
Last active December 20, 2015 07:39
font family 中文解决方案

Web font 服务方案: http://www.justfont.com/

Mac下的优化黑体: font-family: helvetica,"Hiragino Sans GB"; 来源:前端观察

AceEditor的等宽文字方案对Mac下也有较好表现 font-family:'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace; 来源:Gist 编辑器

@watert
watert / teyigongnengyayaya.txt
Created July 31, 2013 07:40
( ・ิω・ิ)我有一个特异功能
( ・ิω・ิ)我有一个特异功能,
( ・ิω・ิ) 我可以把我的眉毛摘下来,
( ・ิω・)ノิิ摘下,
( ・ิω・ิ)安上,
╰ิิ( ・ω・)ノิิ两边都摘下,
( ・ิω・ิ)安上。。。
( ・ω・)。。。安不回来了。
@watert
watert / mongoBetweenDate.coffee
Created August 19, 2013 03:19
between date for mongoose query using
mongoBetweenDate = (date1,date2=false)->
parseDateStr = (date)->
dateStr = date.replace(/-/g,"/")
d = new Date dateStr
d = false if d is "Invalid Date"
d
date1 = parseDateStr date1
where = {}
if date1
getJSON = (url,callback)->
require("http").get url,(res)->
res.on "data",(data)->
data = JSON.parse data.toString()
callback data
@watert
watert / _.random.js
Created August 29, 2013 02:10
advanced random methods for underscore
/*
_.random.str() : "Quick"
_.random.str(3) : "Jumps Jumps Fox"
_.random.list() : [43, 65, 52, 65, 49]
_.random.list(3) : [43, 65, 49]
*/
(function(){
var methods = {
num:function(num1,num2){
num1=num1||100;
// Example:
JavaScript.load("/javascripts/something.js");
// With callback (that’s the good thing):
JavaScript.load("http://www.someawesomedomain.com/api.js", function() {
API.use(); // or whatever api.js provides ...
});
@watert
watert / UITableView.swift
Last active July 21, 2017 15:10
UITableView example in iOS Playground with XCode 6 beta
// Playground - noun: a place where people can play
import UIKit
class ViewController: UIViewController ,UITableViewDelegate, UITableViewDataSource
{
var tableView: UITableView!
var items: NSMutableArray!
override func viewDidLoad() {
super.viewDidLoad()
@watert
watert / model.router.coffee
Created July 30, 2014 09:41
RestfulAPI router with expressjs and mongoose
# usage: app.use "/[collectionName]", require("./routes/[collectionName]")
express = require('express')
class ModelRestfulRouter
findOne:(req,res)->
@model.findById req.params.id,(err,data)->
unless err then res.json(data)
find:(req,res)->
query = req?.query or {}
@watert
watert / backbone.view.minimal.coffee
Last active August 29, 2015 14:06
Minimal Backbone View without backbone framework for minimal web app
class BaseView
constructor:(options)->
@options = options
@el = options.el
@$el = $(@el)
@initialize?(options)