Skip to content

Instantly share code, notes, and snippets.

Dave Curylo ninjarobot

  • Virtustream, Inc.
  • Atlanta, GA
Block or report user

Report or block ninjarobot

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ninjarobot
ninjarobot / RoadToFSharp.md
Last active May 25, 2019
How I ended up as an F# developer.
View RoadToFSharp.md

My Road to F#

I came from the OOP world, most of my professional work was in Java or C#. The languages were similar, and I could use them interchangably as I built software in each of them for several years. With enough experience in both, I was comfortable with either ecosystem and could generally be productive in either. Sometimes the job required one or the other. Sometimes the target OS constrained my choice to Java, which frustrated me a bit, because the languages were so similar, why would the runtime try to restrict a choice? I enjoyed writing server applications on Unix in college, and Linux afterwards, because the machines were so easy to configure compared to Windows machines that took a few hours to install and configure to get my software running. On Linux, I could type a handful of commands into a newly installed system and be up and running.

Sometime around 2005, Java had stagnated while C# was flourishing. They both released generics, but then C# came out with new features like

View system.drawing.colors.pdf
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ninjarobot
ninjarobot / ExampleTypedWebParts.md
Last active Jan 17, 2019
Composing web handlers with type safety in Suave or Giraffe
View ExampleTypedWebParts.md

Type Safe Composition of HTTP Handlers in Suave and Giraffe

Suave and Giraffe are functional web frameworks that work based on composition of handlers. A handler is a function that accepts an HttpContext and returns an Async<HttpContext option>, fitting nicely into an HTTP server's protocol of accepting HTTP messages with a request and some metadata, then returning a message with that metadata and a response. This makes the WebPart in Suave, for example.

While the frameworks themselves only allow you to put a WebPart into the processing pipeline, it is entirely up to you how you compose functions together to get that WebPart. When you compose WebPart A and WebPart B (or HttpHandler A and HttpHandler B), you are using the a compose operator - >=>. Take a look at the function:

let compose (first : 'a -> Async<'b option>) (second : 'b -> Async
@ninjarobot
ninjarobot / dotnet.yaml
Last active Mar 28, 2019
Ansible playbook to install the .NET Core SDK on an Ubuntu server.
View dotnet.yaml
---
- hosts: all
tasks:
- name: Download MS product repository
get_url:
url: https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb
dest: /tmp/packages-microsoft-prod.deb
- name: Install MS product repository
apt: deb=/tmp/packages-microsoft-prod.deb
become: true
@ninjarobot
ninjarobot / littlesuave.sh
Created Aug 22, 2018
Script to make a build a tiny running Suave server
View littlesuave.sh
#!/bin/bash
dotnet new console -n littleSuaveApp -lang F#;
cd littleSuaveApp;
dotnet add package suave;
awk '/open System/{print "open Suave"}; /0/{print " startWebServer { defaultConfig with bindings = [ HttpBinding.createSimple HTTP \"0.0.0.0\" 8080 ] } (Successful.OK \"Hello World!\")"}1' Program.fs > tmp.fs;
mv tmp.fs Program.fs;
dotnet publish -c Release;
@ninjarobot
ninjarobot / processing-a-delimited-string.md
Last active Jul 19, 2018
Processing a delimited string
View processing-a-delimited-string.md
?- S = "the|little|brown|fox|lost|its|way", split_string(S,"|","",Strings), maplist(string_length,Strings,Lengths), list_to_set(Lengths,Set).
S = "the|little|brown|fox|lost|its|way",
Strings = ["the", "little", "brown", "fox", "lost", "its", "way"],
Lengths = [3, 6, 5, 3, 4, 3, 3],
Set = [3, 6, 5, 4].
@ninjarobot
ninjarobot / parsing_json.pl
Created Jul 6, 2018
Parsing a JSON string in SWI-Prolog
View parsing_json.pl
?- use_module(library(http/json_convert)).
true.
?- json:atom_json_term('{"foo":"bar"}',T, []), T=json(J), J.foo=Bar.
T = json([foo=bar]),
J = [foo=bar],
Bar = bar.
@ninjarobot
ninjarobot / brew_install_nsd.sh
Created May 25, 2018
Installing nsd on macOS with brew
View brew_install_nsd.sh
$ brew install nsd
==> Installing dependencies for nsd: openssl, libevent
==> Installing nsd dependency: openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2o_1.high_sierr
######################################################################## 100.0%
==> Pouring openssl-1.0.2o_1.high_sierra.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), place .pem files in
View paket-mkbundle.sh
apt-get update && apt-get install -y gcc
mkbundle --simple --machine-config /etc/mono/4.5/machine.config --config /etc/mono/config -L /usr/lib/mono/4.5 --library /usr/lib/libmono-btls-shared.so -o paket paket.exe
@ninjarobot
ninjarobot / paket-mkbundled-install.log
Last active May 8, 2018
Attempting a paket install with mkbundled paket
View paket-mkbundled-install.log
Paket version 5.156.7
found: /src/suaveapp/paket.dependencies
Parsing /src/suaveapp/paket.dependencies
Resolving packages for group Main:
0 packages in resolution.
1 requirements left
- Suave, 2.2.1 (from /src/suaveapp/paket.dependencies)
Trying to resolve Suave 2.2.1 (from /src/suaveapp/paket.dependencies)
Performance:
You can’t perform that action at this time.