Skip to content

Instantly share code, notes, and snippets.

require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "rails"
gem "puma"
gem "twitter"
gem "omniauth-twitter"
end
@clupprich
clupprich / spinner.rb
Created October 29, 2021 08:34
Terminal Spinner
%w(⠾ ⠷ ⠯ ⠟ ⠻ ⠽).cycle { |dot| print "\b#{dot}"; sleep 0.1 }
@clupprich
clupprich / railsfile_books.rb
Created March 15, 2021 08:39
A single file Rails application setting up the DB, a few models, running minitest and finally starting up a Rails server
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "rails"
gem "pg"
end
require "active_record"
# Use it like so:
# > bundle exec {rubocop, standardrb} --require ./lib/github_actions_formatter.rb --format GithubActionsFormatter
class GithubActionsFormatter < RuboCop::Formatter::BaseFormatter
def file_finished(file, offenses)
return unless (uncorrected_offenses = offenses.reject(&:corrected?)).any?
uncorrected_offenses.each do |o|
output.printf("::error file=%s,line=%d,col=%d::%s\n", path_to(file), o.line, o.real_column, o.message.tr("\n", " "))
end
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
@clupprich
clupprich / schema_matcher.rb
Last active August 29, 2015 14:24
JSON Schema matcher
# spec/support/schema_matcher.rb
class Schema
@definitions = {}
def self.define(name, &block)
@definitions[name] = block.call
end
def self.defined?(name)
@definitions.key?(name)
source 'https://rubygems.org'
gem 'bson_ext'
gem 'mongo_mapper', '0.13.1'
@clupprich
clupprich / .gitignore
Last active August 29, 2015 14:15
mongo-replica-test
data/**
@clupprich
clupprich / gist:8c1d85c1c3ce79767875
Created December 19, 2014 09:20
Write CouchDB stats into DB with current timestamp
curl -s -X GET http://localhost:5984/_stats | echo "[$(cat -), { \"datetime\": \"$(date -u +"%Y-%m-%dT%H:%M:%SZ")\" }]" | jq '.[0] + .[1]' | curl -X POST -H "Content-Type: application/json" -d @- http://localhost:5984/stats