Skip to content

Instantly share code, notes, and snippets.

@just3ws
just3ws / .skhdrc
Created Nov 28, 2020
Yabai + SKHD config to emulate SizeUp
View .skhdrc
# SizeUp: Send Window Left
ctrl + alt + cmd - left : yabai -m window --grid 1:2:0:0:1:1
# SizeUp: Send Window Right
ctrl + alt + cmd - right : yabai -m window --grid 1:2:1:0:1:1
# SizeUp: Send Window Up
ctrl + alt + cmd - up : yabai -m window --grid 2:1:0:0:1:1
# SizeUp: Send Window Down
@just3ws
just3ws / bohater-parkingu.yaml
Last active Jun 10, 2018
Bohater Parkingu API 1.0.1
View bohater-parkingu.yaml
---
openapi: 3.0.0
servers:
- description: Bohater Parkingu Rates API
url: https://virtserver.swaggerhub.com/just3ws/bohater-parkingu/1.0.1
info:
description: Parking rate for a given date and time range.
version: "1.0.1"
title: Bohater Parkingu API
contact:
@just3ws
just3ws / gogodoots.zsh
Created Mar 20, 2018
Script to easily run multiple queries for types of files and dump them to a simplified JSON string.
View gogodoots.zsh
#!/usr/bin/env zsh
# vim:set ft=zsh:
local word="$1"
local filter=".items[] | { repository: .full_name, username: .owner.login, reponame: .name, branch: .default_branch, description: .description }"
local query="q=$word in:path fork:false"
# local query="q=evil fork:false language:\"Emacs Lisp\""
echo -n '{"query": "'
echo -n "$query"
echo '"}'
@just3ws
just3ws / floodwall.rb
Last active Oct 13, 2017
Blocks that know where their towel is.
View floodwall.rb
# Rails.configuration.permit_automated_emails = true
class Floodwall
def initialize(context, bypass = false, **data, &action)
@context = context
@data = OpenStruct.new(data || {})
@permit = Rails.configuration.permit_automated_emails || bypass || false
Rails.logger.warn { 'Floodwall has been bypassed and will allow emails through' } if bypass
@just3ws
just3ws / methods.rb
Last active Oct 13, 2017
Methods and stuff
View methods.rb
class Foo
attr_reader :env
def initialize
@env = 'staging' # Rail.env
end
def bar
warninger(biz: 123, buz: 'Hello', baz: Object.new)
end
@just3ws
just3ws / Enable Logging Insight in Postgres.md
Created Sep 15, 2017
Enable Logging Insight in Postgres
View Enable Logging Insight in Postgres.md
vim /usr/local/var/postgres/postgresql.conf

At the end of the file add...

shared_preload_libraries 'pg_stat_statements,auto_explain' # Add settings for extensions here
@just3ws
just3ws / config-initializers-action_controller-notifications.rb
Created Sep 15, 2017
ActiveSupport Notification Subscribers for ActionController and ActiveRecord Events
View config-initializers-action_controller-notifications.rb
unless Rails.env.production?
ActiveSupport::Notifications.subscribe(/\A.*\.action_controller\z/) do |*args|
ts = Time.now.iso8601
event = ActiveSupport::Notifications::Event.new(*args)
event_name, source_name = event.name.split('.')
unless event_name == 'unpermitted_parameters'
log_file = "#{source_name.tr('_', '-')}-notifications.log"
logger = ActiveSupport::TaggedLogging.new(Logger.new(Rails.root.join('log', log_file)))
@just3ws
just3ws / RSpec tags and opts for easier test execution.md
Created Aug 17, 2017
RSpec tags and opts for easier test execution
View RSpec tags and opts for easier test execution.md

To easily limit the execution of RSpec tests while you are developing use the power of the .rspec opts file and RSpec tags.

Tags can be added to any RSpec method describe, context, it, etc.

The are simply arguments passed as a Hash to the method.

describe 'foo', focus: true do
 context 'bar', slow: true do
View c-p-and-me.txt
yyyyy/:oyyyysyyyyyyyyyysssoooo+++++//+///+/+++++/++oosso/:::+++++ooooossyyyyysssssso+:----.````````````-+ssyyyyyyysssssss/-/hyyyyyyyyyyyyyyyssssssssss+-:yhhhhhhhhhhhhhyyyyyysss+..+so++//:+sdNNNNMMMMMMMMMMMMMMMMMMMMMMMMMNNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNNNNNNNNNmmdhydddy///++/---:-:--/ossoossssyyyyyyyyhho+syyssssoooooo+++++//////:::---::::::://+++++ooo++++++/++/://++++++oooo+/-.:/:.-/::/:://:.:--+oo++oosssoossyssshyyyysossyyhysyyyyyysysoso+oo+ss++++so:.-:::--+:::://-//:--//::+syy
yyyyy+-/yyyyyyyyyyyyyyyyyyyyyyyyyys//ssssssssossssssssso/--:++oo+ooooosysyyyyyyyyyyys/-----````````````.:/:::::::///++oss/-/yyyhhyyyyyyyyyyyssyyssssss+-:shhhhhhhhhhhhhhhhhhyyyyo-.ohyhhyhdmNMNNNMMMMMMMMMMMMMMMMMMMMMMMMMMNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNNNNNNNNmdhhhhys:-o+//----::-:+ooossssyyyyyyyyyhhhys+sssssssooooooo+++///:::::---.---::::////+++++++++++///////++++++++++++++:..:/--.//:/:::::--:-/ooooo+sysssshhsyyyssysyyhhyyyyyyysssyysoooo+ooo++/+::++::+o+/:+o++/-+oo++++ooo++/sy
yyyyy+-/yyyyyyyyyyyyyy
@just3ws
just3ws / explain_explained_notes.md
Created Apr 19, 2017
Postgres EXPLAIN Lunch & Learn @ BenchPrep
View explain_explained_notes.md

Postgres EXPLAIN Lunch & Learn @ BenchPrep

EXPLAIN Explained video on YouTube

What EXPLAIN doesn't do

  • Tell you why a particular index isn't used
  • Explain how to rewrite your queries
  • Show what other factors make the DB slow
  • Tell you how much time the request took outside the DB