Skip to content

Instantly share code, notes, and snippets.

View sparksp's full-sized avatar
🏠
Working from home

Phill Sparks sparksp

🏠
Working from home
View GitHub Profile
@sparksp
sparksp / UnlessKeyed.elm
Last active May 21, 2020 09:57
Html.Events.UnlessKeyed
module Html.Events.UnlessKeyed exposing (onClick)
{-|
@docs onClick
-}
import Html
import Html.Events
@sparksp
sparksp / elm-analyse.json
Created April 6, 2020 16:27
Exclude Tailwind.elm
{
"checks": {},
"excludedPaths": [
"src/Tailwind.elm"
]
}
@sparksp
sparksp / Util.elm
Created December 19, 2019 19:47
Remove an item from an Array by index
{-| Remove the indexed item from the Array
Array.fromList [1, 2, 3, 4]
|> arrayRemove 2
== Array.fromList [1, 2, 4]
-}
arrayRemove : Int -> Array a -> Array a
arrayRemove index array =
Array.append
@sparksp
sparksp / Option.elm
Created December 10, 2019 09:02
Comparison of Elm vs F#
module Option exposing (getOr)
getOr : a -> Maybe a -> a
getOr x val =
case val of
Just v ->
v
Nothing ->
x
@sparksp
sparksp / chroma-blank.css
Last active January 2, 2018 12:55
Chroma CSS Styles
/* Background */ .chroma { background-color: #fff; color: #000 }
/* LineTableTD */ .chroma .lntd { vertical-align: top; padding: 0; margin: 0; border: 0; }
/* LineTable */ .chroma .lntable { border-spacing: 0; padding: 0; margin: 0; border: 0; width: 100%; overflow: auto; display: block; }
/* LineHighlight */ .chroma .hl { background-color: #ffffcc; display: block; width: 100% }
/* LineNumbersTable */ .chroma .lnt { margin-right: 0.4em; padding: 0 0.4em 0 0.4em; display: block; }
/* LineNumbers */ .chroma .ln { margin-right: 0.4em; padding: 0 0.4em 0 0.4em; }
/* Whitespace */ .chroma .w {}
/* Error */ .chroma .err {}
@sparksp
sparksp / compare_readers.go
Last active November 18, 2016 17:50
Compare two io.Readers
package io
// Copyright (c) 2016 Phill Sparks
// License MIT
import (
"bytes"
"fmt"
"io"
)
@sparksp
sparksp / README.md
Last active June 3, 2024 19:17
Exercise: Web Crawler

Exercise: Web Crawler

In this exercise you'll use Go's concurrency features to parallelize a web crawler.

Modify the Crawl function to fetch URLs in parallel without fetching the same URL twice.

Hint: you can keep a cache of the URLs that have been fetched on a map, but maps alone are not safe for concurrent use!

Ref: https://tour.golang.org/concurrency/10

@sparksp
sparksp / try_to_i.rb
Created February 23, 2016 15:59
Try to cast to an integer
def try_to_i(string)
if string.to_i.to_s == string
string.to_i
else
string
end
end
@sparksp
sparksp / keybase.md
Created April 15, 2015 14:18
Keybase proof

Keybase proof

I hereby claim:

  • I am sparksp on github.
  • I am monkeyphill (https://keybase.io/monkeyphill) on keybase.
  • I have a public key whose fingerprint is E1F6 9C04 2276 70D9 B93A 128E 769F DBA7 278B 84A9

To claim this, I am signing this object:

source 'https://rubygems.org'
gem "oj"
gem "activesupport", "~> 4.0.0"
gem "minitest"