Skip to content

Instantly share code, notes, and snippets.

View stevenproctor's full-sized avatar

Steven Proctor stevenproctor

View GitHub Profile
@stevenproctor
stevenproctor / loopback.plist
Created July 28, 2017 16:14
OSX Launch Daemon to add loopback address
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>loopback</string>
<key>RunAtLoad</key>
<true/>
<key>ProgramArguments</key>
<array>
@stevenproctor
stevenproctor / index.erl
Created March 10, 2017 06:00
FutureLearn Introduction to Erlang MOOC - WEEK 2: PROGRAMMING CHALLENGE: INDEXING A FILE ASSIGNMENT
-module(index).
-export([get_file_contents/1,
show_file_contents/1,
main/1]).
% Used to read a file into a list of lines.
% Example files available in:
% gettysburg-address.txt (short)
% dickens-christmas.txt (long)
@stevenproctor
stevenproctor / keybase.md
Created September 29, 2016 04:49
keybase.md

Keybase proof

I hereby claim:

  • I am stevenproctor on github.
  • I am proctor (https://keybase.io/proctor) on keybase.
  • I have a public key ASCZGt0FkO-yXpUni3yA2DBA0myAtm3oN2L5ycZRWZLiMwo

To claim this, I am signing this object:

@stevenproctor
stevenproctor / gist:135be29e7f1d457ab3ec
Last active March 2, 2016 15:39
PureScript By Example - Write a fold to determine the largest and smallest files in the filesystem.
onlyFiles :: Path -> Array Path
onlyFiles file = onlyFiles' file []
where
onlyFiles' file files | isDirectory file = do
child <- ls file
onlyFiles' child files
onlyFiles' file files = file : files
safeMin :: Maybe Path -> Maybe Path -> Maybe Path
def do_fizzbuzz(n)
fizz = ['', '', 'fizz'].cycle.lazy
buzz = ['', '', '', '', 'buzz'].cycle.lazy
fizzbuzz = fizz.zip buzz
puts (1..n).
zip(fizzbuzz.map(&:join)).
map {|number, translation| if translation.empty? then number else translation end}.
join("\n")
end
@stevenproctor
stevenproctor / gist:38177ebee5e601e4e153
Created July 9, 2015 15:06
Elixir Experience Problem 15

Problem: 15

Erlang :gen_tcp.connect/3‘s first argument(Address) is either an :inet.ip_address() which is a tuple of octets or an :inet.hostname() which is a char_list. Write a function format_host that takes a string a returns a valid format for :gen_tcp.connect

format_host("192.168.0.1") #=> {192, 168, 0, 1}
  format_host("www.example.com") #=> 'www.example.com'

How about using interop with Erlang to handle a solved problem for you, and take advantage of :inet.parse_strict_address. This solution would also handle IPv6 addresses as well. ;)

@stevenproctor
stevenproctor / Chrome_headers
Last active January 2, 2016 08:28
Issue when `curl`ing site.
Request URL:http://www.functionalgeekery.com/feed/podcast/
Request Method:GET
Status Code:304 Not Modified
Request Headersview source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Cookie:__qca=P0-1012572507-1385437517515; wordpress_test_cookie=WP+Cookie+check; wordpress_logged_in_921aee34bd7b058d3ecda34b629881d8=functionalgeekery%7C1389066714%7C6adbb45f03652e72b43ef1aaa86a5478; wp-settings-1=editor%3Dhtml%26libraryContent%3Dbrowse%26wplink%3D1; wp-settings-time-1=1388894905