This file contains hidden or 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
const walkSync = require('walk-sync'); | |
const stringify = require('csv-stringify'); | |
var sizeOf = require('image-size'); | |
const fs = require('fs'); | |
const directory = 'path/to/the/directory/you/want/to/crawl'; | |
let dataArr = []; | |
let paths = walkSync(directory, { globs: ['**/*.gif'], directories: false }); |
This file contains hidden or 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
/* | |
Note : This gist allows you to add useful helper methods in string object. Add following gist in your source code and by invoking methods like | |
isURL or isEmail, one can check for url and email respectively. | |
Credits : Regular expression for url and email validation has been extracted from Jörn Zaefferer's 'jquery-validation' plugin. | |
*/ | |
String.prototype.isURL = function () { | |
return /^(https?|s?ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~ |
This file contains hidden or 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
/* | |
Note : Always make sure that input given to instance of Date class is in UTC. If Date is in UTC then only | |
proper relative timestamp can be calculated. | |
By simply calling getRelativeTimestamp on any date object will convert it to relative timestamp | |
*/ | |
Date.prototype.getRelativeTimestamp = function () { | |
var tzoffset = this.getTimezoneOffset() * 60 * 1000; // Calculate timezone offset | |
var currDate = new Date(); |
This file contains hidden or 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 urlify(input) { | |
var regex = /(https?:\/\/[^\s]+)/g; | |
return input.replace(regex, function (url){ | |
// Whitelist for last character of URL (Accept other than Letters, numbers and underscore) | |
var lastCharRegex = /[^\w]$/; | |
var lastChar = ''; | |
// Check if URL ends with and special characters (such as , . - ! ? etc) | |
if(lastCharRegex.test(url)) { |
This file contains hidden or 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
class person | |
constructor : (@name) -> | |
doPrivateThings = () -> | |
alert('Psst ' + @name + ' is doing private things.') | |
#using '=' in function declaration will make it private | |
goToRestroom : -> | |
alert(@name + ' is inside restroom.') | |
doPrivateThings.call(this) |
This file contains hidden or 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
import SOAPpy | |
import base64 | |
SHAPEWAYS_SOAP_URL = "http://www.shapeways.com/modules/shapeways_api/webservice/v1/soap.php" | |
USERNAME = 'user' | |
PASSWORD = 'password' | |
def main(): | |
server = SOAPpy.SOAPProxy(SHAPEWAYS_SOAP_URL) | |
session = server.login(USERNAME, PASSWORD) |