Skip to content

Instantly share code, notes, and snippets.

@ruthenium
ruthenium / uncurryE.hs
Created September 27, 2012 15:34
Little uncurry example.
module Main where
------------------------------------------------------------------------------
{- |
First, define some example functions.
-}
------------------------------------------------------------------------------
foo2 :: Int -> Int -> Int
foo2 a b = a + b
------------------------------------------------------------------------------
@ruthenium
ruthenium / subregex.hs
Created September 16, 2012 15:57
Haskell subRegex with transformer, similar to gsub in ruby and other languages.
import Text.Regex (mkRegex, matchRegexAll, Regex)
------------------------------------------------------------------------------
{- | Taken from the <http://pleac.sourceforge.net/pleac_haskell/strings.html>
'subRegex' allows only a fixed 'String'
This custom version takes a ('String' -> 'String') function to compute
a result.
The function is applied to the all matched results, which are found
@ruthenium
ruthenium / Main.hs
Created September 15, 2012 23:13
Convert a string to CamelCase, mixedCase or under_score just like they do in ruby zucker, but in haskell. Not pure strings and lists, POSIX-Regex approach.
module Main where
import Data.Char (toUpper, toLower)
{- | POSIX Regex approach. -}
import Text.Regex (mkRegex, subRegex, matchRegexAll, Regex)
------------------------------------------------------------------------------
{- | Transforms first element of the 'String' using the function given. -}
transformFst :: (Char -> Char) -> String -> String
transformFst _ "" = ""
@ruthenium
ruthenium / gist:3722863
Created September 14, 2012 16:00
Split string by predicate including the matched element.
-----------------------------------------------------------------------------
{-| Split a 'String', by specified predicate, but do not remove matched
characters from the result.
Not an efficient implementation.
First, it folds a 'String' to a list of Strings.
Elements in the resulting list are in the reversed order, because they
are prepended to the final list, not appended.
At the end, it reverses the result.
@ruthenium
ruthenium / Main.hs
Created September 13, 2012 16:46
Convert a string to CamelCase, mixedCase or under_score. Just like they do in ruby zucker, but in pure haskell.
module Main where
{-|
We use a 'Data.Char' here. Who ever needs to convert
to snake_case or CamelCase unicode strings?..
-}
import Data.Char (toUpper, toLower, isUpper)
-----------------------------------------------------------------------------
@ruthenium
ruthenium / gist:3166588
Created July 23, 2012 22:16
Interesting idea of creating a very thin shadow just after the modal elements of the browser window. From spyrestudious.com
body:before {
content: "";
position: fixed;
top: -10px;
left: 0;
width: 100%;
height: 10px;
-webkit-box-shadow: 0px 0px 10px rgba(0,0,0,.8);
-moz-box-shadow: 0px 0px 10px rgba(0,0,0,.8);
box-shadow: 0px 0px 10px rgba(0,0,0,.8);