Skip to content

Instantly share code, notes, and snippets.

@just3ws
just3ws / all.sql
Last active April 12, 2017 14:34
Refactoring Postgres Queries
explain (analyze on, buffers on, verbose on, timing on)
select l.id, l.simulation_id, l.user_id, l.content_package_id, l.score, l.result, l.total_time_taken, l.created_at, l.updated_at
from simulation_results l
inner join (
select simulation_id, max(created_at) created_at
from simulation_results
where user_id = 827911
group by simulation_id
) r
on l.simulation_id = r.simulation_id and l.created_at = r.created_at
@just3ws
just3ws / building_up_module_declarations.sh
Last active April 5, 2017 21:32
Inline vs Nested Ruby Module Declarations
ruby -W2 -v -e ' (ruby-2.2.2@benchprep) wip-simulation-endpoints 9a603b95e ✗
puts "before"
module Foo
puts "- Foo -"
end
puts "more"
module Foo::Bar
puts "- Foo::Bar -"
end
@just3ws
just3ws / refresh-ruby-repo.zsh
Last active March 9, 2017 14:34
Update git repos and install bundler if not present
echo "BEGIN updating: $(pwd)"
cd "$1/.."
git fetch --all --prune --verbose
[[ -a Gemfile && "$(gem query --installed '^bundler$')" == 'false' ]] && gem install bundler --no-document
bundle check || bundle install
@just3ws
just3ws / getting rubygems to work with libv8 on el capitan.sh
Created April 28, 2016 16:41
Getting RubyGems that depend on an older libv8 to work with El Capitan OS X
brew tap homebrew/versions
brew install v8-315
brew unlink v8-315 && brew link v8-315
brew link --force v8-315
bundle config --global build.libv8 --with-system-v8
bundle install --full-index --jobs 4 --clean
@just3ws
just3ws / its_all_just_about_the_view.rb
Created April 20, 2016 15:53
Customizing logic for use by logger
# Simple logger
logger = Logger.new(STDOUT)
# Some object
Foo = Struct.new(:hello, :goodbye)
foo = Foo.new
foo.hello = 'Hola'
foo.goodbye = 'Adiós'
@just3ws
just3ws / forwards_from_grannie.rb
Last active September 1, 2015 17:24
FW: FW: FW:
require 'forwardable'
class Said
attr_reader :msg
def initialize(msg = nil)
@msg = (msg || '').freeze
end
def loud_enough?
@just3ws
just3ws / de_morgans_laws.rb
Last active November 20, 2018 15:22
De Morgan's laws (in Ruby)
puts "<< De Morgan's laws >>\n\n"
PAIRS = [
[false, true],
[true, false],
[true, true],
[false, false]
]
puts "\"NOT (A AND B)\" is the same as \"(NOT A) OR (NOT B)\""
The original works were financially inert. They were posted out on the web for anyone to see them.
An artist sees the works, likes them.
Takes those selected works, enlarges, fine-tunes, prints, frames, and displays the works inside a context.
The artist then puts those pieces on display and for sale.
What is for sale?
@just3ws
just3ws / toggle-assume-changeable.sh
Created May 20, 2015 14:19
Toggle a file from it's local changes being recognized by Git
git-assume-unchangeable () {
git update-index --assume-unchanged "$@"
}
git-assume-changeable () {
git update-index --no-assume-unchanged "$@"
}
git-show-unchangeable () {
git ls-files -v | grep -e "^[hsmrck]"
@just3ws
just3ws / keybase.md
Created March 13, 2015 15:23
Hi, my name is @just3ws

Keybase proof

I hereby claim:

  • I am just3ws on github.
  • I am just3ws (https://keybase.io/just3ws) on keybase.
  • I have a public key whose fingerprint is E399 41FC 8751 D07A F31F 5BD2 19FE 986E 901E 4A5F

To claim this, I am signing this object: