Skip to content

Instantly share code, notes, and snippets.

rickharris / libgit2.rb
Last active Feb 6, 2017 — forked from nalanj/libgit2.rb
Homebrew formula for libgit2
View libgit2.rb
class Libgit2 < Formula
desc "C library of Git core methods that is re-entrant and linkable"
homepage ""
url ""
sha256 "7b441a96967ff525e790f8b66859faba5c6be4c347124011f536ae9075ebc30c"
head ""
option :universal
depends_on "pkg-config" => :build
View invitations_controller.rb
def redeem
# Lookup invitation, 404 if not found
# Build new user.
# If user is valid
# If existing subscription, add user to subscription
# If adding to plan, create new subscription w/ as group leader
# If successful
# Create invitation redeemed event
# Delete invitation
View gist:4172092
<% bonus_videos = RecentClasses.bonus_content_videos(2) %>
<% bonus_videos.each do |video| %>
<div class="primary two-quarter <%= "last" if video == bonus_videos.last %>
<%= link_to(library_slug_url(:slug => video.slug), :class => "contained feature") do %>
<span class="flag flag-right">New</span>
<div class="flush">
<div class="hero-container">
<%= image_tag video.bonus_content_series.image_url %>
<%= image_tag cloudfront_signed_url("stills/" + video.still_image.to_s), :class => "video-thumb" %>
View transaction_example.rb
# So, we want to wrap a block of code in a transaction, and if the transaction
# fails, we'd like to take another action that also uses the database. But how?
# Example #1 - Not possible
success = false
ActiveRecord::Base.transaction do
success = some_method
if success
# do something that gets rolled back
rickharris /
Created Apr 25, 2012
mediaelement.js & Olark - quick event bubbling fix
# This is a waste of a function call, but it operates as a pseudo-olark-ready
# callback, which is just what we need to attach an event to it so that the
# video player loses focus before someone starts typing in the Olark box.
olark 'api.visitor.getDetails', (details) ->
olarkTextarea = $('#habla_wcsend_input')
olarkTextarea.focus ->
rickharris / britney.rb
Created Apr 21, 2012
A simple algorithm to tell whether or not I am pleased with my Greenville coworkers' music choices
View britney.rb
BRITNEY_LISTENERS = ["@seangaffney", "@jeremyjantz"]
def has_been_listening_to_britney?(twitter_handle)
def is_rick_pleased?
["@seangaffney", "@jeremyjantz"].each do |coworker|
return false unless has_been_listening_to_britney?(coworker)
rickharris / administer_faqs.rb
Created Mar 13, 2012
admin_login for integration tests
View administer_faqs.rb
require 'test_helper'
class Admin::AdministerFaqsTest < ActionDispatch::IntegrationTest
an "Admin creating a new FAQ section" do
before do
it "is able to view available plans" do
visit "/admin/faq_sections/new"
View .vimrc
" Don't try to play nicely with vi
set nocompatible
" Allow buffers to be hidden, even if they're not saved.
set hidden
" Save the last 100 commands and search terms in history
set history=100
" Filetype settings and syntax should be enabled.
rickharris / dabblet.css
Created Feb 1, 2012
The first commented line is your dabblet’s title
View dabblet.css
* The first commented line is your dabblet’s title
body {
padding-top: 100px;
select {
max-width: 300px;
rickharris / example.scss
Created Jan 13, 2012
Example of a Sass bug
View example.scss
// Failing example: how to make a duplicate selector
// Requirement 1. Style block with list of selectors on newlines
// Requirement 2. Extend non-first selector from the list of selectors
// Requirement 3. Extend from nested selector
// Results in two sets of duplicate selectors
.example-1-3 {
font-size: 24px;
color: #444;