Skip to content

Instantly share code, notes, and snippets.

@okeeffe
okeeffe / find_pairs_on_condition.sql
Created January 25, 2017 18:08
SQL Query to find the pairs of employees where one is younger than the other
/*
SQL Query to find the pairs of employees where one is younger than the other.
To test, try it here: http://www.w3schools.com/sql/trysql.asp?filename=trysql_select_all
*/
SELECT e1.FirstName AS Younger, e2.FirstName AS Older
FROM Employees AS e1
JOIN Employees AS e2 ON e1.BirthDate > e2.BirthDate;
@okeeffe
okeeffe / nested_counting.sql
Created January 25, 2017 18:00
SQL Query to find the CustomerIDs of all the customers who have the most orders
/*
SQL Query to find the CustomerIDs of all the customers who have the most orders.
Could be 1 or more.
To test, try it here: http://www.w3schools.com/sql/trysql.asp?filename=trysql_select_all
*/
SELECT CustomerID FROM Orders
GROUP BY CustomerID
HAVING COUNT(CustomerID) = (
@okeeffe
okeeffe / lexicographical_nested_list_comp.py
Created January 25, 2017 12:51
Nested list comprehension for 3D coordinates in lexicographical order
if __name__ == '__main__':
"""Print the coordinates of the 3D cuboid (after recieving dimensions) that do not exceed the 4th input param.
Sample input:
1
1
1
2
Sample output:
[[0, 0, 0], [0, 0, 1], [0, 1, 0], [1, 0, 0], [1, 1, 1]]"""
@okeeffe
okeeffe / do_as_instructed.py
Created January 25, 2017 12:19
Code to work on a list as instructed from stdin
if __name__ == '__main__':
"""Code to work on a list as instructed by stdin.
Sample input (first number is # of instructions to follow):
12
insert 0 5
insert 1 10
insert 0 6
print
remove 6

Keybase proof

I hereby claim:

  • I am okeeffe on github.
  • I am okeeffe (https://keybase.io/okeeffe) on keybase.
  • I have a public key ASCzlmnpy62Zbbwzjn6TqIIfBPH-vzTkG2W7AFIS5r06Ago

To claim this, I am signing this object:

@okeeffe
okeeffe / roman.rb
Last active April 27, 2016 15:21
roman.rb - My third Ruby kata, and thankfully far more in tune with my brain than the last one!
# CONSTANTS
ROMAN_TO_VAL = {
I: 1,
V: 5,
X: 10,
L: 50,
C: 100,
D: 500,
M: 1000,
IV: 4,
@okeeffe
okeeffe / regexp.rb
Last active April 25, 2016 16:31
regexp.rb - My second Ruby kata. Nearly killed me, for some reason.
class Regexp
def self.split_num_into_subranges(rounded_min, num)
# 256 -> 200..249 & 250..256
range_arr = []
num_arr = num.to_s.chars
i = num_arr.length - 1
# > 0 to avoid changing the first digit
while i > 0
# Save the original number (max of the subrange)
@okeeffe
okeeffe / lcd.rb
Last active April 5, 2016 18:28
lcd.rb mk1 - My first Ruby kata. Abandon hope all ye who enter here.
# TO RUN: download, cd into the dir and: ruby lcd.rb 12 (for default size of 2)
# or ruby lcd.rb -s 4 9346433
# CONSTANTS
MIDDLE_SEGMENT_IDX = 1
DEFAULT_SIZE = 2
DEFAULT_NUM = '0'.freeze
ZERO = [' - ', '| |', ' ', '| |', ' - '].freeze

CSS3 hover text animate in div

A Pen by Richard Bray on CodePen.

License.

So awesome I had to save it as a gist for future reference. Nice one Richard!