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 rePhoneNumber = /([2-9]|two|three|four|five|six|seven|eight|nine)[^0-9a-zA-Z]{0,3}([0-9]|zero|o|one|l|i|two|three|four|five|six|seven|eight|nine)[^0-9a-zA-Z]{0,3}([0-9]|zero|o|one|l|i|two|three|four|five|six|seven|eight|nine)[^0-9a-zA-Z]{0,3}([0-9]|zero|o|one|l|i|two|three|four|five|six|seven|eight|nine)[^0-9a-zA-Z]{0,3}([0-9]|zero|o|one|l|i|two|three|four|five|six|seven|eight|nine)[^0-9a-zA-Z]{0,3}([0-9]|zero|o|one|l|i|two|three|four|five|six|seven|eight|nine)[^0-9a-zA-Z]{0,3}([0-9]|zero|o|one|l|i|two|three|four|five|six|seven|eight|nine)[^0-9a-zA-Z]{0,3}([0-9]|zero|o|one|l|i|two|three|four|five|six|seven|eight|nine)[^0-9a-zA-Z]{0,3}([0-9]|zero|o|one|l|i|two|three|four|five|six|seven|eight|nine)[^0-9a-zA-Z]{0,3}([0-9]|zero|o|one|l|i|two|three|four|five|six|seven|eight|nine)/gi | |
export default function containPhoneNumber(num) { | |
return !!rePhoneNumber.test(num); | |
} |
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
#!/bin/bash | |
vim -d <(eb printenv $1) <(eb printenv $2) |
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
//return an array of objects according to key, value, or key and value matching | |
function getObjects(obj, key, val) { | |
var objects = []; | |
for (var i in obj) { | |
if (!obj.hasOwnProperty(i)) continue; | |
if (typeof obj[i] == 'object') { | |
objects = objects.concat(getObjects(obj[i], key, val)); | |
} else | |
//if key matches and value matches or if key matches and value is not passed (eliminating the case where key matches but passed value does not) | |
if (i == key && obj[i] == val || i == key && val == '') { // |
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
// Convert the package versions in package.json to the version of the installed packages | |
// | |
// cd your-package | |
// node fix-package-json.js > package.json | |
var fs = require("fs"); | |
var contents = fs.readFileSync("package.json"); | |
var json = JSON.parse(contents); | |
// Get current installed versions |
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
# Pull base image. | |
FROM node:4.2.3 | |
# NPM 3 has better management for peerDependencies | |
RUN npm install -g npm@3.x | |
# These 2 guys take a little time and they rarely change... | |
RUN npm install -g bower forever@0.14.2 |
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 tableToJSON(ar, transpose){ | |
if (transpose) ar = arrayTranspose_(ar); | |
var headers = ar.shift(); | |
return JSON.stringify(getObjects(ar, normalizeHeaders(headers))); | |
} | |
// For every row of data in data, generates an object that contains the data. Names of | |
// object fields are defined in keys. | |
// Arguments: | |
// - data: JavaScript 2d array |
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 getJSON(aUrl,sheetname) { | |
//var sheetname = "test"; | |
//var aUrl = "http://pipes.yahoo.com/pipes/pipe.run?_id=286bbb1d8d30f65b54173b3b752fa4d9&_render=json"; | |
var response = UrlFetchApp.fetch(aUrl); // get feed | |
var dataAll = JSON.parse(response.getContentText()); // | |
var data = dataAll.value.items; | |
for (i in data){ | |
data[i].pubDate = new Date(data[i].pubDate); | |
data[i].start = data[i].pubDate; | |
} |
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
# -*- coding: utf-8 -*- | |
""" | |
Builds epub book out of Paul Graham's essays: http://paulgraham.com/articles.html | |
Author: Ola Sitarska <ola@sitarska.com> | |
Copyright: Licensed under the GPL-3 (http://www.gnu.org/licenses/gpl-3.0.html) | |
This script requires python-epub-library: http://code.google.com/p/python-epub-builder/ | |
""" |
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 truncText (text, maxLength, ellipseText){ | |
ellipseText = ellipseText || '…'; | |
if (text.length < maxLength) | |
return text; | |
//Find the last piece of string that contain a series of not A-Za-z0-9_ followed by A-Za-z0-9_ starting from maxLength | |
var m = text.substr(0, maxLength).match(/([^A-Za-z0-9_]*)[A-Za-z0-9_]*$/); | |
if(!m) return ellipseText; | |
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
source "http://rubygems.org" | |
gem "janky", "~>0.9" | |
gem "pg" | |
gem "thin" |