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
class User < ApplicationRecord | |
rolify :strict => true, :before_add => :before_add_role | |
#Helper method to remove any existing role this user has for a resource | |
def remove_all_roles resource | |
# README: This syntax relies on changes on the following PR | |
# https://github.com/RolifyCommunity/rolify/pull/427 | |
# Or include the source of this directly: | |
# gem 'rolify', :git => "git://github.com/Genkilabs/rolify.git" | |
remove_role nil, resource |
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