Skip to content

Instantly share code, notes, and snippets.

work work work

Alexii Carey elchingon

work work work
View GitHub Profile
elchingon / rails-5-initializer-commands
Last active Jan 13, 2019
Rails 5 Initialize commands for Doorkeeper, Devise, Rolify, Rspec
View rails-5-initializer-commands
# Create Rails App
rails new app_name -d mysql
### cp config/database.example.yml
rake db:create
View activestorage.rb
# config/initializers/activestorage.rb
Rails.application.config.to_prepare do
# Provides the class-level DSL for declaring that an Active Record model has attached blobs.
ActiveStorage::Attached::Macros.module_eval do
def has_one_attached(name, dependent: :purge_later, acl: :private)
class_eval <<-CODE, __FILE__, __LINE__ + 1
def #{name}
@active_storage_attached_#{name} ||="#{name}", self, dependent: #{dependent == :purge_later ? ":purge_later" : "false"}, acl: "#{acl}")
satendra02 / app.DockerFile
Last active Sep 2, 2020
docker+rails+puma+nginx+postgres (Production ready)
View app.DockerFile
FROM ruby:2.3.1
# Install dependencies
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
# Set an environment variable where the Rails app is installed to inside of Docker image:
ENV RAILS_ROOT /var/www/app_name
RUN mkdir -p $RAILS_ROOT
# Set working directory, where the commands will be ran:
require 'sidekiq/api'
# 1. Clear retry set
# 2. Clear scheduled jobs
rhettallain /
Created Mar 8, 2017
This is the code to run on raspberry pi for an interactive pi-day poster
# Example using a character LCD connected to a Raspberry Pi or BeagleBone Black.
import time
import Adafruit_CharLCD as LCD
import Adafruit_CharLCD as LCD
import turtle
import random
from math import sqrt
from gpiozero import Button
necojackarc / active_job_retry_controlable.rb
Last active Feb 5, 2020
To enable ActiveJob to control retry
View active_job_retry_controlable.rb
module ActiveJobRetryControlable
extend ActiveSupport::Concern
attr_reader :attempt_number
module ClassMethods
def retry_limit(retry_limit)
@retry_limit = retry_limit
sarahholderness /
Last active Sep 27, 2020
Python scripts to read a list of customer emails and send an email with the daily weather forecast
import weather
import smtp
Send a greeting email to our customer email list
with the daily weather forecast and schedule
def get_emails():
# Reading emails from a file
View an example of puma and ngxin with ruby on rails

Nginx and Puma for Ruby on Rails

When a lot of people are working on the same Rails application, than Vagrant could help to set up environment quick and easy. Even Vagrant is not recommended for production, it is very usefull for testing deployment script. For production we can simply copy deployment script and run manually.

We can deploy Ruby on Rails app using a quick way to deploy ruby on rails on vagrant.

elchingon / Ubuntu Unicorn RVM Init.d script
Last active Aug 29, 2015
Ubuntu Unicorn RVM Init.d script
View Ubuntu Unicorn RVM Init.d script
---- find out the version of ruby and your gemset (because rvm rules)
rvm current
--- create rvm alias
rvm alias create app_name ruby-2.1.2@app_gemset
--- set rvm wrappers (they removed no-link option and seems like all core gems are given a wrapper)
rvm wrapper app_name unicorn_rails
--- /etc/init.d/unicorn
View angular.filters.nl2br.js
# Usage in html template:
"xxx | nl2br"
<div ng-bind-html=" YourString | nl2br "></div>
You can’t perform that action at this time.