Skip to content

Instantly share code, notes, and snippets.

View gist:804465
Building native extensions. This could take a while...
ERROR: Error installing patron:
ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-1.9.2-p136/bin/ruby extconf.rb
checking for curl-config... yes
checking for rb_thread_blocking_region()... yes
creating Makefile
kitop / gslyaml.rb
Created Jun 24, 2011 — forked from EmmanuelOga/gslyaml.rb
GSL::Vector to YAML
View gslyaml.rb
require 'psych'
require 'yaml'
require 'gsl'
v = GSL::Vector.alloc 1..10
class GSL::Vector
kitop / unicorn.rb
Created Feb 18, 2013
Unicorn config example
View unicorn.rb
# config/unicorn.rb
worker_processes 4
timeout 30
preload_app true
before_fork do |server, worker|
# Replace with your ORM of choice
if defined?(ActiveRecord::Base)
View email_worker.rb
class EmailWorker
include SuckerPunch::Worker
def perform(user_id)
ActiveRecord::Base.connection_pool.with_connection do
user = User.find(user_id)
View email_worker_spec.rb
require 'spec_helper'
# it's important to add the ':worker => true' setting so tests don't run in a transaction. This is configured in spec_helper
describe EmailWorker, :worker => true do
before(:each) do
@user = FactoryGirl.create :user
let(:worker){ }
View products_controller.rb
class ProductsController < ApplicationController
def preview
ActiveRecord::Base.transaction do
if request.referer =~ %r{/admin/products/(.+)/edit}
@product = Product.find($1)
@product =[:product])
raise "Invalid" unless @product.valid?
kitop / twitter-cards.liquid
Created Sep 16, 2013
Twitter Cards Snippet for Shopify Stores
View twitter-cards.liquid
{% comment %}
This is for widgets that share content on Twitter.
Twitter developer info:
Brought to you by Viralica
{% endcomment %}
{% if template contains 'product' %}
<meta name="twitter:card" content="product">
<meta name="twitter:title" content="{{ product.title }}" />
<meta name="twitter:description" content="{{ product.description | strip_html | strip_newlines | truncatewords: 160, '' | escape }}" />
kitop / post-commit
Last active Jan 2, 2016
Git post commit hook to remind to precompile some assets
View post-commit
# A hook script to remind us to precompile the assets.
NC='\033[0m' # No Color
changes=$(git diff --name-only HEAD^)
kitop / app.rb
Created Apr 11, 2014
nested routes
View app.rb
Cuba.define do
on "posts" do
run Posts
class Posts < Cuba
define do
on ":id" do |id|
post = Post[id]
kitop /
Last active Aug 29, 2015
angular on cuba - Rubyconf 2014