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 / 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 / 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 / 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:

A simple Ruby class for uploading really large files to S3 via @envato's awsraw gem.

Until this pull request is merged in, you'll need to use my fork of the gem.

MultipartUploader.new(connection, path, key).upload

Build a Faraday connection as shown below with AWSRaw credentials, then you can re-use it in the uploader.

@pat
pat / gist:6961373
Last active December 25, 2015 10:28
Noting down the basics for file encryption for future reference. Particularly helpful for the next time I need to pass SSL certs around.

Basic encrypting of files to send between people who understand public/private keys.

Encrypting

Generate a random password file. The longer the better (245 characters seems to be the limit for RSA encryption though).

openssl rand 245 > key.file

Composing this into a single tweet is impossible…

What I think we all want:

  • A Rails Camp that is welcoming to newcomers and old hands alike; and
  • A ticket process that is reasonably simple and does not require a large amount of time from organisers (they are volunteers!).

Either of these things alone is difficult, and combining both is clearly challenging.

As I’ve mentioned on Twitter already, there’s been some discussion about evolving the ballot process (mainly with regards to when CC details are collected, but expanding for groups is another option), and this could be an excellent project at this upcoming Rails Camp.

@pat
pat / gist:6482497
Last active December 22, 2015 13:59
Cafes, Restaurants and Bars in Melbourne.

Melbourne CBD

Breakfast / Lunch

  • Postal Hall
  • The Mess Hall
  • Captains of Industry (cafe with a barber, tailor and cobbler sharing the space).

Dinner

@pat
pat / gist:6423135
Created September 3, 2013 12:15
Australian Politics Primer - September 3rd 2013

Disclaimer: as you’ve likely picked up from Twitter, I’m obviously biased. I’m not going to make much of an attempt to avoid that.

Parties, History and Houses

The Australian Federal Election is happening this Saturday. The likely outcome is that our new Prime Minister will be Tony Abbott, a conservative, bible-loving, homophobic misogynist. He’s the leader of the Liberal Party, who aren’t really very good at being liberal. Hence, in Australia, there’s the distinction between big-L Liberal and small-l liberal. The Liberal Party has an ongoing coalition with the National Party, who are also conservatives (perhaps moreso) with a focus on the bush (anywhere that isn’t a city). Together they’re known as the Coalition (yes, I know, it’s imaginative, but they save their creativity for how to best fuck over refugees, women, the poor, and generally anyone whose skin colour isn’t white).

They’re not in power at the moment though – the party running the country currently is the Australian Labor Party (a

@pat
pat / fixed_format.rb
Last active December 22, 2015 01:29
Reliably get the fixed format of a float in Ruby, rather than exponential. BUT: don't use an extraordinarily large number of decimal places, else you'll likely get more precision than you need.
# as a method
def fixed_format(float)
return float if float.to_s['e'].nil?
matches = float.to_s.scan(/(\d+)e\-(\d+)$/).first
# exponent + number of trailing digits
digits = matches.last.to_i + matches.first.length
("%0.#{digits}f" % float).gsub(/0+$/, '')
end
ThinkingSphinx::Index.define :document, with: :active_record, delta: true, sql_range_step: 999999999, group_concat_max_len: 16384 do
#~ How can I optmise this index so that I can have facets and indexes
#~ on each association without it taking forever to run?
#~ Having more than 3 indexes at any one time, means rake ts:index doesn't finish running.
has "SELECT document_id * 2 + 0 as `id`, country_id as `country_ids` FROM `countries_documents` ORDER BY document_id", as: :country_ids, source: :query, facet: true, type: :integer, multi: true
has "SELECT document_id * 2 + 0 as `id`, image_id as `image_ids` FROM `documents_images` ORDER BY document_id", as: :image_ids, source: :query, facet: true, type: :integer, multi: true
has "SELECT document_id * 2 + 0 as `id`, subscriber_id as `subscriber_ids` FROM `documents_subscribers` ORDER BY document_id", as: :subscriber_ids, source: :query, facet: true, type: :integer, multi: true
has "SELECT document_id * 2 + 0 as `id`, video_id as `video_ids` FROM `do