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 / about.md
Last active January 5, 2020 16:59
Intcode Quine
@seanhandley
seanhandley / robot.log
Created December 11, 2019 20:23
Debug log from the space hull painting robot @ Advent of Code 2019, Day 11
This file has been truncated, but you can view the full file.
[09340e50][0] RECEIVED 1
[09340e50][0] READ ARG 0 from position 8
[09340e50][0] INPUT 1
[09340e50][0] WRITE 1 to 8
[09340e50][2] READ ARG 0 from position 8
[09340e50][2] READ ARG 1 from absolute position 4
[09340e50][2] JNZ loc 8 is 1 (jumping to loc 350)
[09340e50][350] READ ARG 0 from absolute position 351
[09340e50][350] RB 672
[09340e50][352] READ ARG 0 from absolute position 353
@seanhandley
seanhandley / feedback_looped_amplifiers.txt
Created December 8, 2019 19:26
AoC 2019 Day 7, Part 2
This file has been truncated, but you can view the full file.
# Debug Mode On
[a] READ[1] => 8
[a] IN(8)
[a] WRITE[8] <= 5
[a] READ[8] => 5
[a] READ[4] => 10
[a] READ[5] => 8
[a] ADD(5, 10, 8)
[a] WRITE[8] <= 15
[a] READ[7] => 1
@seanhandley
seanhandley / pi_info.sh
Last active July 16, 2019 06:12
Display Info About Raspberry Pi
# Cheers to the original author https://www.raspberrypi.org/forums/viewtopic.php?t=23440
function pi_info_uptime() {
let upSeconds="$(/usr/bin/cut -d. -f1 /proc/uptime)"
let secs=$((${upSeconds}%60))
let mins=$((${upSeconds}/60%60))
let hours=$((${upSeconds}/3600%24))
let days=$((${upSeconds}/86400))
printf "%d days, %d hours, %d minutes, %d seconds" "$days" "$hours" "$mins" "$secs"
}
SESSION=`curl -s -L -I http://raspberrypi:9091/transmission/web | grep X-Transmission-Session-Id | cut -d' ' -f 2 | sed 's/[[:space:]]*$//'`
curl 'http://raspberrypi:9091/transmission/rpc' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-US,en;q=0.9,fr;q=0.8,ru;q=0.7' -H "X-Transmission-Session-Id: `echo $SESSION`" -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' -H 'Pragma: no-cache' -H 'Content-Type: json' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Referer: http://raspberrypi:9091/transmission/web/' -H 'DNT: 1' --data-binary '{"method":"torrent-add","arguments":{"paused":false,"download-dir":"/mnt/sda1/New","filename":"'"${URL}"'"}}' --compressed --insecure
@seanhandley
seanhandley / constant_troll.rb
Created August 12, 2014 15:43
Ruby Hash Constants are Anything But Constant
irb(main):001:0> I_AM_A_CONSTANT = "I never change"
=> "I never change"
irb(main):002:0> i_am_a_variable = I_AM_A_CONSTANT
=> "I never change"
irb(main):003:0> i_am_a_variable = "I can change"
=> "I can change"
irb(main):004:0> I_AM_A_CONSTANT
=> "I never change"
irb(main):005:0> I_AM_A_CONSTANT_HASH = {contents: "I never change"}
=> {:contents=>"I never change"}
module H3
class Resolution
extend FFI::DataConverter
native_type FFI::Type::INT
RES_RANGE = 0..15
class << self
def to_native(value, _context)
failure unless value.is_a?(Integer) && RES_RANGE.cover?(value)
typedef :ulong_long, :h3_index

Smoky Red Pepper Chicken

Feeds 4.

Goes beautifully with green beans and rice or new potatoes.

Ingredients

  • 3 x Chicken breast fillets
  • 200ml Double cream
@seanhandley
seanhandley / nginx.conf
Created October 12, 2015 13:53
NginX Cache Headers
server {
# ...
# Feed
location ~* \.(?:rss|atom)$ {
expires 1h;
add_header Cache-Control "public";
}
# Media: images, icons, video, audio, HTC