Skip to content

Instantly share code, notes, and snippets.

View sgerrand's full-sized avatar
🧑‍✈️
Manual controls

Sasha Gerrand sgerrand

🧑‍✈️
Manual controls
View GitHub Profile
@parndt
parndt / existing.rb
Last active December 19, 2015 13:29
Who wants to make this nicer? :(
def extension_path_for_nested_extension(path, apply_tmp)
if File.exist?(path.gsub(/\.erb$/, ""))
if %r{/(locales/.*\.yml)|((routes|#{gem_name})\.rb\.erb)$} === path
# put new translations into a tmp directory
path = path.split(File::SEPARATOR).insert(-2, "tmp").join(File::SEPARATOR) if apply_tmp
elsif %r{/readme.md$} === path || %r{/#{plural_name}.rb$} === path
path = nil
end
elsif %r{lib\/#{plural_name}.rb$} === path
path = nil
#!/usr/bin/env ruby
gem "parser", "~> 1.4"
require "parser"
require "parser/ruby19"
require "set"
class ConstantDeclarationAndUseProcessor < Parser::AST::Processor
attr_reader :declared, :used
def initialize
@ragingwind
ragingwind / Backend Architectures Keywords and References.md
Last active April 17, 2024 10:51
Backend Architectures Keywords and References
@ashrithr
ashrithr / kafka.md
Last active March 14, 2024 21:16
kafka introduction

Introduction to Kafka

Kafka acts as a kind of write-ahead log (WAL) that records messages to a persistent store (disk) and allows subscribers to read and apply these changes to their own stores in a system appropriate time-frame.

Terminology:

  • Producers send messages to brokers
  • Consumers read messages from brokers
  • Messages are sent to a topic
@havenwood
havenwood / bench.md
Last active December 12, 2015 05:49
Entirely Unscientific Benchmark of Primes in Various Ruby Implementations

Unscientific Benchmark

The Benchmark

def is_prime? n
  (2...n).all? { |i| n % i != 0 }
end

def sexy_primes n
@kvnsmth
kvnsmth / example-subtree-usage.md
Last active March 5, 2023 21:58
A real world usage for git subtrees.

Let's say you have an iOS project, and you want to use some external library, like AFNetworking. How do you integrate it?

With submodules

Add the project to your repo:

git submodule add git@github.com:AFNetworking/AFNetworking.git Vendor/AFNetworking

or something to that effect.

@sbkinney
sbkinney / import_sat_via_Zendesk_API.js
Created November 9, 2012 01:47
This is a method for pulling Zendesk data from a view via the API into a Google Docs spreadsheet
/* This function runs when the spreadsheet is opened and populates a menu option
labelled Zendesk that contains two options (7 days and 30 days) which are tied
to the listed functions
*/
function onOpen() {
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var entries = [{
name : "Pull Satisfaction Data (last 7 days, rolling)",
functionName : "getSatisfactionDataLast7"
@sferik
sferik / install-ruby-2.0.0.sh
Created November 5, 2012 02:28
Instructions to install on Ruby 2.0.0 on Mac OS X with homebrew
#!/usr/bin/env sh
brew update
brew install rbenv
brew install ruby-build
brew install openssl
CONFIGURE_OPTS=--with-openssl-dir=`brew --prefix openssl` rbenv install 2.0.0-preview1
@domenic
domenic / promises.md
Last active March 31, 2024 14:07
You're Missing the Point of Promises

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.
class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
end
end
BCX::Application.routes.draw do
draw :api
draw :account
draw :session