Skip to content

Instantly share code, notes, and snippets.

randomID = function(a,b) {
b=b||16;
return Array(a||32).join(0).replace(/0/g,function(){return(0|Math.random()*b).toString(b)});
}
#!/usr/bin/env node
/**
npm install cheerio request step
chmod +x urlparser.js
./urlparser.js
*/
var cheerio = require('cheerio')
, request = require('request')
var request = require('request');
var cheerio = require('cheerio');
var fs = require('fs');
var step =require('step');
step(
function readUrl(){
console.log("readUrl")
var html = (function () {/*
<!DOCTYPE html>
<html>
<body>
<h1>Hello, world!</h1>
</body>
</html>
*/}).toString().match(/[^]*\/\*([^]*)\*\/\}$/)[1];
var log = function(){
if(location.href.indexOf("debug_messi=1") > -1 ){
var arg = $.makeArray(arguments);
arg.unshift("["+MODULE_NAME+"]");
console.log.apply(console, arg);
}
};
var CssFilterSupport = {
checkSupport : function(testCase){
return window.CSS && _.isFunction(CSS.supports) && (CSS.supports("-webkit-filter", testCase) || CSS.supports("filter", testCase));
},
blur : function(){
return this.checkSupport("blur(10px)");
},
// http://jsperf.com/new-vs-object-create-including-polyfill
if (typeof Object.create !== 'function') {
Object.create = function(o, props) {
function F() {}
F.prototype = o;
if (typeof(props) === "object") {
for (prop in props) {
if (props.hasOwnProperty((prop))) {
F[prop] = props[prop];
content.replace('/(<([^>]+)>)/ig,', '').
@niceaji
niceaji / directive.js
Created September 13, 2014 15:19
directive example
var myModule = angular.module(...);
myModule.directive('directiveName', function (injectables) {
return {
restrict: 'A',
template: '<div></div>',
templateUrl: 'directive.html',
replace: false,
priority: 0,
transclude: false,
function toast (msg) {
$('.toast').remove();
$("<div class='toast'><h3>" + msg + "</h3></div>")
.css({
display: "block",
opacity: 0.8,
position: "fixed",
padding: "7px",
"text-align": "center",
width: "270px",