Skip to content

Instantly share code, notes, and snippets.

View jessecurry's full-sized avatar

Jesse Curry jessecurry

View GitHub Profile
@jessecurry
jessecurry / .rubocop.yml
Created July 22, 2019 15:24
Rubocop Setup
require:
- rubocop-rails
Rails:
Enabled: true
Metrics/ClassLength:
Enabled: false
Metrics/AbcSize:
Enabled: false
Metrics/LineLength:
@jessecurry
jessecurry / keyMirror.js
Created May 7, 2019 17:03
keyMirror with namespaces
'use strict';
const keyMirror = (list, namespace) => {
let newList= {};
let prefix = namespace ? namespace + ":" : "";
Object.keys(list).map(element => {
var key = String(element);
newList[key] = prefix + element
});
@jessecurry
jessecurry / base.rb
Last active December 17, 2015 18:55
Wrap JSON data with type-safe methods
module JsonWrapper
class Base
MAPPING_TYPES = {
array: :to_a,
boolean: :to_bool,
date: :to_date,
datetime: :to_datetime,
float: :to_f,
hash: :to_h,
integer: :to_i,
@jessecurry
jessecurry / email_report_job.rb
Created June 11, 2015 14:06
Job to email reports
class EmailReportJob < ActiveJob::Base
queue_as :mail
def perform recipients, report_builder
recipients.each do |recipient|
ReportMailer.new_report_email(recipient, report_builder).deliver
end
end
end
@jessecurry
jessecurry / report_mailer.rb
Created June 11, 2015 14:03
Report Mailer
class ReportMailer < ApplicationMailer
def new_report_email recipient, report_builder
attachments['report.pdf'] = { mime_type: 'application/pdf', content: report_builder.generate_stream }
mail(to: recipient, subject: report_builder.title)
end
end
@jessecurry
jessecurry / report_builder.rb
Created June 11, 2015 13:57
Example of GlobalID in a custom class
class ReportBuilder
include GlobalID::Identification
def id
report.id
end
def self.find id
new(report_class.find(id))
end
@jessecurry
jessecurry / jcKeypress.js
Created October 24, 2014 16:20
First pass for a keypress directive for Angular.js
.directive('jcKeypress', function () {
return {
template: '',
restrict: 'AE',
scope: {
keyCode: '@',
keyAction: '&'
},
link: function(scope, element, attrs) {
attrs.altKey = attrs.altKey || false;
@jessecurry
jessecurry / keybase.md
Created September 17, 2014 21:47
keybase.md

Keybase proof

I hereby claim:

  • I am jessecurry on github.
  • I am jessecurry (https://keybase.io/jessecurry) on keybase.
  • I have a public key whose fingerprint is AE69 C486 9CEC 9606 4C4E C394 B08C 3BFB C402 9463

To claim this, I am signing this object:

@jessecurry
jessecurry / BFParallaxImageView.h
Created August 26, 2014 20:23
Parallax NSImageView for OS X
//
// BFParallaxImageView.h
// bout-osx
//
// Created by Jesse Curry on 8/26/14.
// Copyright (c) 2014 Bout Fitness, LLC. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@jessecurry
jessecurry / angular-filter-bytes.js
Last active December 4, 2015 10:08 — forked from thomseddon/gist:3511330
Angular filter to display file sizes
app.filter('bytes', function() {
return function(bytes, precision) {
if (isNaN(parseFloat(bytes)) || !isFinite(bytes)) {
return '-';
}
if (typeof precision === 'undefined') {
precision = 1;
}