Skip to content

Instantly share code, notes, and snippets.

View D3MZ's full-sized avatar

Demetrius Michael D3MZ

View GitHub Profile
cut -d',' -f6 #Close prices in sheet
awk 'NR>1{print $1-p} {p=$1}' #changes in close prices
awk '{if ($1 != 0) print $1}' #no zeros
perl -ne 'print $_ < 0 ? -1 : 1, "\n";' #up-down format
@D3MZ
D3MZ / Expected
Created September 6, 2012 21:04
Turning greedy regex to shortest match
<strong><span style="font-size: large;">Ingredients:</span></strong><br />
<ul>
<li>Ines Rosales Rosemary and Thyme Tortas</li>
<li>Pizza Sauce (ready made in a jar)</li>
<li>Roma Tomatoes</li>
<li>Roasted Red Peppers </li>
<li>Marinated Artichoke Hearts</li>
<li>Olives (I used Pitted Spanish Manzanilla Olives)</li>
<li>Daiya Vegan Mozzarella Cheese</li>
</ul>
@D3MZ
D3MZ / Expected_match.html
Created September 7, 2012 14:37
Shortest Match Regex
<strong><u><span style="font-size: large;">Ingredients:</span></u></strong><br />
<ul>
<li>2 Granny Smith Apples (Peeled and Diced)</li>
<li>Juice from 1/2 Lemon</li>
<li>2 TBSP Splenda Brown Sugar</li>
<li>1/2 tsp Cinnamon</li>
<li>1/2 Cup Rolled Oats</li>
</ul>
@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?}
@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 / 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 / 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 / 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 / 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 / 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