Skip to content

Instantly share code, notes, and snippets.

View marcotc's full-sized avatar

Marco Costa marcotc

View GitHub Profile
@marcotc
marcotc / find_new_tfsa_limit.rb
Created December 6, 2017 20:51
Finds latest TFSA limit published by CRA
require 'wombat'
require 'date'
data = Wombat.crawl do
base_url "https://www.canada.ca"
path "/en/revenue-agency/services/tax/individuals/frequently-asked-questions-individuals/adjustment-personal-income-tax-benefit-amounts.html"
limit xpath: "/html/body/main/div[1]/div[2]/div/table/tbody/tr[45]/td[2]"
year css: ".active > th:nth-child(2)"
end
@marcotc
marcotc / clear_ar_cache.rb
Created October 3, 2017 20:52
Clear ActiveRecord cache
ActiveRecord::Base.connection.query_cache.clear
@marcotc
marcotc / current_queries.sql
Last active September 25, 2017 16:53
Retrieve and kill current Postgres queries
SELECT pid, age(query_start, clock_timestamp()), state, query FROM pg_stat_activity WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' and state = 'active' ORDER BY age(query_start, clock_timestamp());
--select pg_cancel_backend(123456);-- Kill by PID
@marcotc
marcotc / tf2items.weapons.txt
Last active April 30, 2017 05:57
tf2items.weapons.txt
"custom_weapons_v3"
{
// For reference: "1" "280 ; 2" // Change projectile to rocket
"*"
{
// Demoman
"308" // Loch-n-load
{
"1" "280 ; 2"
"2" "3 ; 0.75"
@marcotc
marcotc / FastClicker.ico
Last active April 10, 2017 01:58
Fast Mouse Clicker icon
@marcotc
marcotc / sidekiq_retry_time.csv
Created February 14, 2017 18:16
Sidekiq retry exponential backoff formula times
Retry count Retry Time Total Cumulative Time Total Cumulative Days
0 0:00:00 0:00:00 0.0
1 0:00:16 0:00:16 0.0
2 0:00:31 0:00:47 0.0
3 0:01:36 0:02:23 0.0
4 0:04:31 0:06:54 0.0
5 0:10:40 0:17:34 0.0
6 0:21:51 0:39:25 0.0
7 0:40:16 1:19:41 0.1
8 1:08:31 2:28:12 0.1
@marcotc
marcotc / fix-ruby-readline.sh
Created January 11, 2017 22:14
Fix ruby readline version mismatch on MacOS with homebrew
brew update && brew upgrade
for i in `rbenv versions --bare|xargs`; do rbenv install -f $i && RBENV_VERSION=$i gem pristine --all; done
@marcotc
marcotc / test.ipynb
Last active January 10, 2017 04:05
Test
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@marcotc
marcotc / query.rb
Last active December 8, 2017 22:59
Run arbitrary query using ActiveRecord
ActiveRecord::Base.connection.exec_query("select * from TABLE")
@marcotc
marcotc / nbt_parser.yaml
Last active December 12, 2016 03:01
Parser for Named Binary Tag (NBT), in Kaitai format (http://kaitai.io/)
meta:
id: nbt
file-extension: nbt
endian: be
application: Named Binary Tag (NBT)
seq:
- id: tag_compound
type: tag_compound
types:
tag_byte: