Skip to content

Instantly share code, notes, and snippets.

View richardvenneman's full-sized avatar
🆒

Richard Venneman richardvenneman

🆒
View GitHub Profile
@necojackarc
necojackarc / active_job_retry_controlable.rb
Last active June 30, 2021 13:20
To enable ActiveJob to control retry
module ActiveJobRetryControlable
extend ActiveSupport::Concern
DEFAULT_RETRY_LIMIT = 5
attr_reader :attempt_number
module ClassMethods
def retry_limit(retry_limit)
@retry_limit = retry_limit
@sebboh
sebboh / gist:f1dfe4f096746c45f3e9ea06a09743a0
Last active February 27, 2024 17:10 — forked from masonforest/gist:4048732
Installing a Gem on Heroku from a Private GitHub Repo

Installing a Gem on Heroku from a Private GitHub Repo

Sometimes you want to use a gem on Heroku that is in a private repository on GitHub.

Using git over http you can authenticate to GitHub using basic authentication. However, we don't want to embed usernames and passwords in Gemfiles. Instead, we can use authentication tokens.

This method does not add your OAuth token to Gemfile.lock. It uses bundle config to store your credentials, and allows you to configure Heroku to use environment variables when deploying.

  1. Generate an OAuth token from GitHub
@davidhund
davidhund / pragmatic-touch-icons.md
Last active September 4, 2020 15:42
Pragmatic Touch Icons

NOTE I'm trying to find the most optimal fav/touch icon setup for my use-cases. Nothing new here. Read Mathias Bynens' articles on re-shortcut-icon and touch icons, a FAQ or a Cheat Sheet for all the details.

I'd like to hear how you approach this: @valuedstandards or comment on this gist.

The issue

You have to include a boatload of link elements pointing to many different images to provide (mobile) devices with a 'favicon' or 'touch icon':

![Touch Icon Links](https://o.twimg.com/2/proxy.jpg?t=HBj6AWh0dHBzOi8vcGhvdG9zLTYuZHJvcGJveC5jb20vdC8yL0FBRGFGY1VRN1dfSExnT3cwR1VhUmtaUWRFcWhxSDVGRjNMdXFfbHRJWG1GNFEvMTIvMjI3OTE2L3BuZy8xMDI0eDc2OC8yL18vMC80L1NjcmVlbnNob3QlMjAyMDE1LTA0LTE0JTIwMTYuNTYuMjYucG5nL0NNejBEU0FCSUFJZ0F5Z0JLQUkvNGR1eDZnMzZmYnlzYWI3

@estum
estum / migrate_hstore_to_json.rb
Last active October 11, 2022 12:29
Ruby on Rails & Postgres: Reversible migrate hstore column to jsonb with contents
class MigrateHstoreToJson < ActiveRecord::Migration
def up
rename_column :posts, :data, :data_hstore
add_column :posts, :data, :jsonb, default: {}, null: false, index: { using: 'gin' }
execute 'UPDATE "posts" SET "data" = json_object(hstore_to_matrix("data_hstore"))::jsonb'
remove_column :posts, :data_hstore
end
def down
rename_column :posts, :data, :data_jsonb
@averyvery
averyvery / application.rb
Last active April 4, 2023 15:02
Inline CSS or JS in Rails
config.assets.precompile += [
# precompile any CSS or JS file that doesn't start with _
/(^inline[^_\/]|\/[^_])[^\/]*.(js|css)$/,
...
@dmilisic
dmilisic / active_record_enum_with_rails_admin.rb
Last active January 21, 2022 10:50
Initializer for handling ActiveRecord (4.1+) enums by RailsAdmin (0.6.2)
module ActiveRecord
module RailsAdminEnum
def enum(definitions)
super
definitions.each do |name, values|
define_method("#{ name }_enum") { self.class.send(name.to_s.pluralize).to_a }
define_method("#{ name }=") do |value|
if value.kind_of?(String) and value.to_i.to_s == value
@lttlrck
lttlrck / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@kevin-smets
kevin-smets / iterm2-solarized.md
Last active April 22, 2024 01:47
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

@tomas-stefano
tomas-stefano / Capybara.md
Last active April 25, 2024 16:44
Capybara cheatsheet

Capybara Actions

# Anchor
click_link 'Save'

# Button
click_button 'awesome'

# Both above
@ndarville
ndarville / business-models.md
Last active January 13, 2024 17:27
Business models based on the compiled list at http://news.ycombinator.com/item?id=4924647. I find the link very hard to browse, so I made a simple version in Markdown instead.

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google