This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function normalizeDate (raw) { | |
const patterns = [ | |
// 2017-01-30 | |
{re: /^\d{4}-\d{2}-\d{2}($|,)/, f: m => m[0]}, | |
// 2017-01 | |
{re: /^\d{4}-\d{2}($|,)/, f: m => m[0]}, | |
// 2017 | |
{re: /^\d{4}($|,)/, f: m => m[0]}, | |
// 20170130 | |
{re: /^(\d{4})(\d{2})(\d{2})($|,)/, f: m => `${m[1]}-${m[2]}-${m[3]}`}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<app> | |
<h1>Riot</h1> | |
<p>A React-like user interface micro-library.</p> | |
<style scoped type="external"> | |
:scope { | |
display: block; | |
} | |
h1 { | |
border-bottom: 1px solid black; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ES6 | |
[...Array(10).keys()] | |
Array(10).map((n, i) => i) | |
Array.from(Array(10).keys()) | |
Array.from({ length:10 }, (v, i) => i) | |
// ES5 | |
Array(10).map(function(n, i) { return i }) | |
// Oldies |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
numberFormat = (n) ->s = n + ''; s = s.replace(/(\d+)(\d{3})$/, '$1,$2') while /(\d+)(\d{3})$/.test s; s | |
numberFormat2 = (n) -> (n + '').replace /(\d+)(\d{3})?(\d{3})?(\d{3})?(\d{3})?(\d{3})$/, (match...) -> (match[p] + '' for p in [1..6] when match[p]).join ',' | |
numberFormat3 = (n) -> (n = '00' + n).substr(n.length % 3).match(/\d{3}/g).reduce((x,y) -> x + ',' + y if y).replace /^0*/, '' | |
numberFormat4 = (n) -> (n + '').split('').reduceRight (x, y) -> if (x.length + 1) % 4 then y + x else y + ',' + x | |
# usage | |
s = numberFormat4 1234567 # "1,234,567" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var MyNamespace = {}; | |
MyNamespace.Person = function(){ | |
/* Public Fields */ | |
this.name = ''; | |
this.sex = 'M'; | |
/* Private Fields */ | |
var _age = 0; | |
/* Constructor */ | |
this.initialize = function(name, sex, age){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wget -m -k -K -E http://url/of/web/site |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var widget;widget={server:"http://librize.com",root:"https://raw.github.com/librize/widgets/master",default_params:{},style_loaded:{},addStyle:function(a){return $("head").append('<link rel="stylesheet" type="text/css" href="'+a+'" />')},getQueryParams:function(a){var b,c,d,e,f,g,h,i;d={};h=a.replace(/^.*\?/,"").split("&");for(f=0,g=h.length;f<g;f++){c=h[f];i=c.split("="),b=i[0],e=i[1];d[b]=e}return d},getDefaultParams:function(a){var b;b=this.getQueryParams(a);return this.default_params={place:b.place||void 0,limit:b.limit||5,height:b.height||75,width:b.width||0,theme:b.theme||"simple"}},show:function(a){var b,c,d,e,f,g,h=this;d=a.attr("data-place")||this.default_params.place;c=a.attr("data-limit")||this.default_params.limit;b=a.attr("data-height")||this.default_params.height;g=a.attr("data-width")||this.default_params.width;e=a.attr("data-theme")||this.default_params.theme;if(d){(this.style_loaded[e]==null?e!=="none":void 0)&&this.addStyle(""+widget.root+"/css/"+e+".css");this.style_loaded[e]=!0;f=""+widget |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<script src="http://code.jquery.com/jquery-1.7.js"></script> | |
</head> | |
<body> | |
<script> | |
url = 'https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://www.engadget.com/rss.xml&callback=?'; | |
$.getJSON(url, function(){ | |
alert('PASS'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HAI | |
I HAS A ANIMAL | |
GIMMEH ANIMAL | |
BOTH SAEM ANIMAL AN "CAT", O RLY? | |
YA RLY | |
VISIBLE "U HAS KITTEH" | |
NO WAI | |
VISIBLE "KITTEH R 2 GUD 4 U" | |
OIC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find . -name \*.php -exec php -l "{}" \; |