Skip to content

Instantly share code, notes, and snippets.

@mando
mando / OTDC.md
Last active December 12, 2023 14:40
Old Timer Drinking Club

Y'all, I'm feeling awful wistful and nostalgic these days.

For a bit, I thought I missed the old days of Austin on Rails but, just between you and me, I just miss y'all. I miss spending an evening at the pub with you folks, dishing that hot goss and planning schemes and dreaming big dreams.

It's no secret what happened - life and kids and work and shifts in priority. I get it. We all get it.

You can't step into the same river twice, said Heraclitus. I say we prove that jerk wrong.

Let's get together and sit and drink and talk and think and scheme and dream - add a comment if you're interested along with dates and times that work for you. This ain't a democracy but we can do our best to accomodate the most we can. This also ain't exclusionary - if you're reading this and don't feel like you were a part of the OG AoR scene but for some reason want to join us, you're heckin invited too. I've got a drink and a smile for all y'all.

# In case anyone is wondering how to easily use the :crypto hash or hmac API's from elixir-land, here you go.
File.stream!(filename, [:read, {:read_ahead, 65535}], 65535)
|> Enum.reduce(:crypto.hash_init(:sha), &:crypto.hash_update(&2, &1))
|> :crypto.hash_final
|> Base.encode16
# Line 3 opens up a stream, and we're reading in 64KB chunks from the FS which is roughly pretty efficient
# In line 4, we initialize our hash (which returns a context) and put that as the default value in the reducer
# The hash_update in the reducer returns the modified context. Remember arg1 is the item, and arg2 is the accumulator
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active May 10, 2024 17:12
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
def revoke(user)
proxy_association.owner.tap do |project|
# You can't remove the last user with access (someone has to have access to the project!)
if project.users.many?
if user.pending? && user.projects.one?
user.destroy
else
project.users.delete(user)
user.touch
end
@ssoroka
ssoroka / acceptance_helper.rb
Created May 30, 2011 05:45
Use feature, background, and scenario blocks to write acceptance tests in test/unit
# Use feature, background, and scenario blocks to write acceptance tests in test/unit
# which are really just integration tests. include capybara or webrat or something and voila.
# test/acceptance_helper.rb
require 'test_helper'
module ActionDispatch
class AcceptanceTest < ActionDispatch::IntegrationTest
class << self
alias :background :setup