Skip to content

Instantly share code, notes, and snippets.

<html>
<body>
<a href="#testing">Test</a>
<br />
<br />
<br />
<br />
<br />
@colinpetruno
colinpetruno / json_objects.rb
Created August 5, 2019 10:18
JsonObjects.rb
class DataObject
def self.from(json_data)
new(json_data)
end
def new(json_data)
@json_data = JSON.parse(json_data)
end
def as_json(_opts={})

Link to document:

https://drive.google.com/file/d/1cRgAdjkZNGR2IttjwZkNCxnuNf315QuH/view?usp=sharing

Background:

I have been working with the Origami gem to sign PDF's to replicate docusign but more EU compliant. However the gem is really basic and has quite a few errors in it that need corrected. For the most part, while going slow, it has progressed well. After a decent amount of QA there is still a subset of documents that don't work.

@colinpetruno
colinpetruno / backfill_active_storage.rake
Last active September 28, 2018 19:20
Postgres Paperclip to ActiveStorage Rake Task
namespace :backfill do
task active_storage: :environment do
require 'open-uri'
def key(instance, attachment)
SecureRandom.uuid
# Alternatively:
# instance.send("#{attachment}_file_name")
end
Couldn't find CsvImporter with 'id'=30969 [WHERE `contact_imports`.`type` IN ('CsvImporter')]
/var/attend/production/firehouse/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/relation/finder_methods.rb:324:in `raise_record_not_found_exception!'
/var/attend/production/firehouse/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/relation/finder_methods.rb:444:in `find_one'
/var/attend/production/firehouse/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/relation/finder_methods.rb:423:in `find_with_ids'
/var/attend/production/firehouse/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/relation/finder_methods.rb:71:in `find'
/var/attend/production/firehouse/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/querying.rb:3:in `find'
/var/attend/production/firehouse/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/core.rb:131:in `find'
/var/attend/production/firehouse/releases/20160112190930/app/jobs/process_csv_j
@colinpetruno
colinpetruno / countCSSRules.js
Last active September 2, 2015 14:10 — forked from psebborn/countCSSRules.js
Count the number of rules and selectors for CSS files on the page. Flags up the >4096 threshold that confuses IE
function countCSSRules() {
var results = '',
log = '';
if (!document.styleSheets) {
return;
}
for (var i = 0; i < document.styleSheets.length; i++) {
countSheet(document.styleSheets[i]);
}
function countSheet(sheet) {
@colinpetruno
colinpetruno / docker-compose.yml
Created July 22, 2015 20:55
Docker Compose Base
web:
build: .
command: bin/rails server -p 4567 -b '0.0.0.0'
volumes:
- .:/app/<app-name>
ports:
- 4567:4567
@colinpetruno
colinpetruno / Dockerfile
Created July 22, 2015 20:54
DockerFile Base
FROM ruby:2.2.0
RUN apt-get update -qq && apt-get install -y build-essential
ENV APP_HOME /app/<app-name>
RUN mkdir -p $APP_HOME
WORKDIR $APP_HOME
ADD Gemfile* $APP_HOME/
RUN bundle install
$(function () { //this javascript code runes immediatly and not in a document ready
// may cause some race conditions
var $xpoNav = $('.xpo-nav'),
nodes= [],
$moreMenu = $('<li class="xpo-nav-dropdown more-menu"><a href="#" class="xpo-nav-dropdown-toggle" data-toggle="xpo-nav-dropdown" data-target="#">More <i class="xico-ui-arrow-down"></i></a></li>'),
$nestedUl = $('<ul class="xpo-nav-dropdown-menu"></ul>');
@colinpetruno
colinpetruno / gist:1e2f2c0d3bf39a389ae6
Created May 20, 2014 17:50
Iphone / Android url scheme redirects
if (navigator.appVersion.indexOf('iPhone') > -1 || navigator.appVersion.indexOf('iPad') > -1) {
// default link here if they do not have the device installed
setTimeout(function noapp() { window.location=params.finalDefault; }, 25);
/* if they do have the app installed this is the registered url
scheme provided by the client, if they dont have this app installed
the url will do nothing and thus force the redirect to the default link after 25 ms */
window.location = deepLinks.apple;