Skip to content

Instantly share code, notes, and snippets.

View thoughtpunch's full-sized avatar
💸
Hiring with AI @ Dover

Dan Barrett thoughtpunch

💸
Hiring with AI @ Dover
View GitHub Profile
@thoughtpunch
thoughtpunch / most_common_word.rb
Created February 25, 2014 00:26
Ruby Homework Problem - Most common word in list
# DANS METHOD + EXPLANATION - LETS TAKE A LOOK AT HOW THIS WORKS
# lets start with a string
string = "Joe is a cool dude. I am also a cool dude. Cool dudes are the best."
# lets clean it up by removing punctuation and lowercasing everything.
# - remember 'Dude' does not equal 'dude' nor 'dUdE', etc. String comparison is exact!
# - the '/\W/' is a regex command that matches all non-letters and numbers. 'gsub' replaces those matches with something, in
# this case, it's an empty space
string.downcase.gsub(/\W/,' ')

Keybase proof

I hereby claim:

  • I am thoughtpunch on github.
  • I am thoughtpunch (https://keybase.io/thoughtpunch) on keybase.
  • I have a public key whose fingerprint is 0B80 D1C9 BCEA C8B3 EEF6 32D7 45DD 4038 F3DF D8C8

To claim this, I am signing this object:

@thoughtpunch
thoughtpunch / Gemfile
Created June 20, 2014 00:30
Dan Barrett Gemfile
gem "devise" # Authentication
gem "cancan" # Authorization
gem "omniauth" # OAuth providers
# JS Libs
#
gem 'coffee-rails', '~> 4.0.0'
gem 'underscore-rails'
# Global Config/Settings
@thoughtpunch
thoughtpunch / schema.rb
Created January 24, 2011 19:13
Posts_Schema
create_table "posts", :force => true do |t|
t.string "sender", :null => false
t.string "receiver", :null => false
t.text "interaction", :default => "What happened?"
t.integer "score", :default => 0, :null => false
t.boolean "approved", :default => false
t.datetime "created_at"
t.datetime "updated_at"
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Action Controller: Exception caught</title>
<style>
body { background-color: #fff; color: #333; }
body, p, ol, ul, td {
font-family: verdana, arial, helvetica, sans-serif;
font-size: 13px;
#1.TEST.RB FROM http://wiki.neo4j.org/content/Getting_Started_With_Ruby
#require "rubygems"
#require 'neo4j'
#create one node
#Neo4j::Transaction.run do
# #create a node and on property
# node = Neo4j::Node.new :age => 21
#
# #update the node with another property
@thoughtpunch
thoughtpunch / database.rb
Created June 25, 2011 02:16
config/database.rb
#config/database.rb
ActiveRecord::Base.configurations[:development] = {
:adapter => 'postgresql',
:host => 'localhost',
:port => '5432',
:database => 'trustmob_ui_development',
:username => 'postgres',
:password => ''
}
@thoughtpunch
thoughtpunch / padrino_rake_errors.txt
Created June 25, 2011 02:27
"padrino rake ar:migrate" console errors
rake aborted!
ActiveRecord::ConnectionNotEstablished
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:317:in `retrieve_connection'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract/connection_specification.rb:97:in `retrieve_connection'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract/connection_specification.rb:89:in `connection'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/migration.rb:488:in `initialize'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/migration.rb:435:in `new'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/migration.rb:435:in `up'
/usr/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/migration.rb:417:in `migrate'
/usr/lib/ruby/gems/1.9.1/gems/padrino-gen-0.9.29/lib/padrino-gen/padrino-tasks/activerecord.rb:136:in `block (2 levels) in <top (required)>'
@thoughtpunch
thoughtpunch / geolocate_rapist.rb
Created November 14, 2011 15:55
How I know I've been up too late coding....
require 'net/http'
require 'json'
require 'hashie'
class Geolocate
def self.ip(ip)
#REGEX FOR VALID IP ADDRESSES
if /\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/.match(ip).nil?
raise "Not a valid IP address (e.x. '123.456.78.9')"
@thoughtpunch
thoughtpunch / google_maps_places_autocomplete.js
Created November 25, 2011 19:12
Google Maps API + Places AutoComplete JS
$(document).ready(function()
{
$('blockquote.text').expander();
function initialize() {
var mapDiv = $('#map_canvas');
var lat = mapDiv.data('latitude'),
lng = mapDiv.data('longitude');
var mapOptions = {
center: new google.maps.LatLng(lat,lng),