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
// Your main application js. We will include jQuery first, then everything else | |
//= require jquery | |
// | |
//= require_tree . | |
// You can choose to DRY common selectors perhaps used system wide. | |
const SELECTORS = { | |
RESULTS: () => $("#results-box") | |
} |
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
//app/assets/js/any_es6_module.js | |
//Use globally in any es6 module you are requiring through application.js | |
var render_pdf_thumbnail = function(pdfData, $canvas) { | |
//This is the sauce. We instantiate a new Worker from our globally scoped worker-loader f() | |
pdfjsLib.GlobalWorkerOptions.workerPort = new pdfjsWorker(); | |
// In my case, using DocumentInitParameters object to load binary data. | |
var loadingTask = pdfjsLib.getDocument({data: pdfData}); | |
loadingTask.promise.then(function(doc) { |
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 CustomUtils | |
# This should look for hash keys, or ActiveModel::Base attributes within the string | |
# while also safeguarding from typing errors. | |
# Interpolation symbols not provided in the hash should be left unchanged. | |
# This does NOT support "deep interpolation" eg. "my %{%{nested_key}} string" | |
#@param String with %{key} interpolation fields | |
#@param Hash with symbolic keys OR Object with 'attributes' method eg. ActiveModel | |
#@returns String original with any keys replaced if they are in the hash, others ignored | |
def self.interpolate str, obj | |
#For the hash, we need to re-key the hash to be sure, and add default to skip missing interpolations |
OlderNewer