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
# The BlockConfiguration Class for storing the root-level | |
# configuration attributes | |
class BlockConfiguration | |
attr_accessor :attributes | |
%w(attr1 attr2 attr3).each do |method| | |
define_method method do |value| | |
attributes[method] = value | |
end |
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
#!/usr/bin/env ruby | |
require 'optparse' | |
require 'pp' | |
# This hash will hold all of the options | |
# parsed from the command-line by | |
# OptionParser. | |
options = {} |
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
class File | |
def self.gsub(path, regexp, &block) | |
content = File.read(path).gsub(regexp, &block) | |
File.open(path, 'wb') { |file| file.write(content) } | |
end | |
def self.sub(path, regexp, &block) | |
content = File.read(path).sub(regexp, &block) | |
File.open(path, 'wb') { |file| file.write(content) } |
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/sh | |
### BEGIN INIT INFO | |
# Provides: mongodb | |
# Required-Start: $all | |
# Required-Stop: $all | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: starts the mongodb data-store | |
# Description: starts mongodb using start-stop-daemon |
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
# Downloads MongoDB Version 1.2.2 to the Home Dir | |
# Extracts it and moves the contents into the /var/mongodb folder | |
# Creates a symlink from /var/mongodb/mongod to /usr/local/sbin | |
cd ~/ | |
wget http://downloads.mongodb.org/linux/mongodb-linux-x86_64-1.2.2.tgz | |
tar -xf mongodb-linux-x86_64-1.2.2.tgz | |
mkdir -p /var/mongodb | |
mv mongodb-linux-x86_64-1.2.2/* /var/mongodb/ | |
ln -nfs /var/mongodb/bin/mongod /usr/local/sbin |
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
#! /usr/bin/env ruby | |
# Checks to see if the given utility is installed | |
def installed?(util) | |
%x(which #{util}).chomp! | |
end | |
# Makes the path or file friendly for UNIX environment | |
def make_friendly(file) | |
file.gsub("'", "\\'").gsub('"', '\\"').gsub(" ", "\\ ") |
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
require 'rubygems' | |
require 'json' | |
require 'open-uri' | |
require 'progressbar' | |
# YouTube | |
# This class allows you to directly download videos straight from YouTube | |
# All you have to do is provide the full URL to a video on YouTube.com | |
# See the examples below! | |
class YouTube |
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
# | |
# FFMPEG Commands | |
# Playstation 3 / Sony Bravia HD TV Conversion | |
ffmpeg -y -i video.mkv -vcodec libx264 -level 41 -vpre normal -crf 24 -threads 0 -acodec libfaac -ab 128k -ac 2 -ar 48000 new_video.mp4 |
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
.DS_Store | |
log/*.log | |
tmp/**/* | |
config/database.yml | |
db/*.sqlite3 | |
public/assets | |
public/javascripts/all.js | |
public/stylesheets/all.css |
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
# Methods to parse permalinks from strings | |
## Method 1 | |
require 'iconv' | |
class String | |
def to_permalink | |
(Iconv.new('US-ASCII//TRANSLIT', 'utf-8').iconv self).gsub(/[^\w\s\-\—]/,'').gsub(/[^\w]|[\_]/,' ').split.join('-').downcase | |
end | |
end |