Skip to content

Instantly share code, notes, and snippets.

@rickharris
rickharris / libgit2.rb
Last active February 6, 2017 18:36 — forked from nalanj/libgit2.rb
Homebrew formula for libgit2
class Libgit2 < Formula
desc "C library of Git core methods that is re-entrant and linkable"
homepage "https://libgit2.github.com/"
url "https://github.com/libgit2/libgit2/archive/v0.24.6.tar.gz"
sha256 "7b441a96967ff525e790f8b66859faba5c6be4c347124011f536ae9075ebc30c"
head "https://github.com/libgit2/libgit2.git"
option :universal
depends_on "pkg-config" => :build
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
<% 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" %>
@rickharris
rickharris / transaction_example.rb
Created May 2, 2012 18:15
How do you do this??
# 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
rickharris / fix.js.coffee
Created April 25, 2012 22:33
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 ->
$(document).click()
@rickharris
rickharris / britney.rb
Created April 21, 2012 00:50
A simple algorithm to tell whether or not I am pleased with my Greenville coworkers' music choices
BRITNEY_LISTENERS = ["@seangaffney", "@jeremyjantz"]
def has_been_listening_to_britney?(twitter_handle)
BRITNEY_LISTENERS.include?(twitter_handle)
end
def is_rick_pleased?
["@seangaffney", "@jeremyjantz"].each do |coworker|
return false unless has_been_listening_to_britney?(coworker)
end
@rickharris
rickharris / administer_faqs.rb
Created March 13, 2012 00:41
admin_login for integration tests
require 'test_helper'
class Admin::AdministerFaqsTest < ActionDispatch::IntegrationTest
an "Admin creating a new FAQ section" do
before do
admin_login
end
it "is able to view available plans" do
visit "/admin/faq_sections/new"
" 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
rickharris / dabblet.css
Created February 1, 2012 21:31
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
body {
padding-top: 100px;
}
select {
max-width: 300px;
@rickharris
rickharris / example.scss
Created January 13, 2012 19:21
Example of a Sass bug
// 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-1,
.example-1-2,
.example-1-3 {
font-size: 24px;
color: #444;