Skip to content

Instantly share code, notes, and snippets.

View ljsc's full-sized avatar

Lou Scoras ljsc

  • Bloomberg LP
  • Washington, DC
View GitHub Profile

Stephen's Shitlist

Person/Place/Thing Shit-storm level (tm)
Obama / Healthcare ![1][poo] ![2][poo] ![3][poo] ![4][poo] ![5][poo]
ERB and HAML templates ![1][poo] ![2][poo] ![3][poo] ![4][poo] ![5][poo]
Matt Newton Metaprogramming ![1][poo] ![2][poo] ![3][poo] ![4][poo] ![5][poo]
T-Mobile ![1][poo] ![2][poo] ![3][poo] ![4][poo] ![5][poo]
John ![1][poo]
Ruby Hash Rockets ![1][poo] ![2][poo] ![3][poo] ![4][poo] ![5][poo]

Stephen's Shitlist

Person/Place/Thing Shit-storm level (tm)
Obama / Healthcare ![1][poo] ![2][poo] ![3][poo] ![4][poo] ![5][poo]
ERB and HAML templates ![1][poo] ![2][poo] ![3][poo] ![4][poo] ![5][poo]
Matt Newton Metaprogramming ![1][poo] ![2][poo] ![3][poo] ![4][poo] ![5][poo]
T-Mobile ![1][poo] ![2][poo] ![3][poo] ![4][poo] ![5][poo]
John ![1][poo]
import Html as H
import Html ((:=))
intercalate : String -> [String] -> String
intercalate s ss = concat (intersperse s ss)
shadow : Float -> Float -> Float -> Float -> Float -> Float -> String
shadow x y b h s l = intercalate " " [H.px x , H.px y, H.px b] ++ " " ++ H.color (hsl h s l)
greeting : Float -> Element
;; take your make-guess function
(defn make-guess [guess]
(/ (+ (/ 2.0 guess) guess) 2.0))
;; and iterate to a lazy-seq of approximations
(def guesses (iterate make-guess 1.0))
;; then we can zip the list with itself, but shifted one value
;; this gives us a seq of guess pairs.
(def guess-pairs
@ljsc
ljsc / Fizzbuzz.hs
Last active August 29, 2015 14:00
YAFBI: Yet Another Fizz-Buzz Implementation
--
-- Haskell version for comparison, just because ;)
--
module Fizzbuzz where
import Control.Conditional (condDefault)
doFizz :: Int -> IO ()
doFizz = sequence_ . map putStrLn . fizzbuzz
fizzbuzz :: Int -> [String]
@ljsc
ljsc / ufind.rb
Created March 26, 2014 01:26
Unoptimized Union-Find algorithm in Ruby.
class UnionFind
def initialize(universe)
@data = {}
universe.each do |element|
@data[element] = element
end
end
def find(n)
root = n
@ljsc
ljsc / fizzbuzz.rb
Created November 12, 2013 05:40
East oriented fizzbuzz
module FizzBuzz
class Runner
attr_writer :handlers
def initialize(output)
@output = output
end
def run(n)
n.times { |n| round(n+1) }
@ljsc
ljsc / gist:6250375
Created August 16, 2013 14:25
Combining contravariant functors?
type Prop = String
type Value = String
newtype ChartConf = Conf { toList :: [(Prop, Value)] } deriving Show
newtype Charter a = Charter { runCharter :: a -> ChartConf }
instance Monoid ChartConf where
mempty = Conf []
c1 `mappend` c2 = Conf $ toList c1 `mappend` toList c2
@ljsc
ljsc / AffineTime.hs
Created August 10, 2013 13:40
Messing around with the haskell thyme package.
import Data.Thyme hiding (seconds)
import Data.Thyme.Format.Human
import Data.AffineSpace
import Data.VectorSpace
seconds, minutes, hours, days, weeks :: Rational -> NominalDiffTime
seconds n = fromSeconds n
minutes n = n *^ 60 *^ seconds 1
hours n = n *^ 60 *^ minutes 1
days n = n *^ 24 *^ hours 1
@ljsc
ljsc / gist:5816855
Last active December 18, 2015 17:09 — forked from richmolj/gist:5811358
Add factory method.
class Post
# Make the DI overhead a bit more bareable with a factory method. You can
# still use the default constructor if you need the extra flexibility.
#
# I'm not quite sure about this last parameter though for the should_order.
# Most of the time passing a boolean is a code smell that you have some unwanted
# control coupling...
#
def self.standard_post(should_order)
alarm_handler = AlarmHandler.new(:post_search)