Skip to content

Instantly share code, notes, and snippets.

View mariozig's full-sized avatar

Mario Zigliotto mariozig

  • Intuit
  • San Mateo, CA
View GitHub Profile
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
bloggy_web latest fd72d1901622 10 hours ago 912 MB
<none> <none> a51a0506164a 10 hours ago 903.4 MB
bloggy_square latest 4246ada965f2 10 hours ago 903.4 MB
<none> <none> 6e1e68d610ba 10 hours ago 903.4 MB
docker_square latest 85c7ac711d78 11 hours ago 808.9 MB
postgres 9.4.1 03119fe33f25 4 days ago 213.9 MB
ruby 2.2.1 ef6e4b7dc7cd 3 weeks ago 775.1 MB
kirkdockerized_web latest 83edc1a1d29a 4 months ago 347.8 MB

#Heroku, Ruby on Rails and PhantomJS

In this post, I’m going to show you how to modify an existing Ruby on Rails app running on Heroku’s Cedar stack to use PhantomJS for screen scraping. If you’ve never heard of PhantomJS, it’s a command-line WebKit-based browser (that supports JavaScript, cookies, etc.).

Let’s get started. This is a high-level overview of the required steps:

  • Modify your app to use multiple Heroku buildpacks.
  • Extend your app to use both the Ruby as well as the PhantomJS buildpacks.
  • Confirm that everything worked.
@mariozig
mariozig / developer_machines.sh
Last active September 17, 2020 21:46
Changes to remote for developers. Full blog post @ http://ruby.zigzo.com/2015/03/23/moving-from-gitlab-to-github/
# Go to local repo
cd /path/on/your/machine/my-repo
# Just update the remote
git remote set-url origin git@github.com:mario/my-repo.git
@mariozig
mariozig / migrate_repo.sh
Last active May 26, 2024 20:57
Migrate repo from GitLab to GitHub Full blog post @ http://ruby.zigzo.com/2015/03/23/moving-from-gitlab-to-github/
# Assume we are in your home directory
cd ~/
# Clone the repo from GitLab using the `--mirror` option
$ git clone --mirror git@your-gitlab-site.com:mario/my-repo.git
# Change into newly created repo directory
$ cd ~/my-repo.git
# Push to GitHub using the `--mirror` option. The `--no-verify` option skips any hooks.
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
@mariozig
mariozig / #10945
Last active December 23, 2015 06:29
Add additional assert that more clearly exposes the fact that ArtistsTrack's artistic_role_id is being lost
# Activate the gem you are reporting the issue against.
gem 'activerecord', '4.0.0'
require 'active_record'
require 'minitest/autorun'
require 'logger'
# This connection will do for database-independent bug reports.
# ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: 'shiz.db')
ActiveRecord::Base.logger = Logger.new(STDOUT)
devise = yes?("Devise? ")
cancan = yes?("Cancan? ")
omniauth = yes?("Omniauth? ")
foundation = yes?("Foundation? ")
bootstrap = foundation ? false : yes?("Bootstrap? ")
ember = yes?("Ember? ")
handlebars = ember ? false : yes?("Handlebars? ")
underscore = yes?("Underscore? ")
staticpages = yes?("Static Pages Controller with home page? ")
github = yes?("GitHub create and push? ")
# Do not refactor, it is a bad practice. YOLO
# Not understanding why or how something works is always good. YOLO
# Do not ever test your code yourself, just ask. YOLO
# No one is going to read your code, at any point don't comment. YOLO
# Why do it the easy way when you can reinvent the wheel? Future-proofing is for pussies. YOLO
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
@user.errors[:email].should include("is invalid") # check for the error format message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
x = method_that_returned_nil() #=> nil
x ||= "default" #=> "default" : value of x is nil, so it will be replaced with "default"
x ||= "other" #=> "default" : value of x is "default" so it will stay "default" and NOT be set to "other"