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
open System | |
open System.Data | |
open System.ComponentModel | |
let createDataTable (data: seq<'T>) : DataTable = | |
let table = new DataTable() | |
let props = TypeDescriptor.GetProperties(typeof<'T>) | |
// Add columns | |
for prop in props do |
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
open FSharp.Data | |
[<Literal>] | |
let SampleUrl = "file://" + __SOURCE_DIRECTORY__ + "/Sample.html" | |
[<Literal>] | |
let PageUrl = "https://phw.nhs.wales/news/public-health-wales-statement-on-novel-coronavirus-outbreak/" | |
type Page = HtmlProvider<SampleUrl> |
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
open System.IO | |
type MathLlwybr = | |
| File of Length: int64 | |
| Directory | |
//let llwybr1 = fsi.CommandLineArgs.ElementAt(1) | |
let dirChars = [| Path.DirectorySeparatorChar ; Path.AltDirectorySeparatorChar |] |> Array.distinct |
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
require 'fileutils' | |
inputDirectory = "/home/ellyll/Dropbox/Arbrofion/TextReplacer" | |
outputDirectory = "/tmp/ReplacedFiles" | |
replacementsFile = "/home/ellyll/Dropbox/Arbrofion/TextReplacer/replacements.csv" | |
# Read replacements csv file | |
replacements = File.readlines(replacementsFile).collect {|line| line.chomp.split(",") } | |
replacements.each {|r| puts "replace \"#{r[0]}\" with \"#{r[1]}\"" } |
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 com.eclipsesource.json.Json | |
import com.eclipsesource.json.JsonObject | |
import com.eclipsesource.json.JsonValue | |
// Recursively get JSON values for all properties in a JSON object with the given key name | |
fun getAllWithName(jsonObj : JsonObject, keyName : String) : ArrayList<JsonValue> { | |
val keys = jsonObj.names() | |
return keys.fold(ArrayList<JsonValue>()) { acc, key -> | |
val value = jsonObj.get(key) | |
if (key == keyName) { |
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
let fizzBuzz n = | |
if n % 3 = 0 && n % 5 = 0 then "FizzBuzz" | |
elif n % 3 = 0 then "Fizz" | |
elif n % 5 = 0 then "Buzz" | |
else (sprintf "%d" n) | |
let a = seq { 1 .. 20 } | |
a | |
|> Seq.iter (fun n -> printfn "%d: %s" n (fizzBuzz n)) |
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
using System.IO; | |
using System.Linq; | |
namespace SortingExample | |
{ | |
public class Sorter | |
{ | |
static void Main(string[] args) | |
{ | |
var lines = File.ReadAllLines(args[0]).OrderBy(a => a); |
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
require 'net/http' | |
require 'json' | |
http = Net::HTTP.new('haveibeenpwned.com',443) | |
http.use_ssl = true | |
addresses = %w(foo@bar.com) # Add your addresses here separated by spaces | |
http.start | |
addresses.each do |email_address| | |
res = http.get("/api/v2/breachedaccount/#{email_address}") |