Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Diogo Gomes Alphabetus

🎯
Focusing
View GitHub Profile
@Alphabetus
Alphabetus / __readme.md
Created Feb 20, 2020 — forked from maxivak/__readme.md
Tree with ancestry. Rails
View __readme.md

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 / async_rake.rb
Created Sep 19, 2019 — forked from tompave/async_rake.rb
how to run rake tasks asynchronously from controllers by spawning child processes
View async_rake.rb
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 / redis.rb
Last active Sep 18, 2019 — forked from pubis/redis.rb
Redis config and initialization for rails
View redis.rb
#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
View clear-sidekiq-jobs.sh
# 1. Clear retry set
Sidekiq::RetrySet.new.clear
# 2. Clear scheduled jobs
Sidekiq::ScheduledSet.new.clear
# 3. Clear 'Processed' and 'Failed' jobs
@Alphabetus
Alphabetus / geo_distance.js
Last active Mar 13, 2019 — forked from ed-flanagan/geo_distance.js
Great-circle distance formulas in JavaScript
View geo_distance.js
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);
@Alphabetus
Alphabetus / index.html
Last active Dec 26, 2018
html1.2 >> notes made for ckaltenbach904
View index.html
<!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:
You can’t perform that action at this time.