Skip to content

Instantly share code, notes, and snippets.

View apanzerj's full-sized avatar

Adam Panzer apanzerj

View GitHub Profile
@fnando
fnando / polite.rb
Created January 28, 2011 18:12
ActiveRecord macro example
require "active_record"
module Polite
BAD_WORDS = ["fuck", "asshole", "motherfucker", "cunt", "cock", "dickhead"]
ESCAPED = BAD_WORDS.collect {|word| Regexp.escape(word)}
RE = /(#{ESCAPED.join("|")})/i
def self.extended(base)
base.extend ClassMethods
end
@mranney
mranney / emoji_sad.txt
Created January 30, 2012 23:05
Why we can't process Emoji anymore
From: Chris DeSalvo <chris.desalvo@voxer.com>
Subject: Why we can't process Emoji anymore
Date: Thu, 12 Jan 2012 18:49:20 -0800
Message-Id: <AE459007-DF2E-4E41-B7A4-FA5C2A83025F@voxer.com>
--Apple-Mail=_6DEAA046-886A-4A03-8508-6FD077D18F8B
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=utf-8
@pstadler
pstadler / ticker.sh
Last active July 17, 2024 18:47
Real-time stock tickers shell script (requires jq)
# This has been moved: https://github.com/pstadler/ticker.sh
@bensie
bensie / base.rb
Created December 6, 2012 17:53
Sinatra API Helpers
require "sinatra/base"
require "sinatra/namespace"
require "multi_json"
require "api/authentication"
require "api/error_handling"
require "api/pagination"
module Api
class Base < ::Sinatra::Base
@steved
steved / oauth2.zendesk.rb
Created August 6, 2013 18:26
Ruby OAuth2 Example for Zendesk
require 'zendesk_api'
require 'oauth2'
client = OAuth2::Client.new('{my client unique identifier}',
'{my client secret}',
site: 'https://{subdomain}.zendesk.com',
token_url: "/oauth/tokens",
authorize_url: "/oauth/authorizations/new")
  • Dynamic Dispatch
  • Dynamic Method
  • Ghost Methods
  • Dynamic Proxies
  • Blank Slate
  • Kernel Method
  • Flattening the Scope (aka Nested Lexical Scopes)
  • Context Probe
  • Class Eval (not really a 'spell' more just a demonstration of its usage)
  • Class Macros
@remh
remh / gist:1426ccb24ec36162ba2b
Last active August 29, 2015 14:03
Datadog Agent 5.0.0

What is Datadog Agent 5.0.0 ?

Datadog Agent 5.0.0 is the next major version of the Datadog Agent. Its main improvement being that it will be self-contained. All dependencies required by the Agent to run will be part of the package.

Warning

This version of the Datadog-Agent is still in beta. It's planned to be released soon and is being used by us and a few of our users without any major issue but please keep in mind that it's a BETA version.

What issues will it solve ?

  • Conflicts with dependencies (Tornado, Supervisor, Check dependencies: MysqlDB, Postgres....)
  • On Centos 5, there is no forwarder which can create some issues (such as no proxy support for Dogstatsd). This will be solved
  • Full support of Fedora Core
require 'rails_helper'
RSpec.describe TodosController, :type => :controller do
describe "GET #index" do
#describe "POST #create" do
#describe "GET #show" do
#describe "PATCH #update" do (or PUT #update)
#describe "DELETE #destroy" do
#describe "GET #new" do
@apanzerj
apanzerj / application.rb
Last active June 25, 2019 22:56
A minimalistic signed request validation middleware
# config/application.rb
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module (YOUR APPLICATION)
@ivanyv
ivanyv / application.amp.erb
Created December 12, 2015 02:51
Easy Google AMP on Rails
<html>
<head>
<link rel="canonical" href="<%= current_uri_sans_amp %>">
</head>
...
</html>