Skip to content

Instantly share code, notes, and snippets.

View danielvlopes's full-sized avatar

Daniel Lopes danielvlopes

View GitHub Profile
@tristanm
tristanm / README.md
Last active October 1, 2024 06:35
Migrating a Rails project from MySQL to PostgreSQL

Migrating a Rails project from MySQL to PostgreSQL

This brief guide is written from my own experience with migrating a large (~5GB) MySQL database to PostgreSQL for a Rails project.

No warranties, guarantees, support etc. Use at your own risk and, as always, ENSURE YOU MAKE BACKUPS FIRST!

I chose [pgloader][1] because it's extremely fast. YMMV.

  1. Replace mysql2 gem with pg in Gemfile.
  2. Update config/database.yml for PostgreSQL. I used [Rails' template][2] as a starting point.
@pricees
pricees / Ruby Basic
Last active August 29, 2015 13:56
My Ruby Litmus Test.rb
# Integer vs Float div by zero gotchas
#
#
1 / 0 = [answer]
1.0 / 0 = [answer]
1 / 0.0 = [answer]
0 / 0.0 = [answer]
# String concatenation vs interpolation
x = 5

May 2012 - Present (9 months)

LuckyLady is a company I founded together with my wife. She offers spiritual advice and counseling through a number of web properties and a custom CRM I develop and maintain. http://www.raizesespirituais.com.br

Programmer @ objetiva, November 2010 - Present (2 years 3 months)

Objetiva is a consulting company I co-founded. We help startups through their first cycles of product development or when their product has gone down the tube because someone made a mess. At this point we've frozen activities because both my co-founder and myself have burned out on the consulting business. I'm currently still working with one of our clients but it's more an on the side thing. http://www.objetiva.co/?locale=en

@jbhannah
jbhannah / Procfile
Last active May 10, 2017 06:50
Jekyll on Heroku without Rack::Jekyll or custom buildpacks
web: bundle exec puma -p $PORT config.ru
# Wrapper around jQuery ajax methods that exposes
# returned data by publishing an event
#
class Ajax
@getJSON: (url, event)->
$.getJSON url, (data)->
Event.trigger(event, data)
window.Ajax = Ajax
@jasonrudolph
jasonrudolph / 00-about.md
Created September 21, 2012 18:42
Rough Notes from Strange Loop 2012
@bokmann
bokmann / ActiveRepository.rb
Created March 27, 2012 16:15
ActiveRepository Strawman
# MOTIVATION: As rails apps are growing, people are noticing the drawbacks
# of the ActiveRecord pattern. Several apps I have seen, and several
# developers I have spoken to are looking towards other patterns for object
# persistence. The major drawback with ActiveRecord is that the notion
# of the domain object is conflated with what it means to store/retrieve
# it in any given format (like sql, json, key/value, etc).
#
# This is an attempt to codify the Repository pattern in a way that would
# feel comfortable to beginner and seasoned Ruby developers alike.
#
@metaskills
metaskills / wait_until.rb
Last active May 2, 2024 01:51
Never sleep() using Capybara!
# WAIT! Do consider that `wait` may not be needed. This article describes
# that reasoning. Please read it and make informed decisions.
# https://www.varvet.com/blog/why-wait_until-was-removed-from-capybara/
# Have you ever had to sleep() in Capybara-WebKit to wait for AJAX and/or CSS animations?
describe 'Modal' do
should 'display login errors' do
visit root_path
@nhocki
nhocki / gist:1095522
Created July 20, 2011 18:11 — forked from croaky/gist:1089598
Transfer data from production to staging on Heroku
heroku addons:add pgbackups --remote staging
heroku addons:add pgbackups --remote production
heroku pgbackups:capture --remote production
heroku pgbackups:restore DATABASE `heroku pgbackups:url --remote production` --remote staging
@jcsrb
jcsrb / gist:1081548
Created July 13, 2011 23:05
get avatar from google profiles, facebook, gravatar, twitter, tumblr
function get_avatar_from_service(service, userid, size) {
// this return the url that redirects to the according user image/avatar/profile picture
// implemented services: google profiles, facebook, gravatar, twitter, tumblr, default fallback
// for google use get_avatar_from_service('google', profile-name or user-id , size-in-px )
// for facebook use get_avatar_from_service('facebook', vanity url or user-id , size-in-px or size-as-word )
// for gravatar use get_avatar_from_service('gravatar', md5 hash email@adress, size-in-px )
// for twitter use get_avatar_from_service('twitter', username, size-in-px or size-as-word )
// for tumblr use get_avatar_from_service('tumblr', blog-url, size-in-px )
// everything else will go to the fallback
// google and gravatar scale the avatar to any site, others will guided to the next best version