Skip to content

Instantly share code, notes, and snippets.

View nicolrx's full-sized avatar

nico_lrx nicolrx

View GitHub Profile
@nicolrx
nicolrx / google_index_worker.rb
Created February 5, 2024 15:19
Ruby on Rails Worker to Check in Google Search Console for pages that are not indexed. Then, a worker to index the page.
class GoogleIndexWorker
include Sidekiq::Worker
sidekiq_options retry: 0
require "google/apis/indexing_v3"
require 'google/apis/webmasters_v3'
include Rails.application.routes.url_helpers
# launch worker with your sitemap URL
def perform(sitemap_url)
@MarceloCajueiro
MarceloCajueiro / script.rb
Created July 17, 2018 11:50
Move sidekiq jobs from one queue to another
queue = Sidekiq::Queue.new("default")
queue.each do |job|
if job.klass == "DailyFrequencyCreatorWorker"
DailyFrequencyCreatorWorker.set(queue: 'daily_frequency_creator').perform_async(*job.args)
job.delete
end
end;nil
@levelsio
levelsio / btc-eth-dca-buy.php
Last active January 21, 2025 12:12
This script runs daily and "Dollar Cost Average"-buys $40 BTC and $10 ETH per day
<?
//
// [ BUY BTC & ETH DAILY ON BITSTAMP ]
// by @levelsio
//
// 2017-08-23
//
// 1) buy $40/day BTC
// 2) buy $10/day ETH
//
@shad1w
shad1w / rails_subdir_deploy.md
Last active February 23, 2025 13:34
Deploying a rails application in a subdirectory

Making a Rails application deployable in a subdirectory

USE THIS GUIDE AT YOUR OWN RISK! I AM NOT RESPONSIBLE FOR ANYTHING YOU DO BY FOLLOWING THIS GUIDE! IF ANY DAMAGE IS DONE BY FOLLOWING THE INSTRUCTIONS HERE, IT IS ENTIRELY YOUR RESPONSIBILITY AND I MAY NOT BE HELD LIABLE FOR IT!

Using this guide, you can make it possible to put your Ruby on Rails application behind a reverse proxy in a subdirectory.
This guide was written for Rails 5.

Prerequisites

Using this method, the environment variable RAILS_RELATIVE_URL_ROOT should not be set.

#
# Building an MVP?
# Need a quick database you can set up in seconds?
# What about JSON?
#
# by @levelsio (with help from @marckohlbrugge, @oskarth, @maxdeviant and @kumailht)
# JS
db=[]
fs=require('fs')
@slavikdev
slavikdev / cheatsheet.md
Last active January 1, 2025 15:03
Rails request path cheatsheet

Rails request path cheatsheet

Full path with query string

>>  request.url
=> "http://localhost:3000/ask-help.amp?ptn=pnh"

Virtual path without query string

>>  request.path
=&gt; "/ask-help.amp"
@willwright82
willwright82 / db_pull.rake.rb
Created July 6, 2016 08:39
Pulling the production database to your local development database (Rails + Postgres)
# lib/tasks/db_pull.rake
# via https://martinschurig.com/posts/2015/02/pulling-production-database-to-local-machine-rails-task/
namespace :db do
desc 'Pull production db to development'
task :pull => [:dump, :restore]
task :dump do
dumpfile = "#{Rails.root}/tmp/latest.dump"
puts 'PG_DUMP on production database...'
production = Rails.application.config.database_configuration['production']
@thebucknerlife
thebucknerlife / authentication_with_bcrypt_in_rails_4.md
Last active March 12, 2025 18:03
Simple Authentication in Rail 4 Using Bcrypt

#Simple Authentication with Bcrypt

This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.

The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).

You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault

##Steps

@hofmannsven
hofmannsven / README.md
Last active April 1, 2025 06:51
Git CLI Cheatsheet
@mscoutermarsh
mscoutermarsh / gist:3927973
Created October 21, 2012 18:21
Send user email in their timezone
# Set zone to the users time zone
Time.zone = user.time_zone
# convert time to UTC
user_time_to_utc = Time.zone.parse('2012-10-22 09:25:00').utc
puts "Scheduling for #{user.login} at #{user_time_to_utc}"
# Schedule the sidekiq job
SendPromoEmail.perform_at(user_time_to_utc,user.id)