Skip to content

Instantly share code, notes, and snippets.

View FrancisGX's full-sized avatar

Francis Gabriel Xavier FrancisGX

View GitHub Profile
def words
File.open('/usr/share/dict/words').to_a.map { |word| word.chomp }
end
def count
puts "There are this many words in the dicshonary #{words.length}"
end
def search
count
require 'active_record'
require 'postgres-copy'
require 'pg_data_encoder'
require 'benchmark'
ActiveRecord::Base.establish_connection(
:adapter => "postgresql",
:host => "localhost",
:database => "pg_test"
)
@FrancisGX
FrancisGX / vimrc-copy-for-ryan
Created December 6, 2013 17:52
Here it is!
" set up pathogen, https://github.com/tpope/vim-pathogen
filetype off
call pathogen#infect()
filetype plugin indent on
" don't bother with vi compatibility
set nocompatible
" enable syntax highlighting
syntax enable
This is a C++ program that sorts lines read from the first arg and writes them to the second arg.
#include<string>
#include<vector>
#include<algorithm>
#include<fstream>
using namespace std;
int main(int argc, char **argv) {
@FrancisGX
FrancisGX / gem.sublime-snippet.xml
Created April 5, 2013 22:13
A useful shortcut for working in RoR Gemfiles with Subl. 1. Save this file to /Users/yourname/Library/Application Support/Sublime Text 2/Packages/User (Be sure to remove the .xml extension) 2. Open a gemfile, type gem, and then press tab.
<snippet>
<content><![CDATA[
gem '${1:gem_name}'${2:, '${3:version}'}
]]></content>
<tabTrigger>gem</tabTrigger>
<scope>source.ruby</scope>
</snippet>
@FrancisGX
FrancisGX / your_presence_is_present.rb
Created March 11, 2013 17:33
Best practice for handling strings like a boss
# Notes on the Object#blank?, Object#present?, and Object#presence methods
# Calling .present? on an object will return true if the object is not .blank?
# Again, for clarity, an object is present if it is not blank.
# Thus
"".present? # => false
# Because
"".blank? # => true