Skip to content

Instantly share code, notes, and snippets.

@mlusiak
mlusiak / redis-complete.fs
Created December 11, 2013 01:40
Putting it all together - get data, save to redis, read back, chart
#if INTERACTIVE
#r "bin/Debug/FSharp.Data.dll"
#r "bin/Debug/FSharp.Charting.dll"
#r "bin/Debug/ServiceStack.Common.dll"
#r "bin/Debug/ServiceStack.Interfaces.dll"
#r "bin/Debug/ServiceStack.Text.dll"
#r "bin/Debug/ServiceStack.Redis.dll"
#load "../packages/FSharp.Charting.0.90.5/FSharp.Charting.fsx"
#endif
open System.IO
@mlusiak
mlusiak / chart.fs
Created December 11, 2013 00:36
Charting data
[for v in allValues -> (v.Timestamp, v.Value)]
|> Chart.Line
|> Chart.WithYAxis(Min = 950.0, Max = 1000.0)
@mlusiak
mlusiak / redis-read.fs
Created December 11, 2013 00:34
Read stuff from redis
[<CLIMutable>]
type BitstampLast = {Id:int64; Timestamp:int; Value:decimal}
let redis = new RedisClient("localhost")
let redisBitstamp = redis.As<BitstampLast>()
let allValues = redisBitstamp.GetAll()
@mlusiak
mlusiak / 1-redis-wrong.fs
Last active December 30, 2015 23:39
Saving some stuff into redis
type BitstampLast = {Id:int64; Timestamp:int; Value:decimal}
let redis = new RedisClient("localhost")
redis.FlushAll()
let redisBitstamp = redis.As<BitstampLast>()
let cp = currentPrice()
let last = {Id = redisBitstamp.GetNextSequence(); Timestamp = fst cp; Value = snd cp}
let stored = redisBitstamp.Store(last)
@mlusiak
mlusiak / getJson.fs
Last active December 30, 2015 23:39
Getting Json from bitstamp.net API and parsing it with Json Type Provider
let getHttp (url: string) =
let req = System.Net.WebRequest.Create(url)
let resp = req.GetResponse()
let stream = resp.GetResponseStream()
let reader = new StreamReader(stream)
let html = reader.ReadToEnd()
resp.Close()
html
type Bitstamp = JsonProvider<""" {"high": "844.00", "last": "714.33", "timestamp": "1386459953", "bid": "713.10", "volume": "81293.11654151", "low": "542.38", "ask": "713.88"} """>
@mlusiak
mlusiak / gist:3969505
Created October 28, 2012 19:09
Zombify install error
PM> Install-Package Zombify -Version 0.0.3
Install failed. Rolling back...
Install-Package : The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and th
e directory name must be less than 248 characters.
At line:1 char:16
+ Install-Package <<<< Zombify -Version 0.0.3
+ CategoryInfo : NotSpecified: (:) [Install-Package], PathTooLongException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand