Skip to content

Instantly share code, notes, and snippets.

View draptik's full-sized avatar

Patrick Drechsler draptik

View GitHub Profile
@swlaschin
swlaschin / DependencyInjection.fsx
Last active April 13, 2022 17:37
Code examples from fsharpforfunandprofit.com/posts/dependencies-3/
(* ===================================
Code from my series of posts "Six approaches to dependency injection"
=================================== *)
open System
(* ======================================================================
4. Dependency Injection
Byobu is a suite of enhancements to tmux, as a command line
tool providing live system status, dynamic window management,
and some convenient keybindings:
F1 * Used by X11 *
Shift-F1 Display this help
F2 Create a new window
Shift-F2 Create a horizontal split
Ctrl-F2 Create a vertical split
Ctrl-Shift-F2 Create a new session
// The NUnit and Chessie Nuget packages are required for this
// To install NUnit and Chessie run the following commands from the Package Manager Console
// PM> Install-Package NUnit -Version 2.6.4
// PM> Install-Package Chessie
using System;
using System.Text.RegularExpressions;
using Chessie.ErrorHandling;
using Chessie.ErrorHandling.CSharp;
using Microsoft.FSharp.Core;
@DanDiplo
DanDiplo / JS-LINQ.js
Last active October 31, 2024 12:33
JavaScript equivalents of some common C# LINQ methods. To help me remember!
// JS array equivalents to C# LINQ methods - by Dan B.
// First: This version using older JavaScript notation for universal browser support (scroll down for ES6 version):
// Here's a simple array of "person" objects
var people = [
{ name: "John", age: 20 },
{ name: "Mary", age: 35 },
{ name: "Arthur", age: 78 },
{ name: "Mike", age: 27 },
@NickTomlin
NickTomlin / highlight-snippet
Last active April 15, 2017 22:18
Step through reveal.js code as fragments
// stolen from http://stackoverflow.com/a/25396283
// add this in the "callback" block of the highlight plugin definition
// https://github.com/hakimel/reveal.js/blob/master/index.html#L399
[].forEach.call( document.querySelectorAll( '.highlight' ), function( v, i ) {
hljs.highlightBlock(v);
});
@vkhorikov
vkhorikov / CustomerController.cs
Last active July 30, 2024 14:25
Handling failures and input errors in a functional way
[HttpPost]
public HttpResponseMessage CreateCustomer(string name, string billingInfo)
{
Result<BillingInfo> billingInfoResult = BillingInfo.Create(billingInfo);
Result<CustomerName> customerNameResult = CustomerName.Create(name);
return Result.Combine(billingInfoResult, customerNameResult)
.OnSuccess(() => _paymentGateway.ChargeCommission(billingInfoResult.Value))
.OnSuccess(() => new Customer(customerNameResult.Value))
.OnSuccess(
@swlaschin
swlaschin / enterprise-tic-tac-toe-2.fsx
Last active June 5, 2023 22:16
Follow up to the example of implementing "enterprise" tic-tac-toe in a functional way.
(*
enterprise-tic-tac-toe-2.fsx
Follow up to the example of implementing "enterprise" tic-tac-toe in a functional way.
* Added true capability based security.
Related blog post: http://fsharpforfunandprofit.com/posts/enterprise-tic-tac-toe-2/
*)
@davidfowl
davidfowl / dotnetlayout.md
Last active November 13, 2024 13:19
.NET project structure
$/
  artifacts/
  build/
  docs/
  lib/
  packages/
  samples/
  src/
 tests/
@soheilhy
soheilhy / nginxproxy.md
Last active October 23, 2024 08:19
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers