Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:
Working from ~/

Aaron Van Bokhoven aaronvb

:shipit:
Working from ~/
View GitHub Profile
@aaronvb
aaronvb / kitty.conf
Created Aug 14, 2019
Horizon theme for kitty terminal
View kitty.conf
foreground #BABABA
background #1C1E26
# black
color0 #131419
color8 #676767
# red
color1 #E95678
color9 #EC6A88
View application.handlebars
<div class="container">
{{#if notification}}
<div {{bindAttr class=":alert notification.type"}} id="notification">
<button type="button" class="btn-close" {{action "closeNotification"}}></button>
{{#if notification.title}}
<h3>{{notification.title}}</h3>
{{/if}}
{{notification.message}}
</div>
{{/if}}
View checkpoint.rb
class Checkpoint < ActiveRecord::Base
has_many :note_joins, as: :notable
has_many :notes, through: :note_joins
end
@aaronvb
aaronvb / gist:3172262
Created Jul 24, 2012
Increase and Decrease LED with button
View gist:3172262
/*
Increase LED Brightness with long press, Lower LED brightness with short press
Holding down the button with increase the brightness continuously.
A short press of the button will decrease the brightness by 20%
created 2012
by Aaron Van Bokhoven
*/
@aaronvb
aaronvb / gist:3172080
Created Jul 24, 2012
Increase LED Brightness with Reset
View gist:3172080
/*
Increase LED Brightness with Reset
Each press of the button increases the LED brightness by 10%.
Press and hold the button for 3 seconds to reset the LED to 0%.
created 2012
by Aaron Van Bokhoven
*/
@aaronvb
aaronvb / article_sweeper.rb
Created Oct 16, 2011
pagination page cache sweeper
View article_sweeper.rb
class ArticleSweeper < ActionController::Caching::Sweeper
observe Article # This sweeper is going to keep an eye on the article model
# If our sweeper detects that a article was created call this
def after_create(article)
expire_cache_for(article)
end
# If our sweeper detects that a article was updated call this
def after_update(article)
@aaronvb
aaronvb / gist:1239991
Created Sep 24, 2011
sample virtual host for passenger
View gist:1239991
<VirtualHost *:80>
ServerAdmin admin@yourdomain.com
ServerName yourdomain.com
ServerAlias www.yourdomain.com
DocumentRoot /home/yourserverusername/sites/yourappname/current/public
<Directory /home/yourserverusername/sites/yourappname/current/public>
AllowOverride all
Options -MultiViews
View gist:1087368
if Rails.env == "development"
Dir.foreach("#{Rails.root}/app/models") do |model_name|
require_dependency model_name unless model_name == "." || model_name == ".."
end
end
View gist:1087365
$ rails c
> @kitten = Kitten.first
> Rails.cache.write("kitten_#{@kitten.id}", @kitten)
=> "OK"
> Rails.cache.read("kitten_1")
=> #<Kitten id: 1, cute: "no">
> exit
$ rails c
> Rails.cache.read("kitten_1")
@aaronvb
aaronvb / cron_payment_update.rb
Created May 12, 2011
recurring resque with cron example
View cron_payment_update.rb
require 'redis'
require 'mysql2'
# assuming redis is running on the default port.
# if not, example: redis = Redis.new(:host => "10.0.1.1", :port => 6380)
redis = Redis.new
# Make sure queue exists, if not create it. When clearing a queue with the resque web interface, resque removes the queue, so here we just check to make sure it exists.
if redis.sismember('resque:queues', 'update_payment') == false
redis.sadd('resque:queues', 'update_payment')