Skip to content

Instantly share code, notes, and snippets.

View pat's full-sized avatar
🇵🇸
free Palestine 🇵🇸

Pat Allan pat

🇵🇸
free Palestine 🇵🇸
View GitHub Profile
@pat
pat / keybase.md
Last active August 29, 2015 13:56
keybase.md

Keybase proof

I hereby claim:

  • I am pat on github.
  • I am pat (https://keybase.io/pat) on keybase.
  • I have a public key whose fingerprint is EC7D 42D7 1260 7B31 0563 687C 634E 22D8 2DC2 3B4B

To claim this, I am signing this object:

@pat
pat / gist:10643799
Last active August 29, 2015 13:59
Flying Sphinx: Responding to Heartbleed

Hello

The short version: Flying Sphinx servers are no longer vulnerable to the Heartbleed OpenSSL exploit (as of mid-last week), and API credentials are being re-issued automatically.

The detailed version:

As you've very likely heard, the Hearbleed exploit for OpenSSL has had a significant impact on the majority of Internet sites and services. I just want to let you know how this has been addressed with Flying Sphinx.

Firstly, all Sphinx servers have had OpenSSL updated to 1.0.1g last week. Once that was done and the hosting provider for the central API (Heroku) had addressed the issue within their infrastructure, all SSL certificates were then reissued with new private keys and CSRs, and database credentials were cycled as well.

@pat
pat / gist:88acbc9ba03004aa7355
Created October 20, 2014 00:34
Last Minute NYC Gathering

Hello friends in NYC

I've been lurking around this fine city for the past few weeks, and while I've had the pleasure of catching up with some of you, there are others I've not yet seen. And I fly out on Wednesday afternoon. Obviously, my socialising/planning skills have plenty of room for improvement.

However, if anyone wants to grab dinner or a beverage of some description tomorrow (Monday) evening, do let me know. I'm open as to suggestions of where - somewhere that has good food, is easy to get to, and isn't going to be crowded or noisy would be ideal. If this takes your fancy, do let me know via Twitter or some other means :)

And if you can't make it, for whatever reason, well, the fault is all mine, really.

Hope you're all having fun and doing interesting things :)

@pat
pat / migration.rb
Created December 20, 2014 02:03
Slugging logic out of the model.
# For when you're adding the slug column to a model with existing records:
SlugGenerator.slug User, :slug

We've got a model User, and we're adding in the ability for a user to share their actions on Facebook (and likely other social mediums later on). Obviously, not every user wants to do this, so we want to track their preferences on a per-action-type basis.

I figure there's four ways of handling this:

  • Add a boolean column for every setting to the users table.
  • Add a JSON hash column to the users table to store all preferences.
  • Create a new model (UserPreference) and store each setting as a separate boolean column.
  • Create a new model (UserPreference) and perhaps have separate JSON hash columns per social medium (one for Facebook, one for Twitter, etc).

Whichever approach, it'd be really nice to have form objects for just preferences (and ones that handle situations where not all attributes/settings will be available - some users may only have Twitter connected, others only Facebook, etc).

# Within a Reform::Form subclass, for attribute type detection with Formtastic
def column_for_attribute(attribute)
type = options_for(attribute)[:coercion_type]
Column.new type.name.demodulize.downcase.to_sym
end
Column = Struct.new :type
@pat
pat / index_set.rb
Created January 21, 2015 08:43
Mixing Apartment with Thinking Sphinx
# app/lib/index_set.rb
class IndexSet < ThinkingSphinx::IndexSet
private
def indices
# respect index names if they're provided
return super if index_names.any?
# filter indices by current tenant.
suffix = "#{Apartment::Tenant.current_tenant}_core"

MICF Acts on the $20 list that I've seen before and enjoyed:

  • Alan Brough & Casey Bennetto
  • Celia Pacquola
  • Dave Thornton
  • Hannah Gadsby
  • Josh Earl
  • Justin Hamilton
  • Mark Watson
  • Max & Ivan
bundle --local
Resolving dependencies...
Using rake 10.4.2
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.7.0
Using thread_safe 0.3.5
Using tzinfo 1.2.2
Using activesupport 4.1.5
Using builder 3.2.2
For anyone who needs some Ruby/Rails/HTML done in the near future, or knows
someone else who does...
I have some availability for two to three days a week, from late September. For
at least the first six weeks, as part of some wandering around the globe, I
will be based in Bătdâmbâng in Cambodia, so my involvement in any projects will
have to be done remotely (unless you happen to be in Cambodia as well, of
course).
If you need some indication of my experience - I've been working with Ruby and