Skip to content

Instantly share code, notes, and snippets.

Amazon Linux AMI with Node/NPM and Nginx

Installation

1. Create a Amazon Linux AMI instance on AWS/EC2

2. Connect to your instance with SSH

3. Update your instance:

@loickreitmann
loickreitmann / styles.less
Last active August 29, 2015 14:03
My custom Atom.io styles
/*
* Your Stylesheet
*
* This stylesheet is loaded when Atom starts up and is reloaded automatically
* when it is changed.
*
* If you are unfamiliar with LESS, you can read more about it here:
* http://www.lesscss.org
*/
@loickreitmann
loickreitmann / caesarShift.js
Last active August 30, 2015 01:22
Javascript version of Caesar shift
function crypt(message, shiftText, isDecrypt) {
'use strict';
return caesarShift(message.toUpperCase(), getShift(shiftText, isDecrypt));
}
function getShift(shiftText, isDecrypt) {
var shift;
if (isNaN(shiftText) && !/^-?\d+$/.test(shift)) {
console.log("Shift is not an integer");
return 0;
}
@loickreitmann
loickreitmann / getQuerystringParamByName.js
Created December 6, 2010 22:13
JS function to grab a QS param
function getQuerystringParamByName(name) {
var regexS, regex, results;
regexS = "[\\?&]" + name + "=([^&#]*)";
regex = new RegExp(regexS);
results = regex.exec(location.href);
if (results === null) {
return null;
} else {
return (results[1] !== '') ? results[1] : null;
}
@loickreitmann
loickreitmann / doCookie.js
Created December 6, 2010 22:21
JS function to get or set a cookie
/**
* doCookie: function to get or set a cookie
* @param name (string): cookie name
* @param value (string - optional): cookie value to set
* @param options (object - optional): possible options are
* - expires: (number of days | proper datetime string)
* - path: (string)
* - domain: (string)
*/
function doCookie(name, value, options) {
@loickreitmann
loickreitmann / String.toCamelCase.js
Created April 14, 2011 22:51
Simple String method to convert a string to camel case (i.e, "This is my string!? Dashes - removed !@#$%^&*()(.+=;':[]}{<>|,./\"" converts to "thisIsMyStringDashesRemoved".
/**
* toCamelCase: converts string to camel case
*/
String.prototype.toCameCase = function () {
return this.replace(/^\s+|\s+$/g, "")
.toLowerCase()
.replace(/(\s[a-z0-9])/g, function ($1) {
return $1.replace(/\s/, '').toUpperCase();
})
.replace(/\W/g, '');
@loickreitmann
loickreitmann / String.trim.js
Created April 14, 2011 22:54
String method to remove leading and trailing white space.
/**
* trim: removes leading and trailing white space
*/
String.prototype.trim = function () {
return this.replace(/^\s+|\s+$/g, "");
};
@loickreitmann
loickreitmann / String.toDashed.js
Created April 14, 2011 23:11
Converts a string to dashed.
/**
* toDashed: converts string to dashed
*/
String.prototype.toDashed = function () {
return this.replace(/^\s+|\s+$/g, "")
.toLowerCase()
.replace(/-/g, '')
.replace(/(\s[a-z0-9])/g, function ($1) {
return $1.replace(/\s/, '-');
})
@loickreitmann
loickreitmann / String.toUnderscored.js
Created April 14, 2011 23:19
Converts string to underscored.
/**
* toUnderscored: converts string to underscored
*/
String.prototype.toUnderscored = function () {
return this.replace(/^\s+|\s+$/g, "")
.toLowerCase()
.replace(/_/g, '')
.replace(/(\s[a-z0-9])/g, function ($1) {
return $1.replace(/\s/, '_');
})
@loickreitmann
loickreitmann / String.stripTags.js
Created April 22, 2011 19:13
String function to remove HTML tags from the string
/**
* stripTags: removes HTML tags from a string
* @return String
*/
String.prototype.stripTags = function () {
return this.replace(/<[^<>]+>/g, ' ').replace(/\s{2,}/g, ' ');
};