Skip to content

Instantly share code, notes, and snippets.

View naartjie's full-sized avatar

Marcin Jekot naartjie

View GitHub Profile
#r "nuget: FsHttp, 9.1.2"
open FsHttp
open System
let getSize url =
async {
let! r =
http {
HEAD url
(* lang = F# *)
seq { 1 .. 100 }
|> Seq.map (function
| x when x % 3 = 0 && x % 5 = 0 -> "CracklePop"
| x when x % 3 = 0 -> "Crackle"
| x when x % 5 = 0 -> "Pop"
| x -> x.ToString())
|> Seq.iter (printfn "%s")
@naartjie
naartjie / object_ext.moon
Last active July 8, 2022 21:20
Moonscript Object accessors extension
getters = (cls, getters) ->
cls.__base.__index = (key) =>
if getter = getters[key]
getter @
else
cls.__base[key]
setters = (cls, setters) ->
cls.__base.__newindex = (key, val) =>
if setter = setters[key]
open System
open System.Text.RegularExpressions
type Expr =
| Int of int
| Symbol of string
| Exprs of Expr list
(* convert a string into a list of tokens (include parentheses, remove whitespace) *)
let tokenize (str: string) =
(**
Pushes data from MongoDB to Oracle Micros iCare
Run it like so:
$ MONGO_URL=xxx \
MICROS_URL=xxx \
MICROS_USERNAME=xxx \
MICROS_PASSWORD=xxx \
dotnet fsi ./push_to_micros.fsx
*)
@naartjie
naartjie / show_certs.md
Last active February 2, 2022 20:57
SSL certs

With SNI:

$ openssl s_client -showcerts -servername www.example.com -connect www.example.com:443 </dev/null

No SNI:

$ openssl s_client -showcerts -connect www.example.com:443 
@naartjie
naartjie / debian_backports.sh
Last active October 13, 2021 10:28
Linux apt magic
# stretch
$ echo "deb http://deb.debian.org/debian stretch-backports main" >> /etc/apt/sources.list
$ apt install -t stretch-backports git
@naartjie
naartjie / wget.sh
Created January 1, 2021 16:10 — forked from crittermike/wget.sh
Download an entire website with wget, along with assets.
# One liner
wget --recursive --page-requisites --adjust-extension --span-hosts --convert-links --restrict-file-names=windows --domains yoursite.com --no-parent yoursite.com
# Explained
wget \
--recursive \ # Download the whole site.
--page-requisites \ # Get all assets/elements (CSS/JS/images).
--adjust-extension \ # Save files with .html on the end.
--span-hosts \ # Include necessary assets from offsite as well.
--convert-links \ # Update links to still work in the static version.
@naartjie
naartjie / App.fs
Created November 29, 2020 23:13
F# MongoDB Starter
open MongoDB.Driver
open MongoDB.Bson
open MongoDB.Driver.Linq
let doMongoStuff () =
let client = MongoClient("mongodb://localhost:27017")
let db = client.GetDatabase("rebujito-test")
let collectionName = "users"
@naartjie
naartjie / nmap.sh
Created November 18, 2020 08:45
Scan your local network
nmap -v -sn 192.168.1.0/24