Skip to content

Instantly share code, notes, and snippets.

View D3MZ's full-sized avatar
😎

Demetrius Michael D3MZ

😎
View GitHub Profile
@D3MZ
D3MZ / application.html.erb
Created December 3, 2012 03:10
Haml rocks.
<!DOCTYPE html>
<html>
<head>
<title><%= full_title(yield(:title)) %></title>
<%= stylesheet_link_tag "application", media: "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
<%= render 'layouts/shim' %>
</head>
<body>
@D3MZ
D3MZ / railcasts_episodes.rb
Created November 14, 2012 22:37
grab links for railcasts episodes
require 'mechanize'
@agent = Mechanize.new { |agent| agent.user_agent_alias = 'Mac Safari' }
url = "http://railscasts.com/episodes/13-dangers-of-model-in-session"
page = @agent.get url
links = []
while page.link_with(:text => /next/i)
break if page.search("//*[@id=\"episode\"]/div[1]/ul/li[2]/a").first.nil?
links << page.search("//*[@id=\"episode\"]/div[1]/ul/li[2]/a").first.attributes["href"].value
page = page.link_with(:text => /next/i).click
@D3MZ
D3MZ / before using the ruby file
Created October 25, 2012 02:18
Import Extreme Startups Contacts, Export to Vcards
# download this gist, and cd into folder.
$ sudo gem i vpim #Installs vpim
$ ruby make_vcard.rb ~/Downloads/Extreme\ Startups\ Contact\ List\ \%282\%29\ -\ Contact\ List.csv #Yours will be slightly different. ruby make_vcard.rb file_path
@D3MZ
D3MZ / gist:3915286
Created October 18, 2012 23:06
Evolution of the Programmer
High School/Jr.High
10 PRINT "HELLO WORLD"
20 END
First year in College
program Hello(input, output)
begin
writeln('Hello World')
@D3MZ
D3MZ / mandrill.rb
Created October 1, 2012 21:01
mandrill hack.
require 'pp'
require 'HTTParty'
require 'mail'
#JSON broken for Mandrill.
#class Mandrill
# include HTTParty
# base_uri 'mandrillapp.com'
# def initialize(key)
# #@auth = {:email => u, :key => p}
@D3MZ
D3MZ / gist:3779897
Created September 25, 2012 03:57
Install RVM / Ruby in Ubuntu
curl -L get.rvm.io | bash -s stable --auto; source /home/ubuntu/.rvm/scripts/rvm
sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config #dependencies
rvm install 1.9.3 #or whatever the latest is.
@D3MZ
D3MZ / gist:3779860
Created September 25, 2012 03:41
Enable the universe, in ubuntu.
sudo sed -i -e "s/# deb/deb/g" /etc/apt/sources.list
@D3MZ
D3MZ / mongo.sh
Created September 25, 2012 03:34
Install Mongo on AWS
$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
$ sudo vi /etc/apt/sources.list.d/10gen.list #add deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen
$ sudo apt-get update
$ sudo apt-get install mongodb-10gen
@D3MZ
D3MZ / rubyplusplus 12-17-2011
Created September 24, 2012 16:43 — forked from whistler/rubyplusplus 12-17-2011
Set up Ubuntu for Rails and Github
############ For Vitual Machines #######
sudo locale-gen en_CA.UTF-8
sudo apt-get install ruby git build-essential
############ Apt-Fast ############
sudo apt-get install axel
axel -a "http://www.mattparnell.com/linux/apt-fast/apt-fast.sh"
sudo chmod +x apt-fast
sudo mv apt-fast /usr/bin/
@D3MZ
D3MZ / splitter.rb
Created September 7, 2012 20:16
dn work
class String
def split_to_array
encoding_options = {
:invalid => :replace, # Replace invalid byte sequences
:undef => :replace, # Replace anything not defined in ASCII
:replace => ' ', # Use a blank for those replacements
:universal_newline => true # Always break lines with \n
}
string = self.encode(Encoding.find('ASCII'), encoding_options)
string = string.split("\n").delete_if {|x| x.empty?}