This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Flipper | |
module FlagRegistration | |
# These functions are all memoized because they should be static for the | |
# lifetime of a deployment (albeit they are really static to a Ruby process) | |
def self.registered_flags | |
@registered_flags ||= YAML.load_file("config/feature_flags.yml") | |
end | |
def self.flags_in_code | |
@flags_in_code ||= begin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module DbMaxLengthValidatorConcern | |
extend ActiveSupport::Concern | |
included do | |
cattr_accessor :column_varchar_max_lengths | |
self.column_varchar_max_lengths = {} | |
end | |
module ClassMethods |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ported from a node script that seemed to do truncation well | |
# https://github.com/huang47/nodejs-html-truncate/blob/master/lib/truncate.js | |
class Trunc | |
def self.trunc(str, max_length, options = {}) | |
new(str, max_length, options).trunc | |
end | |
attr_reader :str | |
EMPTY_OBJECT = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'restclient' | |
class OpenapiConverter | |
CONVERTER_URL = "https://converter.swagger.io/api/convert" | |
CONVERTED_FILE_PATH = File.join(Rails.root, "/public/api/docs") | |
CONVERTED_FILENAME = "swagger-spec-v3.json" | |
LOGGER = Rails.logger | |
attr_accessor :url | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rails.application.eager_load! | |
exclude_tables = ["sessions"] | |
row_limit_per_table = nil | |
tables = [] | |
ApplicationRecord.descendants.each do |model| | |
next if exclude_tables.any?{ |skip_table| skip_table == model.table_name } | |
next if tables.include?(model.table_name) # This covers STI | |
puts "Exporting: #{model.table_name}" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Note: This is abstracted from Rails 5.0.x | |
encoded_masked_token = "" # Enter masked csrf that is rendered as meta tag or form parameter | |
csrf_token = ActiveRecord::SessionStore::Session.last.data["_csrf_token"] # Enter csrf token that is saved in database | |
AUTHENTICITY_TOKEN_LENGTH=32 | |
def unmask_token(masked_token) | |
# Split the token into the one-time pad and the encrypted | |
# value and decrypt it |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object.singleton_class.instance_eval do | |
attr_accessor :label | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
def mmddyyyy_date_input_tag(scope, attribute, value) | |
object = Struct.new(attribute, :class).new(value, Hashie::Mash.new(model_name: "Date")) | |
builder = SimpleForm::FormBuilder.new(scope, object, self, {}, nil) | |
input = DateMmddyyyyInput.new(builder, attribute, nil, nil) | |
input.input | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Ecmabara | |
def self.included(base_class) | |
base_class.class_eval do | |
def self.new | |
super.extend Page | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
brew install ffmpeg ImageMagic mplayer gifsicle | |
# Option 1 | |
# http://superuser.com/questions/556029/how-do-i-convert-a-video-to-gif-using-ffmpeg-with-reasonable-quality | |
ffmpeg -y -i yourmovie.mov -vf fps=10,scale=800:-1:flags=lanczos,palettegen palette.png | |
ffmpeg -i yourmovie.mov -i palette.png -filter_complex "fps=10,scale=800:-1:flags=lanczos[x];[x][1:v]paletteuse" yourgif.gif | |
# Option 2 | |
# https://gist.github.com/dergachev/4627207 | |
ffmpeg -i in.mov -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > out.gif |
NewerOlder