Skip to content

Instantly share code, notes, and snippets.

# Add this to your Rails 3.2 project to add in approximations of the Rails 4
# finders and disable Rails 2/3 'dynamic' finders.
module ActiveRecord
# Approximations of the new Rails 4 finders
class Relation
def take
first
end
#!/usr/bin/env ruby
# Throwaway script to dump an index's contents to disk, delete the index, then
# re-upload it. Used for testing index templates in Logstash.
#
# Installing the yajl gem is highly recommended for fast JSON, but not required.
require 'rubygems'
require 'yajl/json_gem' rescue require 'json'
require 'elasticsearch'

Hi!

We're looking for a junior to mid level Javascript and/or Ruby developer to join our team at The Exchange Group.

The Exchange Group is best known for online bike marketplace, bikeexchange.com.au, which in the last couple of years has expanded to New Zealand and Germany. We've also added tinitrader.com.au, renoexchange.com.au and furnitureexchange.com.au to the mix.

The application is primarily Ruby on Rails 3.2, which we're planning on upgrading to 4.0 in the near future. We've brought in AngularJS to several sections of the site already: our new search is entirely Angular. As our application grows, we'll be reducing our reliance on a monolithic Rails application and splitting things into UI & API implementations; this is where you'll come in.

The successful applicant will:

@mipearson
mipearson / rubocop.rb
Last active July 7, 2018 13:26
Run Rubocop against all files that are different from upstream's master
#!/usr/bin/env ruby
changed = `git diff --numstat origin/master | awk '{ print $3 }' | grep -E '(\\.rb|\\.rake)$'`
changed = changed.split("\n").select { |c| File.exist?(c) }
if changed.length > 0
system "rubocop #{ARGV.join(' ')} #{changed.join(' ')}"
else
puts "No changes."
@mipearson
mipearson / bm_test.go
Last active August 19, 2021 12:55 — forked from davecheney/bm_test.go
Add an increment of a global variable after each op to ensure the Go compiler isn't being clever about optimisation.
package bm
import (
"testing"
)
var mb = map[string]bool{
"alpha": true,
"beta": true,
"gamma": true,
* * * * 1 black || true
* * * * 2,3 heart_attack
* * * * 4 rm ~/.bash_history
* * * * 5 cd love
require 'spec_helper'
INPUT = <<-EOF
#<PayPal::SDK::Merchant::DataTypes::DoExpressCheckoutPaymentResponseType:0x007fe08b4ff4e8 @Timestamp=Thu, 27 Mar 2014 06:34:56 +0000, @Ack="PartialSuccess", @CorrelationID="XXXXX", @Version="98.0", @Build="10277387", @DoExpressCheckoutPaymentResponseDetails=#<PayPal::SDK::Merchant::DataTypes::DoExpressCheckoutPaymentResponseDetailsType:0x007fe08b4fee30 @Token="XXX", @PaymentInfo=[#<PayPal::SDK::Merchant::DataTypes::PaymentInfoType:0x007fe08b4feca0 @TransactionID=nil, @ParentTransactionID=nil, @ReceiptID=nil, @TransactionType="none", @PaymentType="none", @ExchangeRate=nil, @PaymentStatus="Failed", @PendingReason="none", @ReasonCode="none", @SellerDetails=#<PayPal::SDK::Merchant::DataTypes::SellerDetailsType:0x007fe08b4fe7c8 @PayPalAccountID="XXXXX", @SecureMerchantAccountID="XXXXX">, @PaymentRequestID="4444", @PaymentError=#<PayPal::SDK::Merchant::DataTypes::ErrorType:0x007fe08b4fe570 @ShortMessage="Transaction cannot complete.", @LongMessage="Instruct the customer to retr

https://twitter.com/davecheney/status/447523678561898496

Why do I think Go is more 'distributed' than other languages, and why do I think that is a good thing ?

  1. Go does not have a BDFL, there is no Guido Van Rossem, no Theo De Ralt, etc. We have our spiritual leaders like Rob Pike and Ken Thompson, but their influence is much less immediate.

  2. The very nature of the development of the Go standard library discourages adding new stuff to the standard library.

2a. I believe this is a good thing

package main
import (
"encoding/json"
"io/ioutil"
"os"
"path"
"testing"
"reflect"
"time"
package main
import (
"fmt"
"io/ioutil"
"os"
"path"
)
func BiggestFile(directory string) (string, error) {