Skip to content

Instantly share code, notes, and snippets.

View MrSmoke's full-sized avatar
🦆
Beep boop

Cameron MrSmoke

🦆
Beep boop
View GitHub Profile
@MrSmoke
MrSmoke / Controller.cs
Created July 2, 2018 06:10
Saml2 Example
public async Task<IActionResult> DoChallenge(string returnUrl)
{
var context = await _interaction.GetAuthorizationContextAsync(returnUrl);
var acrTenantValue = context.AcrValues.First(v => v.StartsWith("tenantId:"));
var tentantId = acrTenantValue.Split(':')[1];
// start challenge and roundtrip the return URL and
var props = new AuthenticationProperties
{
@MrSmoke
MrSmoke / EnumerableExtensions.cs
Created July 26, 2018 07:51
EnumerableExtensions
public static class EnumerableExtensions
{
public static bool TryGetFirstValue<T>(this IEnumerable<T> source, out T value)
{
if (source == null)
throw new ArgumentNullException(nameof(source));
//is a list?
if (source is IList<T> col)
{
@MrSmoke
MrSmoke / Demo.cs
Last active September 7, 2018 02:36
Pipline Builder
public static void Demo()
{
var stringToInt = new TransformBlock<string, int>(str =>
{
Console.WriteLine("StringToInt");
return int.Parse(str);
});
var intToString = new TransformBlock<int, string>(i =>
{
public struct Id
{
public static readonly DateTime Epoch = new DateTime(2000, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
private static int _staticIncrement = new Random().Next();
private static readonly int StaticMachine = (GetMachineHash() + GetAppDomainId()) & 0x00ffffff;
private static readonly short StaticPid = GetPid();
// private fields
private readonly int _a;
public static class AttributeCache<TAttribute> where TAttribute : Attribute
{
private static readonly ConcurrentDictionary<MethodInfo, ReadOnlyCollection<TAttribute>> Lookup =
new ConcurrentDictionary<MethodInfo, ReadOnlyCollection<TAttribute>>();
public static IReadOnlyCollection<TAttribute> GetOrSet(MethodInfo methodInfo) =>
Lookup.GetOrAdd(methodInfo, CachedDelegates.GetCustomAttributes);
private static class CachedDelegates
{
@MrSmoke
MrSmoke / bort.omp.json
Created September 23, 2021 00:39
oh-my-posh theme
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"final_space": true,
"console_title": true,
"console_title_style": "template",
"console_title_template": "{{if .Root}}(Admin) {{end}}{{.Folder}}",
"blocks": [
{
"type": "prompt",
"alignment": "left",
@MrSmoke
MrSmoke / linux-road-blocks.md
Last active May 18, 2024 11:59
Linux roadblocks
@MrSmoke
MrSmoke / cleanup.md
Created January 11, 2022 04:17
Cleanup ubuntu server

Remove un-needed services

sudo apt purge --auto-remove snapd squashfs-tools apport

Remove cloud init

sudo dpkg-reconfigure cloud-init
sudo apt-get purge cloud-init
sudo rm -rf /etc/cloud/ &amp;&amp; sudo rm -rf /var/lib/cloud/
@MrSmoke
MrSmoke / pant_code.ino
Created February 2, 2023 10:33
Pant code
#define WAIST 2
#define LEFT_LEG 3
#define RIGHT_LEG 4
#define LEFT_SHOE 5
#define RIGHT_SHOE 6
#define W WAIST
#define LL LEFT_LEG
#define RL RIGHT_LEG
#define LS LEFT_SHOE
@MrSmoke
MrSmoke / paperwm.md
Created August 29, 2024 01:06
PaperWM keybinds
Default window Keybindings Can be changed in PaperWM extension settings
SuperReturn or SuperN Open a new windows (of the current application)
SuperBackspace Close the active window
Super. or Super, Switch to the next or previous window
SuperLeft or SuperRight Activate the window to the left or right
SuperUp or SuperDown Activate the window above or below
SuperHome or Super