Skip to content

Instantly share code, notes, and snippets.

@manuelsidler
manuelsidler / ndcoslo2018.txt
Last active June 6, 2018 10:41
NDC Oslo 2018
Wednesday:
* 10:20 - 11:20: The Web That Never Was (https://ndcoslo.com/talk/the-web-that-never-was/)
* 11:40 - 12:40: Tabs, spaces and salaries: a data science detective story (https://ndcoslo.com/talk/functional-programming/)
* 13:40 - 14:40: What We’ve Learned From Billions of Security Reports (https://ndcoslo.com/talk/what-weve-learned-from-billions-of-security-reports/)
* 15:00 - 16:00: Why you should use F# (https://ndcoslo.com/talk/why-you-should-use-f/)
* 16:20 - 17:20: Reinventing MVC pattern for web programming with F# (https://ndcoslo.com/talk/reinventing-mvc-pattern-for-web-programming-with-f/)
* 17:40 - 18:40: An Opinionated Approach to ASP.NET Core (https://ndcoslo.com/talk/an-opinionated-approach-to-asp-net-core/)
Thursday:
* 09:00 - 10:00: Rise of the Tech Influencer - Small steps you can take to increase your reach (https://ndcoslo.com/talk/rise-of-the-tech-influencer-small-steps-you-can-take-to-increase-your-reach/)
@manuelsidler
manuelsidler / 16_exercise.fsx
Created June 21, 2018 18:48
Sort subfolders by folder size in F#
open System.IO
type FolderStatistic = { Name : string
Size : int64 }
let calculateFolderSize (folder : string) =
Directory.GetFiles folder
|> List.ofSeq
|> List.sumBy (fun f -> FileInfo(f).Length)
@manuelsidler
manuelsidler / 22-4_collections-options.fsx
Last active May 25, 2019 14:44
F# collections with Option module
let tryLoadCustomerWithOption customerId =
// customerId // does not work as function is expecting an option type
Some customerId // unwrap value first
|> Option.filter(fun x -> x >= 2 && x <= 7)
|> Option.map(fun x -> sprintf "Customer %i" x)
let tryLoadCustomer customerId =
if customerId >= 2 && customerId <= 7 then Some(sprintf "Customer %i" customerId)
else None
type CheckNumber = CheckNumber of int
type CardNumber = CardNumber of int
type CardType =
| Visa
| Mastercard
type CreditCard = {
CardType : CardType
type Project = { Number : int; Cost : float }
let projects1 =
[
{ Number = 1; Cost = 22.50 };
{ Number = 2; Cost = 10.50 }
]
let projects2 =
[
@manuelsidler
manuelsidler / createlistitem.cs
Created May 21, 2021 14:24
Create list item with people lookup field
var expenseItem = new ListItem
{
Fields = new FieldValueSet
{
AdditionalData = new Dictionary<string, object>
{
{"Title", expense.Title},
{"Zeitpunkt", expense.Date},
{"Betrag", expense.Amount},
{"MitarbeiterLookupId", await GetUserLookupId(expense.User)}