Skip to content

Instantly share code, notes, and snippets.

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"
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
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
watch: {
css: {
files: ['styles/*'],
tasks: ['sass', 'cssmin', 'copy:css']
},
# encoding:utf-8
class Order < ActiveRecord::Base
acts_as_paranoid
attr_accessible :coupon_code, :plan, :subscription, :ordered_at, :address_attributes
attr_accessor :coupon_code, :plan
has_many :line_items, dependent: :destroy
has_many :transactions, dependent: :destroy
@clupprich
clupprich / template.rb
Created December 7, 2013 14:27
Rails 4 Application Template
# Rails 4 Application Template
#
# Author: Christoph Lupprich <christoph@luppri.ch>
#
#
# Gems
gem 'devise'
gem 'cancan'
@clupprich
clupprich / git-tag-semantic
Created March 16, 2013 14:17
git tag for semantic versions
#!/bin/bash
# Sorts the output of `git-tag` correctly for version string like v1.2.3.4.
# Save this file somewhere in your bin path and execute with git tag-semantic
semantic_tags=$(git tag | sort -n -t. -k1,1 -k2,2 -k3,3 -k4,4)
echo "$semantic_tags"