CLICK ME
yes, even hidden code blocks!
print("hello world!")
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) |
#!/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 |
// Run the file `node simple_and_fake_jasmine_describe_it_expect_equalsto_pattern.js` from containing folder. | |
// Should receive 1 passing and 1 failing test (as noted by text color -> Green/Red). | |
// To understand: read from the call site and work backwards. | |
// -- Fancy console printing like tests do (no emojis yet) -- // | |
const printToConsole = function(text, status = 'normal', padding = false) { | |
const CC = { | |
Reset: '\x1b[0m', | |
Underscore: '\x1b[4m', | |
FgRed: '\x1b[31m', |
// A super simple no-edge case version of the `expect` function | |
// as seen in mocha/jasmine test environments. | |
// Long form | |
// step one: define a function called `expect` which takes one value. | |
// This value is intended to be the return value of a function. | |
const expect = function(actualValue) { | |
// assign a property onto `expect` called 'equalsTo' which is | |
// itself a function taking one argument (using `this` keyword |
# 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 |
def floatify_string?(val) | |
# if its already a number type, return it | |
return val if (val.class == Integer || val.class == Float) | |
# pre-match zero so that we can initially weed out all no-numeric strings as unparseable | |
return 0.0 if val == "0" || val == "0.0" | |
return nil if val.to_f == 0.0 # "Hello".to_f => 0.0 | |
# only match float-like looking values: "1.0" => 1.0, "1" => 1.0, "0.001" => 0.001, "01345345" => 1345345.0 | |
return val.to_f if val =~ /^[-+]?[0-9]*\.?[0-9]+$/ |
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 |
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 sessionDebugger