Skip to content

Instantly share code, notes, and snippets.

@bellatrix988
bellatrix988 / README.md
Last active January 12, 2023 22:26
Rails 7 & Hotwire & Turbo & Devise workaround

Rails 7 & Hotwire & Turbo & Devise workaround

This gist is relevant while this Devise issue#5446 is not closed or a better solution is not suggested.

Problem:

Not getting flashes errors using turbo.

Solutions:

1. Override FailureApp and devise parent controller.

@michaelvdnest
michaelvdnest / optparse_demo.rb
Last active November 15, 2023 21:37
A sample of Ruby optparse usage
require 'optparse'
options = {}
class Parser
def self.parse(args)
options = {}
opt_parser = OptionParser.new do |opts|
opts.banner = 'Usage: demo.rb [options] ARG...'
opts.separator 'A demo of optparse.'
@schnell18
schnell18 / macosx_remove_java9.sh
Created October 8, 2016 13:26
MacOS X remove Java 9
sudo rm -fr /Library/Java/JavaVirtualMachines/jdk-9.jdk/
sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -fr /Library/PreferencePanes/JavaControlPanel.prefPane
@huytd
huytd / d3-text-measure.js
Created May 6, 2016 18:19
Measure text size in pixels with D3.js
function textSize(text) {
if (!d3) return;
var container = d3.select('body').append('svg');
container.append('text').attr({ x: -99999, y: -99999 }).text(text);
var size = container.node().getBBox();
container.remove();
return { width: size.width, height: size.height };
}
// Usage: textSize("This is a very long text");
@Genkilabs
Genkilabs / application.js
Last active November 18, 2017 11:16
Bootstrap 3 modals in Rails 4 confirms using bootstrap3-dialog JS plugin
//= require jquery
//= require jquery_ujs
//= require_tree .
// ^ I am assuming that bootstrap3-dialog is in the tree
//GLOBAL JQuery Functaionality
$(function(){
/*** CONFIRM MODAL OVERRIDE ***/
//override the use of js alert on confirms
@cpetschnig
cpetschnig / i18n_lookup.rb
Created January 11, 2012 13:32
Log failed I18n lookups in Rails
class I18n::Backend::Simple
module Implementation
protected
def lookup(locale, key, scope = [], options = {})
init_translations unless initialized?
keys = I18n.normalize_keys(locale, key, scope, options[:separator])
keys.inject(translations) do |result, _key|
@dustbyrn
dustbyrn / Gemfile
Created June 28, 2011 19:10
How to reload gems that you're working on
# load the gem from the local filesystem so we can work on it
gem 'couch_record', :path => '../couch_record'