Skip to content

Instantly share code, notes, and snippets.

View orangeeli's full-sized avatar

Eliseu Martinho orangeeli

  • https://fooji.com
  • Lisbon
View GitHub Profile
@orangeeli
orangeeli / dig.sh
Created June 24, 2016 14:02
To confirm that your DNS record is set up correctly, use the dig command with your custom domain. https://help.github.com/articles/setting-up-an-apex-domain/
#!/bin/bash
dig example.com +nostats +nocomments +nocmd
@orangeeli
orangeeli / git.tag.sh
Created June 21, 2016 06:46
git tagging play
#!/bin/bash
# https://git-scm.com/book/en/v2/Git-Basics-Tagging
# $1 => version
# $2 => comment
# example:
# git tag -a version -m "my tagged version"
git tag -a $1 -m "$2"
class JungleController < ActionController::Base
before_filter :is_there_a_hunter?
inherit_resources
protected
def is_there_a_hunter?
false
end
end
class GorillaController < JungleController
def share_banana
respond_to do |format|
format.json { render :json => banana_json }
end
end
def get_banana
respond_to do |format|
@orangeeli
orangeeli / spec.factories.gorilla.rb
Last active July 15, 2016 16:46
A factory girl factory example
FactoryGirl.define do
factory :gorilla do
first_name 'Björn'
middle_name { Faker::Name.name }
last_name { Faker::Name.last_name }
end
end
@orangeeli
orangeeli / spec.api.gorillas.index.rb
Last active July 15, 2016 16:53
A spec example with Factory Girl
require 'rails_helper'
RSpec.describe 'GET /api/v1/gorilla' do
let(:gorilla) {FactoryGirl.create(:gorilla)}
before { get '/api/v1/gorilla'}
subject { response }
@orangeeli
orangeeli / gorilla_controller.rb
Last active July 15, 2016 16:51
The person controller in an API context
module Api
module V1
class GorillaController < ApplicationController
def index
@gorillas = Gorilla.all
render json: {message: 'We are not extinct. Just well hidden.'}
end
end
end
end
@orangeeli
orangeeli / routes.rb
Last active July 15, 2016 16:45
A routes API example
scope '/api', defaults: {format: 'json'} do
scope '/v1' do
scope '/gorilla' do
get '/' => 'api/v1/gorilla#index'
end
end
end
@orangeeli
orangeeli / rvm.change.gemsets.sh
Created May 28, 2016 07:28
Just a healthy reminder of the most used rvm commands
#!/bin/bash
# Just a healthy reminder of the most used rvm commands.
# Just uncomment those you might want to use
# change gemset
# rvm use ruby-version@gemset-name
# create and change gemset
# rvm use ruby-version@gemset-name --create
@orangeeli
orangeeli / rails.mongoid.config.sh
Created May 24, 2016 11:06
Rails config mongoid command
#!/bin/bash
rails g mongoid:config