Skip to content

Instantly share code, notes, and snippets.

Romain Gehrig RomainGehrig

Block or report user

Report or block RomainGehrig

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
RomainGehrig /
Created Feb 27, 2018
Import DBUS variables of the current user
# Source dbus variables to enable dbus-dependant commands, like notify-send
# Integrate this gist in a script where you want to use said commands
# /!\ Security is not guaranteed, be careful when sourcing external files
set -o allexport
source $(readlink -f ~/.dbus/session-bus/*)
set +o allexport
RomainGehrig / fastMappend.hs
Last active Apr 30, 2019
Use a technique similar to fast exponentiation for repeatedly `mappend`ing the same monoid
View fastMappend.hs
import Data.Monoid
import Data.Function (on)
import System.Environment
-- | Apply repeatedly `mappend` on a monoid
-- | Uses the associativity and the identity element of monoids
fastMappend :: (Monoid a) => a -> Integer -> a
fastMappend x n = iter x n mempty
where iter :: (Monoid a) => a -> Integer -> a -> a
iter _ 0 acc = acc
You can’t perform that action at this time.