Skip to content

Instantly share code, notes, and snippets.

Avatar
👾

Gideon Farrell gfarrell

👾
View GitHub Profile
@gfarrell
gfarrell / FunDeps.hs
Last active March 2, 2023 22:12
Explaining functional dependencies in Haskell
View FunDeps.hs
{- stack script --resolver lts-20.5 -}
-- @FunctionalDependencies@ is a useful extension allowing us to resolve the
-- ambiguity inherently arising in multi-parameter typeclasses. Such typeclasses
-- can be useful, but sometimes unergonomic as it can be impossible to solve for
-- certain type variables.
--
-- For a multiparam typeclass @X@ over two parameters @a@, @b@, there is a
-- potentially infinite combination of @a@s and @b@s. This means that if I
-- have a member function @f :: X a b => a -> b@ then I can't know the type
@gfarrell
gfarrell / promises-as-monads.ts
Created April 18, 2022 16:17
Can we treat Promises as Monads?
View promises-as-monads.ts
// Proposition: Promise is equivalent to a loosely typed `ExceptT e IO a` for
// javascript, and fundamentally obeying the monad laws, making it a
// helpful construction for writing computations.
// class Monad m where
// return :: a -> m a
// (>>=) :: m a -> (a -> m b) -> m b
//
// Monad laws:
// Left identity: return a >>= f ≡ f a
@gfarrell
gfarrell / results.txt
Last active June 29, 2017 15:54
Sorting performance: Strings VS. Numbers
View results.txt
~/sandbox > node strings-vs-ints.js 1000000 32
Sorting 1000000 numbers of magnitude 10^32
Sorting 1000000 strings of length 32
Numbers: 461
Strings: 1445
~/sandbox > node strings-vs-ints.js 1000000 32
Sorting 1000000 numbers of magnitude 10^32
Sorting 1000000 strings of length 32
Numbers: 494
Strings: 1500
View pageload.js
$(window).on('load', function() {
var fragment = window.location.hash;
if(fragment != "") {
$('body').animate({
scrollTop: $(fragment).offset().top
});
}
});
@gfarrell
gfarrell / npm-debug.log
Created September 21, 2014 12:54
npm-debug.log for npm install --save gfarrell/state.js
View npm-debug.log
0 info it worked if it ends with ok
1 verbose cli [ 'node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'install',
1 verbose cli '--save',
1 verbose cli 'gfarrell/state.js~0.1.0' ]
2 info using npm@1.4.10
3 info using node@v0.10.28
4 verbose node symlink /usr/local/bin/node
5 warn package.json PresenceMonitor@0.0.1 No repository field.
@gfarrell
gfarrell / dabblet.css
Created August 28, 2014 09:49
RAVN Preloader
View dabblet.css
/**
* RAVN Preloader
*/
body {
background: black;
text-align: center;
}
.logo {
View Simple $_GET example for Leo
<?php
// First we get the variable we want to look at from the $_GET array
$page = $_GET['p'];
// We should never trust the user's input to be safe
// So let's restrict the possibilities with a switch() statement
// If the input is invalid, we return some sort of error
switch($page) {
case 'home':
// show the home page text
View dabblet.css
/**
* Octagon
*/
.octagon {
width: 100px;
height: 100px;
position: absolute;
top: 0;
bottom: 0;
@gfarrell
gfarrell / dabblet.css
Created May 13, 2014 17:35
Quattro progress indicator
View dabblet.css
/**
* Quattro progress indicator
*/
.quattro-progress {
border: #CCC 10px solid;
border-radius: 50%;
width: 100px;
height: 100px;
transform: rotate(45deg);
@gfarrell
gfarrell / dabblet.css
Created May 12, 2014 12:09
Round progress indicator
View dabblet.css
/**
* Round progress indicator
*/
.round-progress-indicator {
width:150px;
height: 150px;
}
.round-progress-indicator span {