Skip to content

Instantly share code, notes, and snippets.


ton devton

View GitHub Profile
devton / Rakefile
Created Jun 1, 2018 — forked from schickling/Rakefile
Activerecord without Rails
View Rakefile
require "active_record"
namespace :db do
db_config = YAML::load('config/database.yml'))
db_config_admin = db_config.merge({'database' => 'postgres', 'schema_search_path' => 'public'})
desc "Create the database"
task :create do
View gist:5c4b56a28ff503340cbaab37e5b4cd7f
Verifying my Blockstack ID is secured with the address 1JDwi1ANgzVi7LvQGg5iuoqyitqmpMXJc4
devton /
Created Mar 17, 2016 — forked from mwhite/
The Ultimate Git Alias Setup

The Ultimate Git Alias Setup

If you use git on the command-line, you'll eventually find yourself wanting aliases for your most commonly-used commands. It's incredibly useful to be able to explore your repos with only a few keystrokes that eventually get hardcoded into muscle memory.

Some people don't add aliases because they don't want to have to adjust to not having them on a remote server. Personally, I find that having aliases doesn't mean I that forget the underlying commands, and aliases provide such a massive improvement to my workflow that it would be crazy not to have them.

The simplest way to add an alias for a specific git command is to use a standard bash alias.

# .bashrc
devton /
Last active Aug 29, 2015
ec2 ubuntu ruby 2.2.1 and small fullstack dependencies
echo "installing depencies..."
sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev nodejs rbenv ImageMagick libmagickwand-dev build-essential postgresql postgresql-common libpq-dev imagemagick nginx libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev -y
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
if [ ! -d ~/.rbenv/plugins/ruby-build ]; then git clone ~/.rbenv/plugins/ruby-build; fi
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
rbenv install 2.2.1 -s
View gist:eb179f6cbcf6fa20af49
How to setup Heroku Hostname SSL with GoDaddy SSL Certificate and Zerigo DNS
Heroku recently added an exciting new 'Hostname SSL' option. This option offers the broad compatibility of IP-based SSL, but at 1/5 the price ($20 / month at the time of this writing).
The following tutorial explains how to use Heroku's new 'Hostname SSL' option on your Heroku project. Before we begin, let's list what we're using here:
* Heroku Hostname SSL
* GoDaddy Standard SSL Certificate
* Zerigo DNS
View crawler.rake
namespace :crawler do
desc 'Start the crawler on a URL'
task :start, [:url] => [:environment] do |t, args| "starting crawler on --> #{args[:url]}"
links = Crawler::Web.collect_links_from args[:url]
CrawledUrl.transaction do
links.each do |url|
CrawledUrl.persist_from url
devton / crawled_url.rb
Created Feb 10, 2015
CrawledUrl Model
View crawled_url.rb
class CrawledUrl < ActiveRecord::Base
# Persiste uma URL no banco de dados
# caso ela já não tenha sido persistida ou
# não tenha nenhuma expressão negativa
def self.persist_from url
self.find_or_create_by ::Crawler::UrlParser.parse(url) unless NegativeExpression.url_match?(url)
View crawled_url_spec.rb
require 'rails_helper'
RSpec.describe CrawledUrl, :type => :model do
describe ".persist_from" do
let(:url) { '' }
let(:attributes) { ::Crawler::UrlParser.parse url }
subject { CrawledUrl.persist_from url }
context "when url already persisted" do
devton / url_parser.rb
Created Feb 10, 2015
View url_parser.rb
module Crawler
class UrlParser
# Instancia a classe e já faz o parser
# retornando um hash com os atributos da URL
def self.parse url
_ = new url
def initialize url
devton / url_parser_spec.rb
Created Feb 10, 2015
Crawler::UrlParser spec
View url_parser_spec.rb
require "rails_helper"
RSpec.describe Crawler::UrlParser, :type => :service do
describe ".parse" do
subject { Crawler::UrlParser.parse url }
context "normal url" do
let(:url) { '' }
let(:url_attributes) {
You can’t perform that action at this time.