Skip to content

Instantly share code, notes, and snippets.

View cypriss's full-sized avatar

Jonathan Novak cypriss

  • Stripe
  • San Francisco
View GitHub Profile
@cypriss
cypriss / sphinx.rb
Last active December 18, 2015 14:59
require 'formula'
class Sphinx < Formula
url 'http://sphinxsearch.com/files/archive/sphinx-0.9.9.tar.gz'
homepage 'http://www.sphinxsearch.com'
md5 '7b9b618cb9b378f949bb1b91ddcc4f54'
depends_on 'mysql'
def install
@cypriss
cypriss / action_mailer_no_tmail.rb
Created August 14, 2012 17:32
Use TMail -> Mail gem in Rails 2.3
require 'action_mailer'
require 'mail'
module ActionMailer
class Base
def clean_address(str)
EmailAddress.parse(str, :no_default_name => true).quoted rescue str
end
@cypriss
cypriss / gist:3239857
Created August 2, 2012 19:15
Working with associated models
# This input set:
class Idea
class Create
include Command
required do
string :title, length: 100
string :body
model :user, builder: User::CreateViaEmail, pk: true
@cypriss
cypriss / xml_parse.rb
Created May 11, 2012 21:09
Don't explode from invalid XML
# This implmements a custom parse strategy of XML. It's exactly the same as Rails (Hash.from_xml)
# except that it rescues syntax errors instead of exploding.
ActionController::Base.param_parsers[Mime::XML] = Proc.new do |body|
if body.blank?
{}.with_indifferent_access
else
begin
Hash.from_xml(body).with_indifferent_access
rescue Nokogiri::XML::SyntaxError => e
Mouth.increment("corner_cases.nokogiri_syntax_error")
@cypriss
cypriss / contact.html
Last active September 8, 2016 14:27
Create a UserVoice ticket with JSONP and our API.
<!DOCTYPE html>
<head>
<title>Demo Contact Form - Submit a ticket to UV via JSONP</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="https://jquery-jsonp.googlecode.com/files/jquery.jsonp-2.2.0.min.js"></script>
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" />
<style type="text/css"> #contact_form { margin: 20px auto; width: 500px; } </style>
</head>
<body>
@cypriss
cypriss / README.md
Last active June 18, 2018 11:57
Rails 2.3.14 Ruby 1.9.3 - Monkey Patches

How we upgraded UserVoice, a Rails 2.3.14 app, to Ruby 1.9.3.

Blog post here

@cypriss
cypriss / gemm.c
Created December 11, 2011 21:23
my first assembly function
void gemm_full_block(double* restrict A, // rdi
double* restrict B, // rsi
double* restrict C, // rdx
const uint32_t inner_k, // ecx
const uint32_t AB_stride, // r8
const uint32_t C_stride, // r9
uint32_t i,
uint32_t j,
uint32_t k) {
@cypriss
cypriss / dynos
Created June 13, 2009 11:06
Dynos - an alternative to NBB Engines. Namespaced controller methods available in any controller.
# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
# ...
before_filter :update_dyno
def dyno
@@dyno_set ||= DynoSet.new
end