Skip to content

Instantly share code, notes, and snippets.

View coalwater's full-sized avatar

Mohammad AbuShady coalwater

  • Amsterdam, Netherlands
  • 00:51 (UTC +02:00)
View GitHub Profile
@hopsoft
hopsoft / model_supports_bulk_updates.rb
Last active December 8, 2020 17:08
ActiveRecord Bulk / Batch Update
# frozen_string_literal: true
module ModelSupportsBulkUpdates
extend ActiveSupport::Concern
module ClassMethods
# Performs a bulk update with an efficient single query for all the records in the list.
# Note that the records are not reloaded form the database.
# This means that ActiveRecord will still see these records as dirty after the bulk_update.
def bulk_update(records)
@bf4
bf4 / 20160307172445_change_paperclip_attachment_path.rb
Created April 29, 2016 03:38 — forked from 121onto/20160307172445_change_paperclip_attachment_path.rb
Example migration for changing paperclip storage path
class MoveAttachmentsToNewLocation < ActiveRecord::Migration
def initialize(name = self.class.name, version = nil)
access_key = Rails.application.secrets.g3_access_key_id
secret_key = Rails.application.secrets.g3_secret_access_key
storage = Fog::Storage::Google.new google_storage_access_key_id: access_key,
google_storage_secret_access_key: secret_key
@bucket_name = Rails.application.secrets.g3_bucket
@bucket = storage.directories.get(@bucket_name)
super(name, version)
@marijn
marijn / README.markdown
Last active May 3, 2024 14:09
List of nationalities in YAML, CSV and TXT format

List of nationalities

It's time someone compiled a list of nationalities to use within a web application. This gist attempts to make a first move at that.

List of countries

I've also compiled a list of countries