Skip to content

Instantly share code, notes, and snippets.

View dam5s's full-sized avatar

Damien LeBerrigaud dam5s

View GitHub Profile
@dam5s
dam5s / PowerShellPromptSetup.md
Last active August 14, 2019 00:13
A custom Powershell prompt à la Oh My ZSH

How to setup

Assuming you have Visual studio code installed and on the path. Assuming you have git installed and on the path.

  1. Open PowerShell.
  2. Edit your profile
    code $profile
    
@dam5s
dam5s / Async.swift
Created November 3, 2020 18:05
Limitations (?) to Swift extensions.
class Async<Wrapped> {
func map(function: @escaping (Wrapped) -> NewWrapped) -> Async<NewWrapped> {
// ...
}
// ...
}
typealias AsyncResult<Success, Failure> = Async<Result<Success, Failure>>
@dam5s
dam5s / result.ex
Created June 27, 2021 22:21
Elixir Result type test
defmodule Result do
@type t :: {:ok, any} | {:failure, any}
@spec map(Result.t, any :: any) :: Result.t
def map(result, mapping) do
case result do
{:ok, value} -> {:ok, mapping.(value)}
{:this_is_wrong, err} -> {:this_is_wrong, err}
end
end
@dam5s
dam5s / profile.ps1
Created July 26, 2022 16:26
Powershell Profile
try { $null = gcm pshazz -ea stop; pshazz init } catch { }
function PromptAdmin {
$identity = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent())
$isAdmin = $identity.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if ($isAdmin) {
Write-Host "ADMIN " -NoNewline -ForegroundColor Red
}
}