Skip to content

Instantly share code, notes, and snippets.

View zzidante's full-sized avatar

Zzi/Mel zzidante

  • Vancouver
View GitHub Profile
@zzidante
zzidante / exclude.sql
Created November 3, 2022 17:24 — forked from fphilipe/exclude.sql
PostgreSQL EXCLUDE constraint
CREATE EXTENSION btree_gist;
CREATE TABLE room_reservations (
room_id integer,
reserved_at timestamptz,
reserved_until timestamptz,
canceled boolean DEFAULT false,
EXCLUDE USING gist (
room_id WITH =, tstzrange(reserved_at, reserved_until) WITH &&
) WHERE (not canceled)
@zzidante
zzidante / README.md
Created May 17, 2022 22:17 — forked from joyrexus/README.md
collapsible markdown

collapsible markdown?

CLICK ME

yes, even hidden code blocks!

print("hello world!")
@zzidante
zzidante / CHRUBY_add_ruby_version.md
Created February 14, 2022 04:16 — forked from yannvery/CHRUBY_add_ruby_version.md
CHRUBY - How to install a new ruby version

Install a new ruby version with chruby

OSX

First of all you must update ruby-build to update definitions list.

brew update

And update ruby-build

@zzidante
zzidante / install_ruby_rpi.sh
Created May 16, 2019 06:07 — forked from blacktm/install_ruby_rpi.sh
A Bash script to install Ruby 2.6 on the Raspberry Pi (Raspbian)
#!/bin/bash
# --------------------------------------------------------------------------------------------
# Installs Ruby 2.6 using rbenv/ruby-build on the Raspberry Pi (Raspbian)
#
# Run from the web:
# bash <(curl -s https://gist.githubusercontent.com/blacktm/8302741/raw/install_ruby_rpi.sh)
# --------------------------------------------------------------------------------------------
# Welcome message
@zzidante
zzidante / Rakefile
Created April 20, 2019 04:59
Sequel Rake tasks for a Sinatra app
# change foo to your library name
# change Foo::Database to your Sequel database
namespace :bundler do
task :setup do
require 'rubygems'
require 'bundler/setup'
end
end
@zzidante
zzidante / Hash Keys to Symbols.rb
Created January 30, 2019 21:54 — forked from Integralist/Hash Keys to Symbols.rb
Convert Ruby Hash keys into symbols
hash = { 'foo' => 'bar' }
# Version 1
hash = Hash[hash.map { |k, v| [k.to_sym, v] }]
# Version 2
hash = hash.reduce({}) do |memo, (k, v)|
memo.tap { |m| m[k.to_sym] = v }
end

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger

<!DOCTYPE HTML>
<html>
<head>
<style>
body {
margin: 0px;
padding: 0px;
}
</style>
</head>