This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Lib | |
import Data.Monoid | |
import Data.Maybe | |
import qualified Data.Map.Strict as Map | |
import Control.Concurrent (threadDelay) | |
import Control.Concurrent.Async | |
import Control.Applicative.Free |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- runs fast | |
{-# LANGUAGE DeriveFunctor #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
module Main where | |
import Control.Monad | |
import Control.Monad.Free.Church | |
import Control.Monad.Free.TH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE DATABASE [OrderedInsert] | |
GO | |
ALTER DATABASE [OrderedInsert] SET ALLOW_SNAPSHOT_ISOLATION ON | |
GO | |
USE [OrderedInsert] | |
GO | |
CREATE TABLE [dbo].[Test]( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (sum-of-squares a b) | |
(+ (square a) (square b))) | |
(define (sum-of-squares-of-max-2 a b c) | |
(if (> a b) | |
(if (> b c) | |
(sum-of-squares a b) | |
(sum-of-squares a c)) | |
(if (> a c) | |
(sum-of-squares a b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SampleViewModel | |
constructor: (values) -> | |
this.title = ko.observable() | |
this.description = ko.observable() | |
this.isPrivate = ko.observable() | |
this.status = ko.observable "Active" | |
this.showApproveReject = ko.computed => @isActive() | |
this.statusUrl = ko.observable() | |
this.privacyUrl = ko.observable() | |
_.extend(this, Backbone.Events) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ConstantsGenerator : IAssetTransformer | |
{ | |
private const char ConstantStartToken = '#'; | |
private const char OpeningBraceToken = '{'; | |
private const char ClosingBraceToken = '}'; | |
private readonly Dictionary<string, string> values; | |
public ConstantsGenerator(Dictionary<string, string> values) | |
{ | |
this.values = values; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var staticDomain = ConfigurationManager.AppSettings["StaticDomain"]; | |
settings.UrlModifier = new StaticDomainUrlModifier(settings.UrlModifier, staticDomain); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Text.XML.HaXml.ParseLazy as PL | |
import Text.XML.HaXml | |
import Text.XML.HaXml.Posn | |
import System.IO | |
main = do | |
inh <- openFile "badges.xml" ReadMode | |
hSetEncoding inh utf8_bom | |
inpStr <- hGetContents inh | |
let (Document _ _ root _) = PL.xmlParse "badges.xml" inpStr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Char | |
import System.Random | |
main = do | |
randomGen <- newStdGen | |
let getR = getRandom randomGen | |
contents <- getContents | |
outputStory . (generateStory 10 getR) $ contents | |
putStrLn "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class Expr | |
case class Var(name: String) extends Expr | |
case class Number(num: Double) extends Expr | |
case class UnOp(operator: String, arg: Expr) extends Expr | |
case class BinOp(operator: String, left: Expr, right: Expr) extends Expr | |
class Plus(left: Expr, right: Expr) extends BinOp("+", left, right) | |
def simplifyTop(expr: Expr): Expr = expr match { | |
case UnOp("-", UnOp("-", e)) => e | |
case BinOp("+", e, Number(0)) => e | |
case BinOp("*", e, Number(1)) => e |
NewerOlder