Skip to content

Instantly share code, notes, and snippets.

View seanhandley's full-sized avatar
🧀
Eating cheese

Sean Handley seanhandley

🧀
Eating cheese
View GitHub Profile
@seanhandley
seanhandley / docker-compose.yml
Last active June 7, 2024 19:25
How To Set Up Docker For Mac (Mojave) with Native NFS
version: '2'
services:
api:
volumes:
- "nfsmount:${CONTAINER_DIR}"
volumes:
nfsmount:
driver: local
driver_opts:
MIN_LENGTH = 3
def max_product(collection)
raise "Minimum collection size is #{MAX_LENGTH}" if collection.length < MIN_LENGTH
collection.sort.last(MIN_LENGTH).reduce(:*)
end
max_product([2, 4, 1, 3, -5, 6])
# => 72
irb(main):001:1* def make_methods(&blk)
irb(main):002:1* (1..100).each { |i| define_method("number_#{i}".to_sym) { blk.call(i) } }
irb(main):003:0> end
=> :make_methods
irb(main):004:0>
irb(main):005:0> make_methods { |i| i }
=> 1..100
irb(main):006:0>
irb(main):007:0> puts number_2 # => 2
2
0.0.0.0 r4.sn-cxaaj5o5q5-tt16.googlevideo.com
0.0.0.0 r3.sn-q5u5bgv02-3c26.googlevideo.com
0.0.0.0 r12.sn-bvvbax-hn26.googlevideo.com
0.0.0.0 r7.sn-w5nuxa-o536.googlevideo.com
0.0.0.0 r1.sn-4g5e6n76.googlevideo.com
0.0.0.0 r3.sn-4g5e6n76.googlevideo.com
0.0.0.0 r4.sn-4g5e6n76.googlevideo.com
0.0.0.0 r5.sn-4g5e6n76.googlevideo.com
0.0.0.0 r6.sn-4g5e6n76.googlevideo.com
0.0.0.0 r1.sn-nx5e6n76.googlevideo.com
@seanhandley
seanhandley / cable.yml
Created February 15, 2017 11:19
Using Redis Auth with ActionCable
default: &default
adapter: redis
url: redis://localhost:6379/1
development:
<<: *default
test:
<<: *default
@seanhandley
seanhandley / 371vs372.diff
Created July 17, 2021 09:30
Diff of H3 lib function names from 3.7.1 to 3.7.2
10c10
< __faceIjkPentToGeoBoundary
---
> __faceIjkPentToCellBoundary
13a14
> __faceIjkToCellBoundary
15d15
< __faceIjkToGeoBoundary
25a26
> __gridDiskDistancesInternal
@seanhandley
seanhandley / a.rb
Last active November 17, 2020 21:09
Finding Raffle Numbers @ RubyConf2020
# Greedy Approach with Array#product
#
# $ time ruby a.rb
# Found it! Your raffle number is f8ryt
# real 2m12.019s
# user 2m7.764s
# sys 0m3.383s
require 'digest'
@seanhandley
seanhandley / 1) InstallSublime.sh
Last active August 22, 2020 09:34
How to install Sublime Text 3 on CentOS
wget http://c758482.r82.cf2.rackcdn.com/sublime_text_3_build_3059_x32.tar.bz2
tar vxjf sublime_text_3_build_3059_x32.tar.bz2
sudo mv sublime_text_3/ /opt/
sudo ln -s /opt/sublime_text_3/sublime_text /usr/bin/sublime
@seanhandley
seanhandley / gist:3089541
Created July 11, 2012 10:33
Gists - The second class citizens of Github

Gists - The second class citizens of Github

So, let me start by saying that gists are awesome. There's no faster, simpler way for me to share code snippts with syntax highlighting for all to see, clone, comment on and assist with.

Marvellous.

But something has been bothering me about gists for some time. A "Gist" in Github parlance, is a git repository backed file (or set of files) which can be edited in the browser by the owner and commented on by other users. Each edit is a github commit (with a commit SHA) and you can link people to different versions of a diff via a URL.

What I wish you could do is link people to diffs themselves, as you can with a full github repository.

@seanhandley
seanhandley / plane_with_case.ex
Last active April 29, 2020 18:53
Elixir Pattern Matching
defmodule Plane do
defstruct is_fueled?: false, has_pilot?: false
def take_off(plane) do
case plane do
%Plane{ is_fueled?: false } ->
:needs_fuel
%Plane{ has_pilot?: false } ->
:needs_pilot
_ ->