Skip to content

Instantly share code, notes, and snippets.

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

Carlos Montalvo ZephiroRB

🏠
Working from home
View GitHub Profile
@ZephiroRB
ZephiroRB / sorting.rb
Created June 4, 2016 03:58
Organiza tus Carpetas con ruby, Sorting Folders with Ruby
# Sorting Folders (Downloads)
# Organizar tus Folders rapidamente.
# Desarrollado por Carlos Montalvo (zetanova.com) 2016
require 'fileutils'
require 'time'
excludes_files = [
/sorting.rb/i,
@ZephiroRB
ZephiroRB / db.rake
Created February 14, 2017 15:06 — forked from hopsoft/db.rake
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd
@ZephiroRB
ZephiroRB / db.rake
Created February 14, 2017 15:06 — forked from hopsoft/db.rake
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd
@ZephiroRB
ZephiroRB / admin.rb
Last active September 7, 2017 20:10
How to simplify query rails
class Admin < ActiveRecord::Base
has_many :admin_domains
has_many :domains, through: :admin_domains
end
#id, name, email
@ZephiroRB
ZephiroRB / puma.nginx.conf
Last active December 22, 2017 23:50
Deploy Rails + Puma Service Ubuntu 16
# store /etc/nginx/site-enable/app.conf
# systemctl restart nginx
upstream app {
server unix:/var/run/puma_app.sock fail_timeout=0;
}
server {
listen 80;
#Historial de comandos
history
# Filtrando comandos en el historial
history | grep “texto”
@ZephiroRB
ZephiroRB / .download_url
Created January 18, 2018 04:24
Download Full Web Page from Terminal
wget -m http://domain.download.com
@ZephiroRB
ZephiroRB / ruby_ftp_example.rb
Created February 8, 2018 17:11 — forked from 3dd13/ruby_ftp_example.rb
Sample code of using Ruby Net::FTP library. Login to FTP server, list out files, check directory existence, upload files
require 'net/ftp'
CONTENT_SERVER_DOMAIN_NAME = "one-of-the-ftp-server.thought-sauce.com.hk"
CONTENT_SERVER_FTP_LOGIN = "saucy-ftp-server-login"
CONTENT_SERVER_FTP_PASSWORD = "saucy-ftp-server-password"
# LOGIN and LIST available files at default home directory
Net::FTP.open(CONTENT_SERVER_DOMAIN_NAME, CONTENT_SERVER_FTP_LOGIN, CONTENT_SERVER_FTP_PASSWORD) do |ftp|
files = ftp.list
@ZephiroRB
ZephiroRB / pretty_title.rb
Created February 13, 2018 04:30
Pretty title
#application_helper.rb
def title(page_title)
content_for(:title) { page_title }
end
#layouts/application.html
<title>Shoppery - <%= yield(:title) || "The Place to Buy Stuff" %></title>
@ZephiroRB
ZephiroRB / 20160216211105_create_images.rb
Created February 18, 2018 00:20 — forked from dannyvassallo/20160216211105_create_images.rb
Use tinymce-rails & tinymce-rails-imageupload with carrierwave & fog
# db/migrate/filename.rb
# generate with >> rails g model image alt:string hint:string file:string
class CreateImages < ActiveRecord::Migration[5.0]
def change
create_table :images do |t|
t.string :alt
t.string :hint
t.string :file