Skip to content

Instantly share code, notes, and snippets.

View gffcoutinho's full-sized avatar

Guilherme Coutinho gffcoutinho

View GitHub Profile
@schickling
schickling / Rakefile
Last active January 31, 2024 23:00
Activerecord without Rails
require "active_record"
namespace :db do
db_config = YAML::load(File.open('config/database.yml'))
db_config_admin = db_config.merge({'database' => 'postgres', 'schema_search_path' => 'public'})
desc "Create the database"
task :create do
ActiveRecord::Base.establish_connection(db_config_admin)
@Integralist
Integralist / 1. sinatra-basic-with-comments.rb
Last active November 9, 2019 20:10
Create basic site using Ruby and Sinatra (and external templates)
#!/usr/bin/env ruby
=begin
install Sinatra: gem install sinatra
install Shotgun: gem install shotgun (this auto-reloads sinatra on every http request - which means every time you make a change in your code you don't have to stop then start sinatra)
To just run your code using Sinatra: ruby name-of-file.rb
To run your code using Shotgun (which is just Sinatra but with ability to auto-reload when changes are made to files): shotgun name-of-file.rb
The following examples are run using Shotgun and the URL is: http://127.0.0.1:9393/
require 'rubygems'
require 'sinatra'
require 'rdiscount'
require 'haml'
require 'dm-core'
require 'sinatra-authentication'
use Rack::Session::Cookie, 'shhhhhhhhhhhhhhh~'
class Page