Skip to content

Instantly share code, notes, and snippets.

@rnelson
rnelson / Program.cs
Created July 1, 2024 18:00
Rendezvous.FruitStand
// Kept the example run as-is, with the following exceptions:
// 1. Changed "let" to "var"
// 2. Added "new" on line 7
// 3. Added semicolons to the statements
// Create a new fruit stand
var stand = new FruitStand();
// Add fruits to the stand
stand.addFruit("apple", 10, 0.5);
@rnelson
rnelson / Program.cs
Created June 3, 2024 15:45
Rendezvous.OnlyEvens
using System.Text;
IEnumerable<int> onlyEvens(IEnumerable<int> list) => list.Where(i => i % 2 == 0).OrderBy(i => i);
void Dump(IEnumerable<int> list)
{
var sb = new StringBuilder();
sb.Append("[");
sb.Append(string.Join(", ", list.Select(i => i.ToString())));
sb.Append("]");
@rnelson
rnelson / Program.cs
Created May 21, 2024 00:04
Simple .NET 8 console app that sends a single tweet
using System.Text.Json;
using TwitterApiLibrary;
using TwitterApiLibrary.OAuth;
/*
* Credentials
* -----------
* 1. Go to the Twitter Developer Portal and create a new application.
* 2. Edit the User authentication settings
* App permissions: Read and write
@rnelson
rnelson / dotnet-on-freebsd.md
Last active November 4, 2023 15:11
.NET 7 on FreeBSD 13.2

.NET 7 on FreeBSD 13.2

After getting it up and running, I sent a quick toot about having .NET 7 running on my FreeBSD VM. It got a lot of boosts and favorites.

To make the process easier for others and to make sure credit is given where due, I decided to make this little gist.

Credits

I did nothing here but find the right bits of instructions and follow them. It looks like Thefrank and sec are the driving forces behind getting .NET working on FreeBSD. More information is on the FreeBSD wiki's .NET page.

@rnelson
rnelson / FileNotFoundException.md
Created January 27, 2022 01:37
Genesyslab.Sip.Endpoint.Provider.Genesys.dll + FileNotFoundException

FileNotFoundException

A few months back, I wrote a simple little Windows desktop application using WPF. It's built for .NET Framework 4.5, which means it should run in 4.5 through 4.8 without any issues. Outside of some core .NET assemblies and the WPF ones, it has a whopping three dependencies:

  1. Genesyslab.Sip.Endpoint.dll
  2. Genesyslab.Sip.Endpoint.Provider.Genesys.dll
  3. Newtonsoft.Json.dll

This application has been used internally on my network, internally on the other half of the company's network (we had a big merger, the networks are linked but only enough to get the important things working on both sides), and internally on some vendor networks. At launch, it connects to a web service of mine to pull down configuration stuff, and user-selected options then dictate what Genesys servers those first two dependencies connect to. Nice and simple.

@rnelson
rnelson / sameDigits.linq
Created May 10, 2021 23:35
sameDigits()
<Query Kind="Program" />
void Main()
{
sameDigits(1);
sameDigits(10);
sameDigits(251894);
sameDigits(251895);
}
#!/bin/ksh
# Cobbled together using https://www.romanzolotarev.com/random.html
# and https://docstore.mik.ua/orelly/unix3/korn/appb_11.htm
CHARS=' -~'
SIZE=20
USAGE="as#"
while getopts "$USAGE" opt; do
@rnelson
rnelson / day02.fs
Created December 10, 2017 13:49
Attempts at AoC 2017 Day 2b
open System
open System.IO
open System.Linq
open System.Text.RegularExpressions
let readInput(filename:string) =
let lines = File.ReadAllLines filename
[|
for l in (lines |> Array.toSeq) do
yield Regex.Split(l, "\s+") |> Array.map int
@rnelson
rnelson / tsinstall.bash
Created November 26, 2017 13:56
Script to install Tarsnap
#!/bin/bash
set -e
ROOT=/opt/tarsnap
usage() {
echo "usage: $0 <version>"
exit 1
}
@rnelson
rnelson / free_oreilly_ebooks.sh
Created October 10, 2016 11:48
O'Reilly Gives Away Free Programming Ebooks
#!/bin/sh
# http://www.oreilly.com/programming/free/
# https://news.slashdot.org/comments.pl?sid=9752765&cid=53044369
# https://news.slashdot.org/comments.pl?sid=9752765&cid=53045853
curl 'http://www.oreilly.com/business/free/' | grep '\.csp' | sed 's/^.*href="//' | sed 's/free\/\(.*\).csp.*">/free\/files\/\1.pdf/' | tr -d '\r' | xargs wget
curl 'http://www.oreilly.com/data/free/' | grep '\.csp' | sed 's/^.*href="//' | sed 's/free\/\(.*\).csp.*">/free\/files\/\1.pdf/' | tr -d '\r' | xargs wget
curl 'http://www.oreilly.com/design/free/' | grep '\.csp' | sed 's/^.*href="//' | sed 's/free\/\(.*\).csp.*">/free\/files\/\1.pdf/' | tr -d '\r' | xargs wget
curl 'http://www.oreilly.com/iot/free/' | grep '\.csp' | sed 's/^.*href="//' | sed 's/free\/\(.*\).csp.*">/free\/files\/\1.pdf/' | tr -d '\r' | xargs wget
curl 'http://www.oreilly.com/programming/free/' | grep '\.csp' | sed 's/^.*href="//' | sed 's/free\/\(.*\).csp.*">/free\/files\/\1.pdf/' | tr -d '\r' | xargs wget