Skip to content

Instantly share code, notes, and snippets.

View nesquena's full-sized avatar

Nathan Esquenazi nesquena

View GitHub Profile
@nesquena
nesquena / .gitignore
Last active April 4, 2019 11:22
Android .gitignore File
# built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
@nesquena
nesquena / a.md
Created November 27, 2012 23:53
RABL Testing Reference

Common Misunderstandings

Serialization should be testable

Agreed and with RABL serialization is testable both in and outside of a web request context. Check out the other gists in this file for examples using Rabl.render to do standalone unit testing.

RABL can't be used for generating push notifications or in background jobs

Not at all true, I use RABL for these purposes in all of my applications. Simply use Rabl.render to render templates in any context.

@nesquena
nesquena / default.vcl
Created September 27, 2012 04:52 — forked from alanmackenzie/default.c
Add X-Request-Start header so we can track queue times in New Relic RPM beginning at Varnish. - Fixed for Varnish 3.0.2-1 on Ubuntu.
# For Varnish NewRelic Tracking
# https://gist.github.com/2820068
C{
#include <stddef.h>
#include <stdio.h>
#include <sys/time.h>
}C
sub vcl_recv {
@nesquena
nesquena / default.vcl
Created September 27, 2012 04:35 — forked from alanmackenzie/default.c
Add X-Request-Start header so we can track queue times in New Relic RPM beginning at Varnish. - Modified by me for varnish 2.X
#
# Add X-Request-Start header so we can track queue times in New Relic RPM beginning at Varnish.
# Taken from https://gist.github.com/494265 & modified to compile on OSX.
#
sub vcl_recv {
// NewRelic X-Request-Start tracking
C{
#include </etc/varnish/newrelic.h>
}C
@nesquena
nesquena / configuration.rb
Created August 23, 2012 07:01
Ruby Source Article Snippets
# http://rubysource.com/polish-your-gems/
# Usage:
# Awesome.configure do |a|
# a.magic_number = 3
# end
module Awesome
class << self
attr_accessor :configuration
def config
@nesquena
nesquena / jbuilder.rb
Created February 14, 2012 01:15
JBuilder and RABL Syntax Comparison
Jbuilder.encode do |json|
json.content format_content(@message.content)
json.(@message, :created_at, :updated_at)
json.author do |json|
json.name @message.creator.name.familiar
json.email_address @message.creator.email_address_with_name
json.url url_for(@message.creator, format: :json)
end
@nesquena
nesquena / capture_stdout.rb
Created November 30, 2011 22:29
Capture STDOUT
require 'stringio'
module Kernel
# Redirect standard out, standard error
# capture_stdout { any_commands; you_want } => "all output from the commands"
def capture_stdout
out = StringIO.new
$stdout = out
$stderr = out
yield
return out.string
@nesquena
nesquena / minitest_steps.md
Created November 30, 2011 21:03
Setup Minitest in a Gem

Minitest Steps

Add to gemspec:

# my_gem.gemspec

Gem::Specification.new do |s|
  # ...
 
@nesquena
nesquena / markdown_yard.md
Created November 29, 2011 21:51
Github Flavored Markdown in YARD
@nesquena
nesquena / linode_fog.rb
Created October 28, 2011 09:24
Linode and Fog Samples
## DNS
@dns = Fog::DNS.new(:provider => 'Linode', :linode_api_key => LINODE_KEY)
if @zone = @dns.zones.all.find { |z| z.domain == ZONE }
puts "Found zone #{@zone.inspect}"
else
@zone = @dns.zones.create(:domain => ZONE, :email => ZONE_EMAIL)
puts "Creating zone #{@zone.inspect}"
end