Skip to content

Instantly share code, notes, and snippets.

View lgs's full-sized avatar

Luca G. Soave lgs

View GitHub Profile
@lgs
lgs / scraping.rb
Created September 5, 2016 13:08 — forked from ngauthier/scraping.rb
Scraping the Web with Ruby Code
#!/usr/bin/env ruby
# From: http://ngauthier.com/2014/06/scraping-the-web-with-ruby.html
require 'capybara'
require 'capybara/poltergeist'
require 'csv'
require 'gdbm'
class NickBot
include Capybara::DSL
@lgs
lgs / 00.howto_install_phantomjs.md
Created September 4, 2016 00:24 — forked from julionc/00.howto_install_phantomjs.md
How to install PhantomJS on Debian/Ubuntu

How to install PhantomJS on Ubuntu

Version: 1.9.8

Platform: x86_64

First, install or update to the latest system software.

sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev
@lgs
lgs / ssl_puma.sh
Created April 13, 2016 16:50 — forked from tadast/ssl_puma.sh
localhost SSL with puma
# 1) Create your private key (any password will do, we remove it below)
$ cd ~/.ssh
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@lgs
lgs / rails.rb
Created April 13, 2016 16:16
Use SSL in Rails development. First: to create a local SSL certificate and start a SSL webserver checkout *shell.sh*. Second: to configure Rails checkout *rails.rb*
# To enable SSL in Rails you could now simply use *force_ssl* in your
# ApplicationController but there is two more things to think about:
# In development our SSL webserver is running on port 3001 so we would
# actually need to use *force_ssl port: 3001* but then this wouldn't
# work for production.
# Also there is a good chance you might not always want to use SSL in development
# so it would be nice if we could just enable or disable SSL in the config.
# To make all this work first copy the file *ssl_with_configured_port.rb* to
# your *lib* directory. Second to enable SSL add *config.use_ssl = true*
@lgs
lgs / application_controller.rb
Created March 17, 2016 09:57 — forked from delba/application_controller.rb
use current_user in controller tests
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
private
def signed_in?
!!session[:user_id]
end
helper_method :signed_in?
@lgs
lgs / application_controller.rb
Created February 26, 2016 13:06 — forked from stefanobernardi/application_controller.rb
Multiple omniauth providers and omniauth-identity on the main user model
class ApplicationController < ActionController::Base
protect_from_forgery
protected
def current_user
@current_user ||= User.find_by_id(session[:user_id])
end
def signed_in?
@lgs
lgs / index.md
Created February 1, 2016 23:42 — forked from rstacruz/index.md
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@lgs
lgs / Gemfile
Created January 8, 2016 01:33 — forked from Burgestrand/Gemfile
Threaded scraping with Capybara, Webkit and Celluloid
source :rubygems
gem 'pry'
gem 'capybara'
gem 'capybara-webkit'
gem 'celluloid'
@lgs
lgs / gist:078d98834fc7b237f62e
Created January 4, 2016 17:56
Docker: clen up intermediate unamed images
docker images | egrep "<none>.*<none>" | awk '{print $3}' | while read image ; do docker rmi -f $image; done
@lgs
lgs / 00-about-search-api-examples.md
Created December 25, 2015 22:20 — forked from jasonrudolph/00-about-search-api-examples.md
5 entertaining things you can find with the GitHub Search API