Skip to content

Instantly share code, notes, and snippets.

{
"device": {
"status": {
"app": {
"version": "2024.02.3",
"environment": "production",
"build": "2000007077",
"hash": "",
"timestamp": 1706129539
},
@jfeaver
jfeaver / rrule_parse.rb
Last active August 20, 2023 06:11
Parse full RRULEs to pass on to the rrule gem
# frozen_string_literal: true
# The rrule gem parses only the recurring rules of the RRULE specification.
# That is, the part that comes after "RRULE:" on the last line of an RRULE. To
# include the DTSTART, and EXDATE as options to the rrule gem, let's add our
# own interface. We remove the "RRULE:" and parse other rules and send them to
# the gem with the desired structure.
#
# Example RRULE which is now parseable as a string:
#
# EXDATE:19960402T010000Z,19960403T010000Z,19960404T010000Z
@jfeaver
jfeaver / active_record_relation_type.rb
Last active September 30, 2022 13:21
Use Dry gems to build a struct which has an active record relation from a specified model as an attribute
require 'dry-struct'
require 'active_record'
module Types
include Dry.Types
def self.ArRelation(model_class)
# Note that ActiveRecord_Relation, ActiveRecord_Associations_CollectionProxy, and ActiveRecord_AssociationRelation
# are private constants - they may change some day
Instance(model_class.const_get(:ActiveRecord_Relation)) |
defmodule Isbn do
require Record
Record.defrecord(:isbn, raw: "", gs1: "", group: "", publisher: "", title: "", check_digit: "")
end
@jfeaver
jfeaver / deploy.rake
Last active September 29, 2015 00:45
Heroku Deploy Script
class DeployTask
attr_accessor :app_suffix, :heroku_app, :git_branch, :force, :enter_maintenance
def initialize(options = {})
@app_suffix = options[:app_suffix]
@heroku_app = options.fetch(:heroku_app, default_app_name)
@git_branch = options.fetch(:git_branch, current_branch)
@force = options.fetch(:force, false)
@enter_maintenance = options.fetch(:enter_maintenance, true)
end
#Deploy and rollback on Heroku in staging and production
class RakeHerokuDeployer
def initialize app_env
@app = ENV["#{app_env.to_s.upcase}_APP"]
end
def run_migrations
push; turn_app_off; migrate; restart; turn_app_on; tag;
end