Skip to content

Instantly share code, notes, and snippets.

@michaelschade
michaelschade / hs-vcard-example.hs
Created April 28, 2011 03:33
hs-vcard Example
import Text.VCard
vc = VCard "Frank Dawson"
(IndividualNames ["Dawson"] ["Frank"] [] [] [])
[ Organization ["Lotus Development Corporation"]
, Address [AddrWork, AddrPostal, AddrParcel] "" ""
"6544 Battleford Drive"
"Raleigh" "NC" "27613-3502" "U.S.A"
, Telephone [TelVoice, TelMessage, TelWork] "+1-919-676-9515"
, Telephone [TelFax, TelWork] "+1-919-676-9564"
BEGIN:vCard
VERSION:3.0
FN:Frank Dawson
N:Dawson;Frank;;;
ORG:Lotus Development Corporation
ADR;TYPE=WORK,POSTAL,PARCEL:;;6544 Battleford Drive;Raleigh;NC;27613-3502;U.S.A
TEL;TYPE=VOICE,MSG,WORK:+1-919-676-9515
TEL;TYPE=FAX,WORK:+1-919-676-9564
EMAIL;TYPE=INTERNET,PREF:Frank_Dawson@Lotus.com
EMAIL;TYPE=INTERNET:fdawson@earthlink.net
@michaelschade
michaelschade / skeleton-index.html
Created May 20, 2011 21:13
Skeleton HTML Index
<!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><html lang="en"><![endif]-->
@michaelschade
michaelschade / Skeleton.hs
Created May 20, 2011 21:13
Skeleton html' and htmlBody functions
{- These imports will serve us for the remainder of the post -}
import Text.Blaze.Internal
import Text.Blaze.Html5
import Text.Blaze.Html5.Attributes
import qualified Data.ByteString.Char8 as C8
import qualified Data.Text as T
-- | HTML tag with no closing.
html' :: Html -> Html
html' = Parent "html" "<html" ""
@michaelschade
michaelschade / Skeleton.hs
Created May 20, 2011 21:14
Skeleton comment function
-- | Comment combinator. `if` is included, so only condition is needed. E.g.,
--
-- > comment "lt IE 7"
comment :: String -> Html -> Html
comment cond = Parent "comment" (ss cond') "<![endif]-->"
where cond' = "<!--[if " ++ cond ++ " ]"
ss s = StaticString (s ++) (C8.pack s) (T.pack s)
@michaelschade
michaelschade / Skeleton.hs
Created May 20, 2011 21:14
Skeleton htmlTag function
-- | Special set of conditionals for the HTML tag to make Skeleton compatible
-- with all browsers.
htmlTag :: Html
htmlTag = do
comment "lt IE 7" $ htmlEn ! class_ "ie ie6"
comment "IE 7" $ htmlEn ! class_ "ie ie7"
comment "IE 8" $ htmlEn ! class_ "ie ie8"
comment "(gte IE 9)|!(IE)" $ htmlEn
where htmlEn = html' ! lang "en" $ ""
@michaelschade
michaelschade / Skeleton.hs
Created May 20, 2011 21:15
Skeleton in use: skeletonBase
skeletonBase :: String -> String -> Html -> AttributeValue -> AttributeValue
-> Html -> Html
skeletonBase cssDir iconDir title desc author content = do
docType
htmlTag
htmlBody $ do
-- ...
import Control.Monad ( liftM )
import Web.JonathansCard ( latest )
main :: IO ()
main = putStrLn . show =<< latest
{- Outputs:
Right (Balance {balAmount = 28.08, balBalanceId = 25573, balCreated = Just
2011-08-08 00:56:03 UTC, balMessage = "My balance is $28.08 as of Aug 7th at
@michaelschade
michaelschade / gist:2630185
Created May 7, 2012 20:27 — forked from boucher/gist:1750375
Stripe PHP simple example
<?php
require 'path-to-Stripe.php';
if ($_POST) {
Stripe::setApiKey("YOUR-API-KEY");
$error = '';
$success = '';
try {
if (!isset($_POST['stripeToken']))
throw new Exception("The Stripe Token was not generated correctly");
@michaelschade
michaelschade / gist:2847749
Created June 1, 2012 01:04 — forked from boucher/gist:1750375
Stripe PHP simple example
<?php
require 'path-to-Stripe.php';
if ($_POST) {
Stripe::setApiKey("YOUR-API-KEY");
$error = '';
$success = '';
try {
if (!isset($_POST['stripeToken']))
throw new Exception("The Stripe Token was not generated correctly");