Skip to content

Instantly share code, notes, and snippets.

View mri-dula's full-sized avatar
😀

Mridula Prabhu mri-dula

😀
View GitHub Profile
@mri-dula
mri-dula / delete_multiple_branches.sh
Created October 22, 2020 09:28
GIT: Delete all (except specific) branches from your local repo
#!/bin/bash
function exit_if_nothing {
if [ -z "$list" ]; then
echo "Nothing to delete"
exit 0
fi
}
list=`git branch --list | cat | grep -v '\*' | grep -v "\master\b"`
exit_if_nothing
for i in $*; do
@mri-dula
mri-dula / convert_to_active_storage.rb
Last active February 27, 2021 00:14
Create active storage attachment records from paperclip files in PostgreSQL
class ConvertToActiveStorage < ActiveRecord::Migration[5.2]
require 'open-uri'
def change
active_storage_blob_statement = ActiveRecord::Base.connection.raw_connection.prepare('active_storage_blob_statement', <<-SQL)
INSERT INTO active_storage_blobs (
"key", filename, content_type, metadata, byte_size, checksum, created_at
) VALUES ($1, $2, $3, '{}', $4, $5, $6)
SQL
@mri-dula
mri-dula / spec.rb
Last active April 11, 2018 12:15
(#32476) has_many does not update on save if parent has not been changed
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
gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
gem "sqlite3"