Skip to content

Instantly share code, notes, and snippets.

@nunosilva800
nunosilva800 / rails_helper.rb
Created June 28, 2014 14:10
expected to respond to `has_db_column?` - rails helper config
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require 'spec_helper'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'shoulda/matchers'
require 'foreigner-matcher'
require 'capybara/rspec'
# Requires supporting ruby files with custom matchers and macros, etc, in
@nunosilva800
nunosilva800 / spec_helper.rb
Created June 28, 2014 14:10
expected to respond to `has_db_column?` - spec helper config
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause this
# file to always be loaded, without a need to explicitly require it in any files.
#
# Given that it is always loaded, you are encouraged to keep this file as
# light-weight as possible. Requiring heavyweight dependencies from this file
# will add to the boot time of your test suite on EVERY test run, even for an
# individual file that may not need all of that loaded. Instead, make a
# separate helper file that requires this one and then use it only in the specs
@nunosilva800
nunosilva800 / delete_remotes_in_master.sh
Last active August 29, 2015 14:05 — forked from schacon/gist:942899
Delete remote branches merged into master
$ git remote prune origin |
git branch -r --merged origin/master |
grep origin |
grep -v '>' |
grep -v master |
xargs -L1 |
cut -d"/" -f2- |
xargs git push origin --delete
@nunosilva800
nunosilva800 / dup_ids.js
Created November 6, 2014 18:52
Jquery snippet to find duplicated IDs in DOM.
$('[id]').each(function(){
var ids = $('[id="'+this.id+'"]');
if(ids.length>1 && ids[0]==this)
console.warn('ID #'+this.id+' found '+ids.length+' times');
});
@nunosilva800
nunosilva800 / fixtures.rake
Created December 5, 2014 23:28
Comfy Sofa export and import fixtures to S3
namespace :fixtures do
namespace :s3 do
require 'fileutils'
def cms_export from, to
# create the fixtures files from DB
ComfortableMexicanSofa::Fixture::Exporter.new(from, to).export!
# get the bucket
bucket = AWS::S3.new.buckets[ENV['S3_BUCKET_FIXTURES']]
ActiveAdmin::Dashboards.build do
# Add this section in your dashboard...
section "Background Jobs" do
now = Time.now.getgm
ul do
li do
jobs = Delayed::Job.where('failed_at is not null').count(:id)
link_to "#{jobs} failing jobs", admin_jobs_path(q: {failed_at_is_not_null: true}), style: 'color: red'
end
@nunosilva800
nunosilva800 / 0_reuse_code.js
Created November 2, 2013 14:55
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@nunosilva800
nunosilva800 / rubycritic_rating_and_score.md
Last active January 22, 2016 21:48
RubyCritic's Rating and Score

Rating and Score

When RubyCritic runs, each analysed class or module gets assigned a rating - a letter from A to F, A being the best. This serves as a baseline to tell you how smelly the code is. Generally A's & B's are good enough, C's serve as a warning and D's & F's are the ones you should be fixing.

Similarly, a global score that ranges from 0 to 100 is calculated, where higher values are better - less code smells detected. This provides a quick insight about the overall code quality.

RubyCritic's rating system was inspired by Code Climate's, you can [read more about how that works here][1].

@nunosilva800
nunosilva800 / equal.rb
Created September 30, 2016 11:18
Ruby equalities
irb> 1 == 1.0
=> true # generic equality
irb> 1 === 1.0
=> true # case equality
irb> 1.eql? 1.0
=> false # equality by value
irb> 1.equal? 1.0
echo "* Updating system"
sudo apt-get update
sudo apt-get -y upgrade
echo "* Installing packages"
sudo apt-get -y install build-essential libxml2-dev libxslt1-dev git-core nginx redis-server postgresql-client libpq5 libpq-dev curl nodejs htop
sudo locale-gen pt_PT.UTF-8
sudo dpkg-reconfigure locales
echo "* Installing rvm"