Skip to content

Instantly share code, notes, and snippets.

View coorasse's full-sized avatar
❤️
I will react...but slowly

Alessandro Rodi coorasse

❤️
I will react...but slowly
View GitHub Profile
@coorasse
coorasse / alwaysdata.rake
Created October 2, 2014 14:03
Rake Task to restart Alwaysdata Server
namespace :alwaysdata do
task :restart do
require "rubygems"
require "bundler/setup"
require "capybara"
require "capybara/dsl"
require "capybara-webkit"
USERNAME= ENV['ALWAYSDATA_USERNAME']
PASSWORD= ENV['ALWAYSDATA_PASSWORD']
@coorasse
coorasse / main.js
Last active February 6, 2018 12:36
Bitbucket Codeship PullRequest integration script
$(function() {
var bitbucket_project_name = 'YOUR BITBUCKET PROJECT_NAME LIKE coorasse/airesis';
var codeship_project_code = 'YOUR CODESHIPO PROJECT UUID CODE (look for it in the badge instructions page or general settings page)';
var regexp = new RegExp("^https://bitbucket.org/" + bitbucket_project_name + "/pull-request/","g");
if ((regexp).test(window.location.href)) {
var branch = $('dd.unabridged a').first().html();
var url = 'https://codeship.com/projects/'+codeship_project_code+'/status?branch='+branch;
var row = $('<div></div>')
var column1 = $('<dt>Codeship</dt>');
module FactoryGirl
module Syntax
module Methods
def find_or_create(name, attributes = {}, &block)
attributes = FactoryGirl.attributes_for(name).merge(attributes)
klass = FactoryGirl.factory_by_name(name).build_class
enums = klass.defined_enums
find_attributes = attributes.clone
find_attributes.keys.each do |key|
@coorasse
coorasse / raven_initializer.rb
Last active June 8, 2018 07:46
Sending Sentry Raven events asynchronously with ActiveJob
Raven.configure(true) do |config|
config.async = ->(event) { SentryJob.perform_later(event) }
end
@coorasse
coorasse / activerecord5_issue.rb
Created December 12, 2016 15:20
activerecord5_issue.rb
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', '5.0.0'
@coorasse
coorasse / activerecord4_working.rb
Created December 12, 2016 15:21
activerecord4_working.rb
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', '~> 4.2.0'
@coorasse
coorasse / cancancan_issue.rb
Created May 23, 2017 08:14
CanCanCan issue replication
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', '5.1.0'
@coorasse
coorasse / main.rb
Last active September 13, 2024 15:27
CanCanCan Issue
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', '5.1.0' # use correct rails version
@coorasse
coorasse / old_files_killer.rb
Last active October 16, 2023 14:25 — forked from pelgrim/old_file_killer.rb
A Ruby on Rails script to delete files older than X days in a given directory.
# A Ruby On Rails script to delete files older than X days in a given directory.
# Quickly written by @coorasse
class FilesCleaner
def self.call(days = 1)
Dir.glob(Rails.root.join('path', 'to', 'folder', '*')).each do |filename|
File.delete(filename) if File.mtime(filename) < days.days.ago
end
end
end
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', '5.1.0' # use correct rails version