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
// Extract and inject SVG logo into document | |
$(document).ready(function() { | |
$('img[src*=".svg"]').each(function() { | |
var $img = jQuery(this), $svg, | |
imgURL = $img.attr('src').replace(/\.svg(\?\w+)/,'.svg'), // strip timestaps from img URL | |
imgAttributes = $img.prop("attributes"); | |
$.get(imgURL, function(data) { | |
$svg = jQuery(data).find('svg'); // Get the SVG tag, ignore the rest | |
$svg = $svg.removeAttr('xmlns:a'); // Remove any invalid XML tags |
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
/* | |
Generate a random string of a given length. | |
@params: | |
length: *required* - length of string to generate | |
kind: *optional* - character set or sets to use for string generation (default: 'aA#') | |
Available options | |
'a' => for lowercase alphabets [a-z] | |
'A' => for uppercase alphabets [A-Z] | |
'#' => numbers [0-9] | |
'!' => special character as defined |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Script loader</title> | |
<!-- Comment out next line to test "jquery missing on page" scenario --> | |
<!-- <script type="text/javascript" src="https://code.jquery.com/jquery-1.11.2.min.js"></script> --> | |
<!-- <script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.min.js"></script> --> | |
</head> | |
<body> |
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
# Extends Ruby BigDecimal class so we have an updated to_s method that returns numbers witheout the ZERO at the end | |
# if the number is an integer. | |
# e,g. '12.0'.to_s => 12 | |
# '9.23'.to_s => 9.23 | |
class BigDecimal | |
alias_method(:original_to_s, :to_s) unless method_defined?(:original_to_s) | |
def is_whole_number? | |
self % 1 == 0 |
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
# ****************** | |
# *** FYI :: This turned out to be the missing link in the process ***** | |
# Install the devel packages for png, jpg, tiff. these are dependencies of ImageMagick | |
# Time taken: ~ 3secs | |
# ****************** | |
sudo yum -y install libpng-devel libjpeg-devel libtiff-devel | |
# ****************** | |
# Download and Install Imagemagick |
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
E.g. | |
$('.js-show-spinner').click(function() { | |
var $saveButton = $(this) | |
$saveButton.html($('<div>').addClass('loader')) | |
setTimeout(function() { $('#' + $saveButton.attr('form')).submit(); }) | |
return 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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
import File.expand_path(File.dirname(__FILE__) + '/schema_format.rb') | |
namespace :db do | |
# Define PG environment utility methods | |
task :pg_env => :environment do | |
def pg_get_config | |
ActiveRecord::Base.configurations.fetch(Rails.env).tap do |config| | |
ENV['PGHOST'] = config['host'].to_s if config.key?('host') | |
ENV['PGPORT'] = config['port'].to_s if config.key?('port') | |
ENV['PGPASSWORD'] = config['password'].to_s if config.key?('password') |