Skip to content

Instantly share code, notes, and snippets.

View lylo's full-sized avatar

Olly Headey lylo

View GitHub Profile
@lylo
lylo / bingo-caller.rb
Created August 4, 2015 19:24
Bingo Caller
# https://en.wikipedia.org/wiki/List_of_British_bingo_nicknames
nicknames = {
1 => "on its own, number",
2 => "me and you, number",
3 => "cup of tea, ",
4 => "knock at the door, ",
5 => "man alive, number ",
7 => "lucky number ",
8 => "garden gate, ",
10 => "davids den, number",
@lylo
lylo / nps.rb
Created January 6, 2015 11:38
NPS calc in Ruby
class NpsCalculator
def nps(scores)
(promotor_share(scores) - detractor_share(scores)).round
end
private
def promotor_share(scores)
scores.count {|score| score > 8} / scores.count.to_f * 100
@lylo
lylo / support_engineer.md
Last active August 29, 2015 14:01
FreeAgent - Support Engineer (Ruby)

Support Engineer (Ruby)

FreeAgent is one of the UK's largest and most popular online accounting products, helping tens of thousands of freelancers and micro-companies manage their businesses in our simple, stress-free way.

We're looking for a new member to join our Support Engineering team, a crucial area of our business. As a Support Engineer you'll be investigating and responding to second-line, customer-reported technical problems, managing and overseeing the resolution of these issues. We develop almost exclusively in Ruby (and Rails is our web framework of choice), so as you'll be spending a lot of your time in our code base, a passion about Ruby and the web in general is important.

You'll be dealing directly with our customers, as well as working closely with our Engineering and dedicated Customer Support teams to ensure that the FreeAgent experience continues to exceed our customers' expectations. You will also take an active role in Corporate IT, supporting our office

@lylo
lylo / happy_christmas_ruby.rb
Created December 5, 2013 14:59
Happy Christmas from Ruby
s="IyBUaGFua3MgZm9yIGxvb2tpbmcgYXQgbXkgY29kZ
S4KIwojIENvcHlyaWdodCAoQykgMjAwMiAgQ2hyaXN0a
WFuI E 5 l d Wtpc
mNoZ W 4 gP G N obmV
1a2l y Y 2hlb k B nbWF
pbC5 j b 20+CiM K I yBUa
GlzI H Byb2dyYW 0 gaXM
gZnJ l Z SBzb2Z0d2F y Z Tsge
W91I G NhbiByZWRpc3 R yaWJ
1dGU g aXQgYW5kL29yCi M g bW9k
@lylo
lylo / fastmail_fluid_userscript.js
Last active April 14, 2021 08:59
Userscript for Fluid App (http://fluidapp.com) to enable dock count and desktop notifications for Fastmail
// Userscript for Fluid App to enable dock badge and desktop notifications for Fastmail.
//
// Author: @lylo
window.fluid.dockBadge = '';
// for tracking when to notify
let previousUnreadCount = 0;
// Main polling
@lylo
lylo / gist:5663750
Last active December 17, 2015 19:58
Rails 3/3.2 mashalling
class Foo
def initialize(a)
@a = a
end
end
d = Marshal.dump(Foo.new(1))
=> "\x04\bIC:\bFoo{\x00\x06:\a@ai\x06"
Marshal.load("\x04\bIC:\bFoo{\x00\x06:\a@ai\x06")
@lylo
lylo / twitter.php
Created January 12, 2013 22:10
How to display Twitter updates using PHP (and without using curl)
<?php
$doc = new DOMDocument();
# load the RSS -- replace 'lylo' with your user of choice
if($doc->load('http://twitter.com/statuses/user_timeline/lylo.rss')) {
echo "<ul>\n";
# number of <li> elements to display. 20 is the maximum
$max_tweets = 10;
source /opt/local/share/doc/git-core/contrib/completion/git-completion.bash
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export PS1="\h:\w\$(parse_git_branch)$ "
@lylo
lylo / Normalizing characters.rb
Created April 29, 2010 13:21
Converting accented latin characters
# Converting accented latin characters
"Marqués".mb_chars.normalize(:kd).gsub(/[^\x00-\x7F]/n,'')
=> "Marques"
#!/usr/bin/env ruby
#
# Find bloating passengers and kill them gracefully. Run from cron every minute.
#
# required for passenger since cron has no environment
ENV['HTTPD'] = 'httpd'
MEM_LIMIT = ARGV[0] || 500