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
npm_global_path = File.join(system("npm config get prefix"), "lib/node_modules") | |
file_name = File.join(npm_global_path, "ionic/lib/tasks/cliTasks.js") | |
File.open(file_name, 'r+') do |f| | |
orig_str = "'--splash|-s': {" | |
str = "'--ignore-cache|-c': { title: 'Ignoring cached resources', boolean: true },#{orig_str}" | |
f.write File.read(file_name).gsub(orig_str, str) | |
end | |
file_name = File.join(npm_global_path, "ionic/node_modules/ionic-app-lib/lib/resources.js") |
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 ActiveRecord | |
module Querying | |
delegate :or, :to => :all | |
end | |
end | |
module ActiveRecord | |
module QueryMethods | |
# OrChain objects act as placeholder for queries in which #or does not have any parameter. | |
# In this case, #or must be chained with any other relation method to return a new relation. |
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
#!/bin/bash | |
# CentOS rbenv system wide installation script | |
# Forked from https://gist.github.com/1237417 | |
# Installs rbenv system wide on CentOS 5/6, also allows single user installs. | |
# Install pre-requirements | |
yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel \ | |
make bzip2 autoconf automake libtool bison iconv-devel git-core |
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
class FileUploader < CarrierWave::Uploader::Base | |
### This uploader is setup for paperclip compatibility | |
include CarrierWave::MiniMagick | |
storage :file | |
def store_dir | |
"system/#{model.class.to_s.pluralize.underscore}/#{mounted_as.to_s.pluralize}/#{model_id_partition}" | |
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
### HOW TO IMPLEMENT EXCEPTION THROTTLING WITH EXCEPTION NOTIFIER FOR RAILS | |
### | |
### Documentation for Exception Notification: https://github.com/smartinez87/exception_notification | |
### SETUP VARIABLES | |
cache_key = "exception_times" | |
if ["development", "test"].include?(Rails.env.to_s) | |
throttle_interval = 0 ### no throttling for dev | |
else |
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
# if defined?(Sidekiq) || ["", "inline"].exclude?(Rails.application.config.active_job.queue_adapter.to_s) | |
if Rails.env.development? | |
ASYNC_JOBS = false ### change temporarily for testing | |
elsif Rails.env.test? | |
ASYNC_JOBS = false | |
else | |
ASYNC_JOBS = true | |
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
################################################## FetchHash - ALL VALUE FETCHING OCCURS USING FETCH METHOD WHICH RAISES ERROR IF KEY NOT FOUND | |
class FetchHash < HashWithIndifferentAccess | |
def [](k) | |
self.fetch(k) | |
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
################################################## CIString (Case-Insensitive String) - HELPFUL FOR STRING COMPARISONS WHERE WE NEED TO IGNORE CASE ERRORS | |
class CIString < String | |
def initialize(*args) | |
if args[0].nil? | |
args[0] = "" | |
end | |
super | |
end | |
def ==(val) | |
val.is_a?(String) ? self.casecmp?(val) : false |
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
### CUSTOM I18N EXCEPTION HANDLER | |
### 1. This exception handler enforces that an exception is raised whenever a translation is not found rather than showing "translation missing" to user | |
### 2. YOU CAN USE I18n.t(key, fallback: true) and it will now handle missing translations as follows: | |
### | |
### If a specific key is used ie. 'fisheries.locations.asd' and the translation is not found then it will look for: | |
### - 'common.asd' | |
### | |
module I18n |
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
def create_tempfile(str_data, file_name: nil) | |
file_basename = file_name.to_s.split('.').first || "Example File" | |
file_ext = file_name.to_s.split('.').last || "csv" | |
### Must seperate basename and extension to array for tempfile new syntax | |
### https://ruby-doc.org/stdlib-3.0.2/libdoc/tempfile/rdoc/Tempfile.html#method-c-new | |
tmp_file = Tempfile.new([file_basename, ".#{file_ext}"], binmode: true) | |
tmp_file << str_data |
OlderNewer