Skip to content

Instantly share code, notes, and snippets.

View jbennett's full-sized avatar

Jonathan Bennett jbennett

View GitHub Profile
@jbennett
jbennett / new_post_notification.rb
Last active January 3, 2024 13:52
introducing noticed-web_push
class NewPostNotification < Noticed::Base
# ... other deliver methods
deliver_by :web_push, data_method: :web_push_data
def web_push_data
{
title: "New post: #{post.title}",
body: post.content.truncate(40),
url: post_url(post),
}
@jbennett
jbennett / application.html.erb
Last active December 22, 2023 19:30
Setting Up Turbo 8
<head>
<!-- other head content -->
<%= turbo_refreshes_with method: :morph, scroll: :preserve %>
<%= content_for :head %>
</head>
@jbennett
jbennett / conditional_formatting.rb
Created October 20, 2023 17:40
Conditional Formatting w/ RubyXL
workbook = RubyXL::Workbook.new
worksheet = workbook.worksheets[0]
# Style to highlight red
style = RubyXL::DXF.new
style.font = RubyXL::Font.new
style.font.color = RubyXL::Color.new("FF0000")
# Add style to workbook
workbook.stylesheet.dxfs ||= RubyXL::DXFs.new # This was my initial problem
@jbennett
jbennett / cleanup.rb
Created September 21, 2023 21:09
CRMmy Review
def click_nav(label)
within "#desktop-nav" do
click_on label
    end
end
scenario "navigate to projects page" do
    click_nav "Projects"
    expect(page).to have_content "Projects"
end
@jbennett
jbennett / application_helper.rb
Created April 7, 2023 18:45
Polymorphic Render
module ApplicationHelper
def polymorphic_render(resource, suffix = nil, options = {})
if resource.nil?
return
elsif resource.is_a? Array
capture do
resource.each { |res| concat polymorphic_render(res, suffix, options) }
end
elsif resource.respond_to? :to_partial_path
path = [resource.to_partial_path, *Array(suffix)].compact_blank.join('_')
/*:
# Swift Protocol Generics
In reference to [Secret Projects Diary #2: Swift 2.0 Protocols](http://inessential.com/2015/07/19/secret_projects_diary_2_swift_2_0_prot):
An variable of type `[Feed]` means that it could have a `LocalFeed` and a `FeedlyFeed`, which may be intentional, but i think not in this case. I am assuming that the `FeedlyFolder` could be typed as `[FeedlyFeed]`. If that is the case, making the Folder protocol be generic with a constraint of Feed should do the trick.
*/
import Cocoa
### Keybase proof
I hereby claim:
* I am jbennett on github.
* I am jbennett (https://keybase.io/jbennett) on keybase.
* I have a public key whose fingerprint is D348 CC45 ABAD D4FA 656D 65CC 5D35 198B 67D3 3F55
To claim this, I am signing this object:
var gulp = require('gulp');
var autoprefixer = require('gulp-autoprefixer'),
concat = require('gulp-concat'),
filter = require('gulp-filter'),
gulpif = require('gulp-if'),
minify = require('gulp-minify-css'),
plumber = require('gulp-plumber'),
rename = require('gulp-rename'),
sass = require('gulp-sass')
uglify = require('gulp-uglify');
@jbennett
jbennett / debounce.js
Created February 19, 2014 14:41
Debounce
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
clearTimeout(timeout);
timeout = setTimeout(function() {
timeout = null;
if (!immediate) func.apply(context, args);
}, wait);
if (immediate && !timeout) func.apply(context, args);
@jbennett
jbennett / gist:4475720
Last active December 10, 2015 18:38
Resources for getting started at CCI

Software

  • Alfred
  • OmniFocus
  • 1Password
  • Transmit
  • Sublime Text
  • MAMP
  • ssh/cli/cPanel
  • CodeKit
  • Dropbox