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('_')
@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
@jbennett
jbennett / SizeWatch.html
Created August 27, 2012 13:10
Watches for screen size to change and triggers named events are specified sizes
<!DOCTYPE html>
<html>
<head>
<title>Size Watch</title>
<script src="http://ajax.googleapis.com/ajax/libs/mootools/1.4.5/mootools-yui-compressed.js"></script>
<script src="file:///Users/jbennett/Desktop/SizeWatch.js"></script>
</head>
<body>
@jbennett
jbennett / gist:1324331
Created October 29, 2011 10:51
Patch for Nooku authorizations
Index: administrator/components/com_default/controllers/behaviors/executable.php
===================================================================
--- administrator/components/com_default/controllers/behaviors/executable.php (revision 4344)
+++ administrator/components/com_default/controllers/behaviors/executable.php (working copy)
@@ -58,7 +58,7 @@
if(parent::canAdd())
{
if(version_compare(JVERSION,'1.6.0','ge')) {
- $result = JFactory::getUser()->authorise('core.create');
+ $result = JFactory::getUser()->authorise('core.create') === true;
<?php
class ComCCIDatabaseBehaviorNotifiable extends KDatabaseBehaviorAbstract
{
/**
* Collection of emails.
*
* @var array
*/
protected $_emails;
@jbennett
jbennett / database_behavior_relatable.php
Created July 6, 2011 04:26
Mixins and Table Behaviours
<?php
/**
* Relatable Behavior
*
* The relatable behavior provides a riby-esk has_many/belongs_to relationship model.
*
* @author jbennett
*
*/