Skip to content

Instantly share code, notes, and snippets.

@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/, '_');
})
@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.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.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, '');