Skip to content

Instantly share code, notes, and snippets.

@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);
@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: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 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 / 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 / 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
------------------------------------------------------------------------------
"""
A newforms widget and field to allow multiple file uploads.
Created by Edward Dale (www.scompt.com)
Released into the Public Domain
"""
from django.utils.encoding import force_unicode
from django.utils.datastructures import MultiValueDict
from django.utils.translation import ugettext
@ruthenium
ruthenium / sweph.cs
Created April 13, 2013 14:56
Swiss Ephemeris wrapper taken from RadixPro engine source code.
/***************************************************************************
Copyright (C) 2008 RadixPro/Jan Kampherbeek (http://radixpro.org).
This program is free software; you can redistribute it and/or
modify it under the terms of both the GNU General Public License (GPL).
You should also adhere to the terms of the Swiss Ephemerice
License (SEPL).
The GPL is published by the Free Software Foundation; either version 3
of the License, or (at your option) any later version is effective.
The SEPL (Swiss Ephemeris License) is published by AstroDienst; either
@ruthenium
ruthenium / simpleInheritance.hs
Created June 4, 2014 19:33
Simple Inheritance and overloading using typeclasses in haskell
import Text.Printf (printf)
-----------------------------------------------------------------------------
{- interface: -}
data BaseObject = BaseObject { baseObjectA :: Int } -- the top-level object
class WithInheritedActions a where
-- inherited actions:
action1 :: a -> IO ()
--action2 :: a -> Foo
@ruthenium
ruthenium / super.hs
Created June 4, 2014 19:34
Inheritance and overloading with 'super' action
{-# LANGUAGE TypeFamilies, StandaloneDeriving #-}
{- anti-pattern warning -}
{-
Say, we need to "inherit" some behavior from another object.
Say, we also need to be able to customize overloaded actions,
preserving the ability of using the original action.
This is the one of the approaches.