Skip to content

Instantly share code, notes, and snippets.

// Usage: $(element).scrollToTop([position])
;(function($){
// only allow one scroll to top operation to be in progress at a time,
// which is probably what you want
var scrollToTopInProgress = false
$.fn.scrollToTop = function(position){
var $this = this,
targetY = position || 0,

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@minwe
minwe / highlight-github.css
Created March 1, 2014 03:58
Github 代码高亮方案
.highlight{background:#ffffff;}
.highlight .c{color:#999988;}
.highlight .err{color:#a61717;background-color:#e3d2d2;}
.highlight .k{font-weight:bold;}
.highlight .o{font-weight:bold;}
.highlight .cm{color:#999988;}
.highlight .cp{color:#999999;font-weight:bold;}
.highlight .c1{color:#999988;}
.highlight .cs{color:#999999;font-weight:bold;}
.highlight .gd{color:#000000;background-color:#ffdddd;}
@minwe
minwe / parseURL.js
Created March 3, 2014 03:24
JavaScript解析浏览器路径
function parseURL(url) {
var a = document.createElement('a');
//创建一个链接
a.href = url;
return {
source: url,
protocol: a.protocol.replace(':',''),
host: a.hostname,
port: a.port,
query: a.search,
@minwe
minwe / hbs.ifCond.js
Created March 10, 2014 08:07
Handlebaes ifCond
Handlebars.registerHelper("ifCond",function(v1,operator,v2,options) {
switch (operator)
{
case "==":
return (v1==v2)?options.fn(this):options.inverse(this);
case "!=":
return (v1!=v2)?options.fn(this):options.inverse(this);
case "===":
// gulpやプラグインをインポート
var gulp = require('gulp')
, compass = require('gulp-compass')
, concat = require('gulp-concat')
, uglify = require('gulp-uglify')
, minifyCSS = require('gulp-minify-css')
, path = require('path')
;
//JSファイルをjsフォルダにコピー
@minwe
minwe / Handlebars.script.helper.js
Last active August 29, 2015 13:58
Handlebars script helper
Handlebars.registerHelper('script', function (src){
var s = '<script src="' + src + '" type="text/javascript"><' + '/script>';
return new Handlebars.SafeString(s);
});
// usage: {{{script "https://gist.github.com/4332573.js"}}}
@minwe
minwe / disqus.lazyload.js
Created April 12, 2014 07:10
懒加载disqus
(function () {
var disqus_shortname = 'evanyoublog',
el = document.getElementById('disqus_thread')
window.addEventListener('scroll', checkPosition)
window.addEventListener('load', checkPosition)
function checkPosition () {
var rect = el.getBoundingClientRect()
if (rect.top < window.innerHeight) {
// Usage: $(element).scrollToTop([position])
;(function($){
// only allow one scroll to top operation to be in progress at a time,
// which is probably what you want
var scrollToTopInProgress = false
$.fn.scrollToTop = function(position){
var $this = this,
targetY = position || 0,
@minwe
minwe / rAF.js
Created April 16, 2014 01:56 — forked from paulirish/rAF.js
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];