Skip to content

Instantly share code, notes, and snippets.

@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 / 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
*/

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 / iphoto-find-mov-copy-renamed.rb
Last active December 10, 2015 07:58
Find .MOV files in iPhoto directories, then copy them to another path with a new name based on creation date "YYYY-MM-DD_HHMMSS.MOV" (last modified, because there is no "creation date").
# was writen and run on system with Ruby 1.8.7
require 'find'
require 'fileutils'
src_dir = '/path/to/iPhoto Library/Masters'
out_dir = '/path/wher/you/want/to/save/you/ruby-copy/'
count = 0
new_count = 0
Find.find(src_dir) do |path|
if not FileTest.directory?(path)
@loickreitmann
loickreitmann / jQuery.cookie.js
Created September 14, 2012 17:23
jQuery.cookie
@loickreitmann
loickreitmann / String.times.js
Created May 8, 2012 20:46
String.times: String method to repeat a string n times
String.prototype.times = function( n ) {
return Array.prototype.join.call( { length : n + 1 }, this );
};
@loickreitmann
loickreitmann / twitter_feed.html
Created April 12, 2012 00:38
HTML example that pulls a twitter user's feed, using some jQuery animations
<!DOCTYPE html>
<html>
<head>
<title>Twitter feed consumption example</title>
<style>
.main {
margin: 0 auto;
position: relative;
width: 328px;
height: 302px;
@loickreitmann
loickreitmann / web-server-user.php
Created May 12, 2011 17:36
Output web server user account on a PHP web page
<?php echo(exec("whoami")); ?>
@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, ' ');
};
@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/, '_');
})