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
Array.prototype.remove = function(value) { | |
var idx = this.indexOf(value); | |
if (idx != -1) { | |
return this.splice(idx, 1); | |
} | |
return false; | |
} |
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 winston = require( 'winston' ), | |
fs = require( 'fs' ), | |
logDir = 'log', // Or read from a configuration | |
env = process.env.NODE_ENV || 'development', | |
logger; | |
winston.setLevels( winston.config.npm.levels ); | |
winston.addColors( winston.config.npm.colors ); | |
if ( !fs.existsSync( logDir ) ) { |
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
//array = [{object: 'property'}, {object2: 'property2'}] | |
var arrayIndexByPropertyValue = function (array, property, value){ | |
//Runs the array | |
for(var i = 0, m = null; i < array.length; ++i) { | |
//Compares the property value | |
if(array[i][property] == value) { | |
//If correct returns it | |
return i; | |
break; |
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 express = require('express') | |
var app = express(); | |
app.set('port', (process.env.PORT || 8080)) | |
app.get('*', function(request, response) { | |
response.redirect('http://example.com') | |
}) | |
app.listen(app.get('port'), function() { |
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 | |
CONNECTION_URL="" | |
BACKUP_DIR="bks" | |
BACKUP_FILE="$BACKUP_DIR/backup_$(date +'%Y%m%d%H%M%S').sql" | |
# Function to parse connection URL | |
parse_url() { | |
local url="$1" | |
local proto="$(echo $url | grep '://' | sed -e's,^\(.*://\).*,\1,g')" |