Skip to content

Instantly share code, notes, and snippets.

View brendanmaguire's full-sized avatar

Brendan Maguire brendanmaguire

  • Dublin, Ireland
View GitHub Profile
@brendanmaguire
brendanmaguire / CatsIOParallelApp.scala
Created March 27, 2018 10:57
Run cats.effect.IO's in parallel
import scala.concurrent.ExecutionContext.Implicits.global
import cats.effect.IO
import cats.implicits._
object CatsIOParallelApp extends App {
def printThreadId(msg: String) =
println(s"${Thread.currentThread.getId} : $msg")
def io(x: String) = IO {
@brendanmaguire
brendanmaguire / sherlock_and_array.clj
Last active January 26, 2018 09:00
Functional Kata Meetup - Clojure solution
; Solution to https://github.com/danielytics/sherlock-and-array/
; Functional Kata meetup https://www.meetup.com/FunctionalKubs/events/246876977/
(defn solve
[s]
(
let [total (reduce + s)]
(defn balanced [arr, accum]
(if (<= (count arr) 1)
false
(
@brendanmaguire
brendanmaguire / dummyserve.py
Created November 21, 2017 16:42
A simple dummy server to print the request to stdout
#!/usr/bin/env python3
"""
Very simple HTTP server in python.
Usage::
./dummyserve [<port>]
Send a GET request::
curl http://localhost
object Minesweeper extends App {
/*
* Solution to http://codingdojo.org/kata/Minesweeper/ (sort of, doesn't read from stdin)
*/
type Row = Int
type Col = Int
def emptyMap= Map[(Row, Col), Int]().withDefaultValue(0)
val rowLen = 4
⍝ Solution that takes a string which may contain parentheses:
⍝ * Get the maximum depth
⍝ * Check that it is balanced
depths←{+\(1 ¯1 0)['()'⍳⍵]}
balanced←{⌊/depths ⍵}
max_depth←{⌈/depths ⍵}
@brendanmaguire
brendanmaguire / runlength.ex
Last active June 9, 2017 08:22
runlength.ex
#
# A solution to the problem defined at https://github.com/marjaimate/runlength/
#
defmodule Runlength do
def encode(string) do
String.codepoints(string)
|> Enum.reverse
|> Enum.reduce([], &char_to_tuples/2)
|> Enum.reduce("", fn ({char, count}, acc) -> "#{acc}#{Integer.to_string(count)}#{char}" end)
// ==UserScript==
// @name wanderbat - remove ad block overlay
// @version 0.1
// @description Remove ad block overlay annoyance from wanderbat site
// @author maguire.brendan@gmail.com
// @match http://airlines.wanderbat.com/
// @grant none
// @require http://code.jquery.com/jquery-1.12.4.min.js
// ==/UserScript==