Skip to content

Instantly share code, notes, and snippets.

View Alphabetus's full-sized avatar
🎯
Focusing

Diogo Gomes Alphabetus

🎯
Focusing
View GitHub Profile
@Alphabetus
Alphabetus / index.html
Last active December 26, 2018 21:13
html1.2 >> notes made for ckaltenbach904
<!DOCTYPE html>
<html lang="en">
<head>
<!-- <link rel="stylesheet" href="../css/styles.css"> -->
<!-- NOTE:
All i needed was to disable this line. let me explain why.
you are calling ../css/styles.css
the term `..` referrs to the folder 1 level above in the tree.
your tree looks like this:
@Alphabetus
Alphabetus / geo_distance.js
Last active March 13, 2019 14:12 — forked from ed-flanagan/geo_distance.js
Great-circle distance formulas in JavaScript
var earth_radius_km = 6371.0;
function deg_to_rad(deg) {
return (deg * Math.PI / 180.0);
}
function haversine_distance(latitude1, longitude1, latitude2, longitude2) {
var lat1 = deg_to_rad(latitude1);
var lng1 = deg_to_rad(longitude1);
var lat2 = deg_to_rad(latitude2);
# 1. Clear retry set
Sidekiq::RetrySet.new.clear
# 2. Clear scheduled jobs
Sidekiq::ScheduledSet.new.clear
# 3. Clear 'Processed' and 'Failed' jobs
@Alphabetus
Alphabetus / redis.rb
Last active September 18, 2019 09:55 — forked from pubis/redis.rb
Redis config and initialization for rails
#config/initializers/redis.rb
require 'redis'
require 'redis/objects'
REDIS_CONFIG = YAML.load( File.open( Rails.root.join("config/redis.yml") ) ).symbolize_keys
dflt = REDIS_CONFIG[:default].symbolize_keys
cnfg = dflt.merge(REDIS_CONFIG[Rails.env.to_sym].symbolize_keys) if REDIS_CONFIG[Rails.env.to_sym]
$redis = Redis.new(cnfg)
Redis::Objects.redis = $redis
@Alphabetus
Alphabetus / async_rake.rb
Created September 19, 2019 08:44 — forked from tompave/async_rake.rb
how to run rake tasks asynchronously from controllers by spawning child processes
class ApplicationController < ActionController::Base
def perform_async(task, options = {})
options[:rails_env] ||= Rails.env
env_vars = options.map { |key, value| "#{key.to_s.upcase}='#{value.to_s}'" }
env_vars_string = env_vars.join(' ')
Process.fork {exec("#{env_vars_string} bin/rake #{task}")}
end
end
@Alphabetus
Alphabetus / __readme.md
Created February 20, 2020 15:38 — forked from maxivak/__readme.md
Tree with ancestry. Rails

Contents:

  • show full path for the item
  • show tree in ol li
  • show tree in dropdown select

Show full path for item

  • one item
@Alphabetus
Alphabetus / javascript:number_to_currency
Created May 21, 2021 14:17 — forked from zaagan/javascript:number_to_currency
javascript: number to currency. Rails like
function number_to_currency(number, options) {
try {
var options = options || {};
var precision = options["precision"] || 2;
var unit = options["unit"] || "$";
var separator = precision > 0 ? options["separator"] || "." : "";
var delimiter = options["delimiter"] || ",";
var parts = parseFloat(number).toFixed(precision).split('.');
return unit + number_with_delimiter(parts[0], delimiter) + separator + parts[1].toString();
@Alphabetus
Alphabetus / main.rb
Created January 5, 2022 19:16 — forked from amirrajan/main.rb
DragonRuby Game Toolkit - Sand Simulation via Cellular Automata
class Elements
def initialize size
@size = size
@max_x_ordinal = 1280.idiv size
@element_lookup = {}
@elements = []
end
def add_element x_ordinal, y_ordinal
return nil if @element_lookup.dig x_ordinal, y_ordinal