Skip to content

Instantly share code, notes, and snippets.

View aaronvb's full-sized avatar
:shipit:
Working from ~/

Aaron Van Bokhoven aaronvb

:shipit:
Working from ~/
View GitHub Profile
@aaronvb
aaronvb / kitty.conf
Created August 14, 2019 23:54
Horizon theme for kitty terminal
foreground #BABABA
background #1C1E26
# black
color0 #131419
color8 #676767
# red
color1 #E95678
color9 #EC6A88
@aaronvb
aaronvb / dj_recurring.rb
Created October 28, 2010 03:30
This will insert a job into the delayed_job queue outside of Ruby on Rails environment. Useful for recurring jobs using cron.
#!/usr/bin/env ruby
# put this somewhere in your project, ie: /lib
# use:
# crontab -e
# */30 * * * * /usr/bin/ruby /your_rails_project/lib/this_file.rb
# that will insert this job into your delayed_job queue every 30 minutes.
require 'rubygems'
require 'mysql'
@aaronvb
aaronvb / fb_js_connect.rb
Created October 25, 2010 06:13
This will allow you to verify and parse the Facebook Javascript Connect cookie for Ruby/Ruby on Rails. Currently working this into a gem: http://github.com/aaronvb/fb_js_connect
require 'digest/md5'
class FbJsConnect
# When using the Facebook Javascript SDK to connect users to your site,
# a cookie will be placed in your applications session store. This class
# will verify your cookie, tell you if you're connected, and provide
# you with a User and other information
#
# cookie = cookies["fbs_YOUR FACEBOOK APP ID"]
# fb = FbJsConnect.new(cookie)
<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}}
class Checkpoint < ActiveRecord::Base
has_many :note_joins, as: :notable
has_many :notes, through: :note_joins
end
@aaronvb
aaronvb / gist:3172262
Created July 24, 2012 20:01
Increase and Decrease LED with button
/*
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 July 24, 2012 19:27
Increase LED Brightness with Reset
/*
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 October 16, 2011 02:27
pagination page cache sweeper
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 September 24, 2011 23:28
sample virtual host for passenger
<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
$ 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")