Skip to content

Instantly share code, notes, and snippets.

View pmargreff's full-sized avatar

Pablo M pmargreff

  • Earth
View GitHub Profile
@pmargreff
pmargreff / strava.rb
Created January 24, 2023 01:38
Updating your strava activities to use a given gear
gem 'strava-ruby-client'
require 'strava-ruby-client'
client = Strava::Api::Client.new(
access_token: "access_code"
)
#time interval to update
after = Time.new(2022, 1, 1).to_i
# running tests against all changed spec files
git status | grep 'spec' | sed -e "s/modified: //" | bundle exec rspec
@pmargreff
pmargreff / gist:2f7c7d6f0cf8a484051f5c759de4cbd3
Created November 4, 2020 18:16
copy-jira-tasks-by-sprint-id.js
var list = [];
$('[data-sprint-id=<REPLACE HERE>] .ghx-summary .ghx-inner').each((e, node)=>{ list.push(node.innerHTML.replace(/"/g, "'"))})
list.join("\n")
require "test/unit/assertions"
include Test::Unit::Assertions
def quick_sort(array)
return array if array.size == 0 || array.size == 1
left_pointer = 0
pivot = array.last
pivot_index = array.size - 1
@pmargreff
pmargreff / with_inspect.out
Created November 30, 2019 17:33
Absinthe call inspect with 10k registers
FUNCTION CALLS % TIME [uS / CALLS]
-------- ----- ------- ---- [----------]
io:o_request/3 1 0.00 0 [ 0.00]
io:put_chars/2 1 0.00 0 [ 0.00]
io:put_chars/3 1 0.00 0 [ 0.00]
io:request/2 2 0.00 0 [ 0.00]
io:execute_request/2 1 0.00 0 [ 0.00]
'Elixir.Plug.Session':call/2
@pmargreff
pmargreff / 10k_flatten.out
Created November 2, 2019 18:44
Graphql response problem
query {
books {
title
}
}
FUNCTION CALLS % TIME [uS / CALLS]
-------- ----- ------- ---- [----------]
'Elixir.Plug.Session':call/2 1 0.00 0 [ 0.00]
'Elixir.Application':get_env/2 1 0.00 0 [ 0.00]
@pmargreff
pmargreff / reassign_owner.sql
Last active October 30, 2019 18:35
Create queries to reset postgres database owners (excluding protected schemas/tables).
SELECT 'ALTER TABLE '|| schemaname || '.' || tablename ||' OWNER TO username;'
FROM pg_tables WHERE NOT schemaname IN ('pg_catalog', 'information_schema')
ORDER BY schemaname, tablename;
SELECT 'ALTER SEQUENCE '|| sequence_schema || '.' || sequence_name ||' OWNER TO username;'
FROM information_schema.sequences WHERE NOT sequence_schema IN ('pg_catalog', 'information_schema')
ORDER BY sequence_schema, sequence_name;
SELECT 'ALTER VIEW '|| table_schema || '.' || table_name ||' OWNER TO username;'
FROM information_schema.views WHERE NOT table_schema IN ('pg_catalog', 'information_schema')
@pmargreff
pmargreff / .tmux.conf
Last active September 24, 2021 11:47
unbind C-b
set -g prefix C-t
unbind '"'
bind-key h split-window -h -c '#{pane_current_path}'
unbind %
bind-key v split-window -v -c '#{pane_current_path}'
unbind [
unbind n
@pmargreff
pmargreff / postgres.sql
Last active November 22, 2018 18:41
postgres utils
# list last vacuum e autovacuum time on each table
SELECT relname, last_vacuum, last_autovacuum FROM pg_stat_user_tables;
# Tools
# Explain explained
# https://explain.depesz.com/
# Articles
# How analyze works:
# https://www.depesz.com/2013/04/16/explaining-the-unexplainable/
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->