Skip to content

Instantly share code, notes, and snippets.

@tj
tj / stuff.js
Created August 5, 2011 21:42
lame js String#prototype helpers
function User(name) {
this.name = name;
}
User.prototype.toString = function(){
return '<User ' + this.name + '>';
};
User.prototype.may = function(perm){
@millermedeiros
millermedeiros / gist:1873712
Created February 21, 2012 04:38
how to filter and batch delete files on node.js
var DIST_FOLDER = '../deploy/';
// ---
var _minimatch = require('minimatch'),
_wrench = require('wrench'),
_fs = require('fs'),
_path = require('path');
function purgeDeploy(){
@lepture
lepture / nginx.rb
Created July 2, 2012 12:52
nginx with http-concat module
require 'formula'
class Nginx < Formula
homepage 'http://nginx.org/'
url 'http://nginx.org/download/nginx-1.2.1.tar.gz'
sha1 '4fb69411f6c3ebb5818005955a085e891e77b2d8'
devel do
url 'http://nginx.org/download/nginx-1.3.2.tar.gz'
sha1 'a3507cb2f13332489804f79885541c717f8f4bf0'
@jonathantneal
jonathantneal / parseURI.js
Created August 2, 2012 23:22
parseURI // returns parsed URI as individual components
function parseURI(uri) {
function regexMaybe(string) {
return "(?:" + string + ")?";
}
uri = String(uri || window.location.href);
var
match = uri.match(new RegExp("^" + regexMaybe("([^:]+):") + "(\\/\\/)?" + regexMaybe("([^@]+)@") + "([^:/]+)/*" + regexMaybe(":(\\d+)\\/*") + regexMaybe("([^?#]+)\\/") + regexMaybe("([^?#]+)") + regexMaybe("\\?([^#]+)") + regexMaybe("#(\\w+)"))),
@LiuJi-Jim
LiuJi-Jim / extract archive file
Created November 27, 2012 05:46
extract archive file
ex () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) rar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
var APP = APP || {};
APP.EventBus = {};
APP.EventBus.bind = function (ev, callback, context) {
var calls = this._callbacks || (this._callbacks = {});
var list = calls[ev] || (calls[ev] = []);
list.push([callback, context]);
return this;
};
@wintercn
wintercn / gist:5918272
Created July 3, 2013 14:18
CSS3 标准和属性对应数据
[
{
"spec name": "CSS Animations",
"uri": "http://www.w3.org/TR/css3-animations",
"category": "css-property",
"Name": "animation-name",
"Value": "<single-animation-name> [\n ‘,’ <single-animation-name> ]*",
"Initial": "‘none’",
"Applies To": "all elements, ::before and ::after pseudo-elements",
"Inherited": "no",
var $ = document.querySelectorAll.bind(document);
Element.prototype.on = Element.prototype.addEventListener;
$('#somelink')[0].on('touchstart', handleTouch);
@millermedeiros
millermedeiros / example.html
Created August 28, 2012 13:52
node.js script to inline static includes
<!DOCTYPE html>
<!-- #include "inc_header.html" title="Example" header="Sample Title" -->
<html>
<head>
<meta charset="utf-8">
<title>Example</title>
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<h1>Sample Title</h1>
@mkristian
mkristian / pom-compass.xml
Last active August 2, 2016 14:28
using gem-maven-plugin to compass compile or execute sass. sass with gem dependency within plugin and compass with global compile dependency (which is also added to the java-classpath and not so nice)
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>example</artifactId>
<version>0.0.36</version>