Skip to content

Instantly share code, notes, and snippets.

View Chocksy's full-sized avatar
🏠
Working from home

Ciocanel Razvan Chocksy

🏠
Working from home
View GitHub Profile
@Lukom
Lukom / email_previews.rb
Last active April 2, 2021 18:43
Preview Emails in ActiveAdmin / Rails 5.1
# app/admin/email_previews.rb
ActiveAdmin.register_page 'Email Previews' do
menu parent: 'dashboard', priority: 10
content do
div '1'
end
sidebar 'Mail Previews' do
Dir['test/mailers/previews/**/*_preview.rb'].each do |preview_path|
@LeonardoCardoso
LeonardoCardoso / GPG-Tower
Last active March 17, 2025 10:05
How to setup Tower to use the GPG Suite
# GPG on Tower
@hyperionel
hyperionel / gist:cd5b3cd77353379e63d16721aae239b2
Last active March 17, 2017 18:35
Commonmarker characteristics
# Commonmarker's default html renderer: https://github.com/gjtorikian/commonmarker/blob/master/lib/commonmarker/renderer/html_renderer.rb
# It has a sepparate method for each type of html tag it supports
# paragraph method:
def paragraph(node)
if @in_tight && node.parent.type != :blockquote
out(:children)
else
block do
@alarrosa14
alarrosa14 / abbreviate.js
Last active August 2, 2018 12:41
Angular filter to abbreviate large numbers, optionally receiving the number of decimal places as parameter.
// Based in http://stackoverflow.com/a/2686098/4436816
//
// Usage examples:
// {{ 2134124 | abbreviate:2}} -> 2.13M
// {{ 2134124 | abbreviate }} -> 2M
// {{ 1000 | abbreviate }} -> 1K
myApp.filter('abbreviate', function() {
return function(number, decPlaces) {
@zulhfreelancer
zulhfreelancer / readline_bundle_image_not_found.md
Last active November 3, 2021 20:50
How to fix 'readline.bundle image not found' problem?

If you get error like this:

Running via Spring preloader in process 7662
/Users/zulh/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require': dlopen(/Users/zulh/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle, 9): Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib (LoadError)
  Referenced from: /Users/zulh/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle
  Reason: image not found - /Users/zulh/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle
	from /Users/zulh/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `block in require'
	from /Users/zulh/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
	from /Users/zulh/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
@sobstel
sobstel / nokogiri_install
Created January 3, 2017 17:30
nokogiri -> ERROR: cannot discover where libxml2 is located on your system
# `ERROR: Error installing nokogiri:
# ERROR: Failed to build gem native extension.
#
# current directory: /usr/local/var/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/nokogiri-1.7.0/ext/nokogiri
# /usr/local/var/rbenv/versions/2.3.1/bin/ruby -r ./siteconf20170103-68488-r71c9j.rb extconf.rb --with-xml=/usr/local/Cellar/libxml2/ --use-system-libraries
# checking if the C compiler accepts ... yes
# checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
# Building nokogiri using system libraries.
# ERROR: cannot discover where libxml2 is located on your system. please make sure `pkg-config` is installed.
# *** extconf.rb failed ***
@taranda
taranda / dynamic-critical-path-css.md
Last active July 7, 2021 19:53
Dynamically Add Critical CSS to Your Rails App

Dynamically Add Critical CSS to Your Rails App

Optimizing the delivery of CSS is one way to improve user experience, load speed and SEO of your web app. This involves determining the "critical path CSS" and embeding it into the html of your page. The rest of the CSS for the site is loaded asynchronously so it does not block the rendering of your "above the fold" content. This Gist will show you how to dynamically generate critical path CSS for your Rails app.

In this example we will use the mudbugmedia/critical-path-css gem.

Prerequisites

You will need to set up caching and Active Job in your Rails app. I recommend using a thread-safe background job manager like resque.

@Chocksy
Chocksy / .1details.md
Last active April 9, 2020 16:26
Gemfile local that will allow for special gems only on local env

Differences between team gemfile and your preferences

The solution for the above problem is to have a different gemfile that you run your rails app against. It can be easily done by adding some terminal aliases to use a different gemfile file. I made that in the current configuration and it works well.

@syafiqfaiz
syafiqfaiz / how-to-copy-aws-rds-to-local.md
Last active December 8, 2024 22:08
How to copy production database on AWS RDS(postgresql) to local development database.
  1. Change your database RDS instance security group to allow your machine to access it.
    • Add your ip to the security group to acces the instance via Postgres.
  2. Make a copy of the database using pg_dump
    • $ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
    • you will be asked for postgressql password.
    • a dump file(.sql) will be created
  3. Restore that dump file to your local database.
    • but you might need to drop the database and create it first
    • $ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
  • the database is restored
@jeffreyjurgajtis
jeffreyjurgajtis / gist:a731b9c779656309c06c
Created June 11, 2015 15:19
Heroku Postgres DB to local Postgres DB
Details:
https://devcenter.heroku.com/articles/heroku-postgres-backups
$ heroku pg:backups capture #=> <backup_number>
$ heroku pg:backups public-url <backup_number> #=> <backup_url>
$ curl -o latest.dump <backup_url>
(drop and re-create local database)
$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U myuser -d mydb latest.dump