Skip to content

Instantly share code, notes, and snippets.

@ngelx
ngelx / __ActiveAdmin_for_rails_setting_cache_v2.md
Last active June 21, 2023 06:09
ActiveAdmin extension to add interface to rails-setting-cached > version 2.

ActiveAdmin extension for rails-setting-cached > v2

This is an ActiveAdmin extension to add the interface to handle rails-setting-cached v2. For prior version I was using activeadmin_setting_cached but seems to be dead and does not support version > 2.

The initial idea was to extend that gem and do a PR, but the code is quite old and probably overcomplex. I may move this to a simple gem if there is any intereset on it.

How to use it

Just place the files in the proper places and should be ready to go.

@ngelx
ngelx / ValidateEmail.rb
Last active June 7, 2023 08:54
Regexp to validate emails in Ruby
# Strictly adhere to email address standards and disallow hyphens at the beginning or end of the domain name.
# Use https://rubular.com for live testing.
def validate_email(string)
(string.downcase =~ /\A[a-zA-Z0-9._%+-]+@[a-zA-Z0-9](?:[a-zA-Z0-9\-_]*[a-zA-Z0-9])?(?:\.[a-zA-Z0-9]*)(?:\.[a-zA-Z]{2,})+\z/)&.zero?
end

Local repo

git tag -d <tagname> # delete the old tag locally git push origin :refs/tags/<tagname> # delete the old tag remotely git tag <tagname> <commitId> # make a new tag locally git push --tags

Remote

git pull --tags -f

@ngelx
ngelx / brew-instructions.sh
Last active December 10, 2022 05:04 — forked from petemcw/brew-instructions.sh
Setup dnsmasq on Mac OS X - Ventura 13.01 - Homebrew 3.6.14
# Install `dnsmasq` and configure for *.local and *.localhost domains
$ brew install dnsmasq
$ vim /opt/homebrew/etc/dnsmasq.conf
# Stop and restart service as root.
$ brew services stop dnsmasq
$ sudo brew services start dnsmasq
$ dscacheutil -flushcache
@ngelx
ngelx / query_track.rb
Last active October 2, 2020 16:33
Setting Rollbar as notification for query_track gem
# config/initializer/query_track.rb
# query_track: https://github.com/kirillshevch/query_track
# rollbar: https://docs.rollbar.com/docs/rails
QueryTrack::Settings.configure do |config|
config.duration = 1 # in seconds
config.notifications.custom_handler = lambda do |sql, duration, trace|
e = Exception.new("Slow SQL Query - #{trace}")

Keybase proof

I hereby claim:

  • I am ngelx on github.
  • I am ngel (https://keybase.io/ngel) on keybase.
  • I have a public key ASDRGl-sWVIho9RL_FVJ2lmQ4vZrALt3SOU_ZfpsZIqgrQo

To claim this, I am signing this object:

@ngelx
ngelx / the thing
Created November 26, 2011 16:18
Relational problem
The problem is this:
class Cmr < ActiveRecord::Base
belongs_to :ruta
...
end
class Cmr24 < Cmr
...
end
class Ruta < ActiveRecord::Base