Skip to content

Instantly share code, notes, and snippets.

View sean-clayton's full-sized avatar
🎷
🐢

Sean Clayton sean-clayton

🎷
🐢
View GitHub Profile
@sean-clayton
sean-clayton / 1-linkedlist.fs
Last active June 22, 2019 14:19
Linked list operations in a few functional languages
// F#
type LinkedList<'a> =
| Nil
| Node of 'a * LinkedList<'a>
let head =
function
| Nil -> Nil
| Node(x, _) -> x
let fizzBuzz attempt =
match attempt with
| (0, 0, _) -> "FizzBuzz"
| (0, _, _) -> "Fizz"
| (_, 0, _) -> "Buzz"
| (_, _, n) -> n.ToString()
for num in 1..100 do
printfn "%s" (fizzBuzz (num % 3, num % 5, num))
function FingerprintWrapper(e) {
var t = null,
r = new n();
c.rebuildXMLHttpRequest(e.ajax_header), c.fetchAjaxHeaders(e);
var d = function(n) {
if (!t) {
t = n ? n.type : "manual/other";
var d = function(t) {
var r = a();
if (r) {
{
"global": {
"check_for_updates_on_startup": true,
"show_in_menu_bar": true,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"complex_modifications": {
"parameters": {
/**
* Check if the component disabled value is "truthy"
*
* This check is done here due to ngc throwing an error when the logic is in the template
*
* @param disabledValue string or boolean value to evaluate
*/
public isDisabled(disabledValue: boolean | string) {
if (disabledValue === true || disabledValue === "true") {
return true;
-- Eight queens solution in 5 lines of haskell
solution :: [Int]
solution = head (allSolutions !! 8)
allSolutions :: [[[Int]]]
allSolutions = iterate (concatMap extendSolution) [[]]
extendSolution :: [Int] -> [[Int]]
extendSolution qs = map (:qs) $ filter (`okToAdd` qs) [0..7]
@sean-clayton
sean-clayton / count.diff
Created April 22, 2019 03:55
Absinthe Relay count
diff --git a/lib/guildship_web/resolvers/guilds.ex b/lib/guildship_web/resolvers/guilds.ex
index 92501df..7a0d34e 100644
--- a/lib/guildship_web/resolvers/guilds.ex
+++ b/lib/guildship_web/resolvers/guilds.ex
@@ -1,11 +1,22 @@
defmodule GuildshipWeb.Resolvers.Guilds do
- alias Guildship.Guilds
+ import Ecto.Query
+ alias Guildship.{Repo, Guilds}
@sean-clayton
sean-clayton / color.re
Created February 15, 2019 16:22
Color conversion in ReasonML/Bucklescript
open Belt;
[@bs.val]
external unsafeParseInt: (string, int) => Js.Null.t(float) = "parseInt";
[@bs.val] [@bs.scope "Math"] external floor: float => int = "floor";
type result('a, 'b) =
| Ok('a)
| Error('b);
@sean-clayton
sean-clayton / random-digit-string.js
Last active February 2, 2019 02:11
Create a random n-digit string in JS.
function randomDigitString(n) {
var x = n;
if (typeof n !== "number") x = 1;
if (n < 1) x = 1;
if (n > 19) x = 19;
return Math.random().toString().substr(2, x);
}