Skip to content

Instantly share code, notes, and snippets.

Ri Caragol ritec

Block or report user

Report or block ritec

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ritec
ritec / blank.html
Created Sep 30, 2019 — forked from geetarista/blank.html
Blank favicon
View blank.html
<link href="data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQEAYAAABPYyMiAAAABmJLR0T///////8JWPfcAAAACXBIWXMAAABIAAAASABGyWs+AAAAF0lEQVRIx2NgGAWjYBSMglEwCkbBSAcACBAAAeaR9cIAAAAASUVORK5CYII=" rel="icon" type="image/x-icon" />
@ritec
ritec / import_job.rb
Created Jun 4, 2019 — forked from madebydna/import_job.rb
Nested Batch workflow with Sidekiq Pro
View import_job.rb
class ImportJob
include Sidekiq::Worker
sidekiq_options :queue => :import, :retry => false, :backtrace => true
def perform(project_id)
# create master batch
a = Sidekiq::Batch.new
a.description = "Master Batch A"
a.on(:success, "ImportJob#on_success", {"step" => "a"})
logger.info "Master Batch A starting #{a.bid}"
@ritec
ritec / libreadline_6_not_found.sh
Last active Mar 25, 2019 — forked from wbotelhos/libreadline_6_not_found.sh
Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib (LoadError)
View libreadline_6_not_found.sh
ln -s /usr/local/opt/readline/lib/libreadline.7.0.dylib /usr/local/opt/readline/lib/libreadline.6.dylib
# or if the error is with dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib
ln -s /usr/local/opt/readline/lib/libreadline.8.0.dylib /usr/local/opt/readline/lib/libreadline.7.dylib
@ritec
ritec / harlem_shake.js
Created Aug 20, 2018
Harlem Shake XSS
View harlem_shake.js
javascript:(function(){function c(){var e=document.createElement("link");e.setAttribute("type","text/css");e.setAttribute("rel","stylesheet");e.setAttribute("href",f);e.setAttribute("class",l);document.body.appendChild(e)}function h(){var e=document.getElementsByClassName(l);for(var t=0;t<e.length;t++){document.body.removeChild(e[t])}}function p(){var e=document.createElement("div");e.setAttribute("class",a);document.body.appendChild(e);setTimeout(function(){document.body.removeChild(e)},100)}function d(e){return{height:e.offsetHeight,width:e.offsetWidth}}function v(i){var s=d(i);return s.height>e&&s.height<n&&s.width>t&&s.width<r}function m(e){var t=e;var n=0;while(!!t){n+=t.offsetTop;t=t.offsetParent}return n}function g(){var e=document.documentElement;if(!!window.innerWidth){return window.innerHeight}else if(e&&!isNaN(e.clientHeight)){return e.clientHeight}return 0}function y(){if(window.pageYOffset){return window.pageYOffset}return Math.max(document.documentElement.scrollTop,document.body.scrollTop)}funct
@ritec
ritec / Postgres info
Last active Mar 8, 2018
usefulPostgresInfo.sql
View Postgres info
# Get a DB Console.
bundle exec rails dbconsole
# Get number of Connections / Used and left
select max_conn,used,res_for_super,max_conn-used-res_for_super res_for_normal
from
(select count(*) used from pg_stat_activity) t1,
(select setting::int res_for_super from pg_settings where name=$$superuser_reserved_connections$$) t2,
(select setting::int max_conn from pg_settings where name=$$max_connections$$) t3
@ritec
ritec / 01_thread.rb
Created Mar 8, 2018 — forked from rsim/01_thread.rb
Code examples from my "Using threads in Ruby applications" presentation in our local Ruby meetup http://www.meetup.com/ruby-on-rails-latvia/events/105142132/
View 01_thread.rb
Thread.new do
sleep 5
puts "finished"
end
thread = Thread.new do
sleep 5
puts "finished"
end
thread.join
@ritec
ritec / sidekiq_monitoring
Created Feb 28, 2018 — forked from ngsmrk/sidekiq_monitoring
Sidekiq queue checking via rails console
View sidekiq_monitoring
stats = Sidekiq::Stats.new
stats.queues
stats.enqueued
stats.processed
stats.failed
@ritec
ritec / user_agent.sql
Created Jan 11, 2018
New Relic Percentage User Agent
View user_agent.sql
select percentage(uniquecount(session), where userAgentName = 'Chrome') as 'Chrome', percentage(uniquecount(session), where userAgentName = 'Firefox') as 'FireFox', percentage(uniquecount(session), WHERE userAgentName='IE') as 'IE' , percentage(uniquecount(session), WHERE userAgentName ='Safari') as 'Safari' from PageView SINCE 600 minutes ago
@ritec
ritec / bench_rails_memory_usage.rb
Created Dec 10, 2017 — forked from brianhempel/bench_rails_memory_usage.rb
A script to test the memory usage of your Rails application over time. It will run 30 requests against the specified action and report the final RSS. Choose the URL to hit on line 45 and then run with `ruby bench_rails_memory_usage.rb`.
View bench_rails_memory_usage.rb
require "net/http"
def start_server
# Remove the X to enable the parameters for tuning.
# These are the default values as of Ruby 2.2.0.
@child = spawn(<<-EOC.split.join(" "))
XRUBY_GC_HEAP_FREE_SLOTS=4096
XRUBY_GC_HEAP_INIT_SLOTS=10000
XRUBY_GC_HEAP_GROWTH_FACTOR=1.8
XRUBY_GC_HEAP_GROWTH_MAX_SLOTS=0
View generate.rake
require 'fileutils'
namespace :spec do
def progress name, x, y
print "\r #{name}: #{x}/#{y} %6.2f%%" % [x.to_f/y * 100]
end
def generate_files name
kind = name.to_s.singularize
collection = Dir.glob Rails.root.join('app',name.to_s,'**','*').to_s
You can’t perform that action at this time.