Skip to content

Instantly share code, notes, and snippets.

View dongyuwei's full-sized avatar
💭
天天听儿歌

dongyuwei dongyuwei

💭
天天听儿歌
View GitHub Profile
@dongyuwei
dongyuwei / convert-expression.js
Last active August 29, 2015 14:06
convert IE expression for lessc compiler
var fs = require('fs');
var content = fs.readFileSync('./fontello-ie7.css','utf-8');
if( content.indexOf('~"expression(') !== -1 ){
console.info("fontello-ie7.css have been converted.");
process.exit(0);
}
content = content.replace(/expression\((.*)\);/g, function(){
element.addClass('animated swing');
setTimeout(function(){
element.removeClass('animated swing');
},500);
//phantomjs pdf.js
var page = require('webpage').create();
page.paperSize = {
format: 'A4',
orientation: "landscape"
};
page.viewportSize = { width: 1200, height: 4347 };
gem install gimli -V
gimli -f foo.md -s https://github.github.com/github-flavored-markdown/shared/css/documentation.css
gem install mailcatcher --both --no-ri --no-rdoc -V
kill -9 $(lsof -i:1025 -t) 2> /dev/null
mailcatcher
export SMTP_SERVER="127.0.0.1"
export SMTP_PORT=1025
var BitMask = function(){
};
BitMask.prototype = {
// & ANDing
test : function(flags,mask){
return (flags & mask) == mask;
},
// | ORing
//f(n) = 1 + 3 + 5 + ... + (2n + 1) n >= 0
function loopCount(n){
var total = 0;
for(var i = 0; i <= n; i++){
total = total + (2 * i + 1)
}
return total;
}

ruby:

/\A[^@]+@[^@]+\z/

js:

/^[^@]+@[^@]+$/
@dongyuwei
dongyuwei / patch_sinatra_asset_pack.rb
Created November 28, 2014 02:46
patch sinatra AssetPack, make it support IE browser better: 1. fix the 30 css links limit of IE browser 2. avoid *.htc file cross domain request when use CDN.
module Sinatra
module AssetPack
class Package
def to_development_html(path_prefix, options={})
if js?
return paths_and_files.map { |path, file|
path = add_cache_buster(path, file)
path = add_path_prefix(path, path_prefix)
link_tag(path, options)
}.join("\n")
@dongyuwei
dongyuwei / transform-image.html
Last active August 29, 2015 14:10
hover transform for image
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>hover transform</title>
<style type="text/css">
.gallery{
width: 388px;
height: 200px;
overflow: hidden;