Skip to content

Instantly share code, notes, and snippets.

View tackme31's full-sized avatar

tackme tackme31

View GitHub Profile
@tackme31
tackme31 / ItIs.cs
Created June 21, 2024 09:33
A moq macher for deeply comparing objects.
public static class ItIs
{
public static T EquivalentTo<T>(T expected)
{
return EquivalentTo(expected, config => config);
}
public static T EquivalentTo<T>(T expected, Func<EquivalencyAssertionOptions<T>, EquivalencyAssertionOptions<T>> config)
{
bool Validate(T actual)
@tackme31
tackme31 / Get-VisualStudioVersion.ps1
Created June 22, 2023 08:53
Powershell function to get visual studio version.
function Get-VisualStudioVersion {
[CmdletBinding()]
param(
[Parameter(Mandatory=$True)]
[string]$Product
)
$products = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -format json | ConvertFrom-Json
$info = $products | Where-Object { $_.catalog.productLineVersion -eq $product } | Select-Object -First 1
if (-not $info) {
@tackme31
tackme31 / .gitconfig
Last active January 26, 2024 06:47
my git aliases
[alias]
st = status
ad = add -A
cm = commit
cmm = commit -m
cmf = commit --fixup
cman = commit --amend --no-edit
cmfr = "!f() { git commit --fixup \"$1\"; GIT_SEQUENCE_EDITOR=: git rebase -i --autosquash \"$1\"^; }; f"
f = fetch
p = pull
@tackme31
tackme31 / Microsoft.PowerShell_profile.ps1
Last active June 22, 2023 05:44
Random emoji prompt for Windows Terminal
function prompt {
$index = Get-Random -Maximum $emojis.Count
return $emojis[$index] + '>'
}
$emojis = @(
"`u{00A9}","`u{00AE}","`u{1005}","`u{1F004}","`u{1F0CF}","`u{1F170}","`u{1F171}","`u{1F17E}","`u{1F17F}","`u{1F18E}","`u{1F191}","`u{1F192}","`u{1F193}","`u{1F194}","`u{1F195}","`u{1F196}","`u{1F197}","`u{1F198}","`u{1F199}","`u{1F19A}",
"`u{1F201}","`u{1F202}","`u{1F21A}","`u{1F22F}","`u{1F232}","`u{1F233}","`u{1F234}","`u{1F235}","`u{1F236}","`u{1F237}","`u{1F238}","`u{1F239}","`u{1F23A}","`u{1F250}","`u{1F251}","`u{1F300}","`u{1F301}","`u{1F302}","`u{1F303}","`u{1F304}",
"`u{1F305}","`u{1F306}","`u{1F307}","`u{1F308}","`u{1F309}","`u{1F30A}","`u{1F30B}","`u{1F30C}","`u{1F30D}","`u{1F30E}","`u{1F30F}","`u{1F310}","`u{1F311}","`u{1F312}","`u{1F313}","`u{1F314}","`u{1F315}","`u{1F316}","`u{1F317}","`u{1F318}",
"`u{1F319}","`u{1F31A}","`u{1F31B}","`u{1F31C}","`u{1F31D}","`u{1F31E}","`u{1F31F}","`u{1F320}","`u{1F321}","`u{1F324}","`u{1F325}","`u{1F326}","`u{1F327}","`u{1F328}","`u{1F
@tackme31
tackme31 / check-homes-recruitment.ps1
Created June 28, 2022 16:03
ホームズの物件で募集中の部屋を出力するやつ
$chintaiList = @(
'https://www.homes.co.jp/archive/b-38203506/', # キングダム相模原
'https://www.homes.co.jp/archive/b-38203509/', # ビバーチェ
'https://www.homes.co.jp/archive/b-38201560/' # タウンハウス内堀
)
function Write-Recuruitments($archiveUrl) {
$result = Invoke-WebRequest $archiveUrl
$heading = $result.ParsedHtml.getElementsByClassName('heading')
@tackme31
tackme31 / Program.cs
Created March 23, 2022 03:34
Remove comments by Roslyn
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
var programBefore = @"
public class MyClass
{
public void MyMethod()
{
// Output
Console.WriteLine(""Hello, world!"");
@tackme31
tackme31 / nl.ps1
Created January 20, 2022 01:58
A PowerShell commandlet like bash's 'nl' command.
Function Join-LineNumbers {
[CmdletBinding()]
param(
[Parameter(Mandatory=$True,
ValueFromPipeline=$True)]
[string[]]$Lines
)
begin {
$private:i = 1
@tackme31
tackme31 / Rename-Extension.ps1
Created November 20, 2021 10:04
PowerShell script to rename extension of files in a specified directory.
<#
.SYNOPSIS
PowerShell script to rename extension of files in a specified directory.
.EXAMPLE
PS> Rename-Extension -Path . -ExtensionFrom txt -ExtensionTo md -Recurse
.PARAMETER Path
Folder that contains the file to be renamed
@tackme31
tackme31 / hide-mute-texts.js
Last active August 23, 2021 00:57
A script to hide texts containing the specified MUTE keywords.
const MUTE_TEXTS = [
'FOO',
'BAR',
'BAZ',
];
const getText = (node) => [...node.childNodes]
.filter(n => n.nodeType === Node.TEXT_NODE)
.reduce((acc, n) => acc += n.nodeValue, '');
const shouldMute = (node) => MUTE_TEXTS.some(text => getText(node).includes(text));
@tackme31
tackme31 / certextension.md
Created July 12, 2021 02:27
証明書関連の拡張子メモ
拡張子 説明
.key 秘密鍵や公開鍵を含むファイル。鍵はPEMかDER形式で保存されている。.pem.derを使うこともある。
.pem PEM形式の証明書や秘密/公開鍵のファイル。
.der DER形式の証明書や秘密/公開鍵のファイル。
.csr 証明書署名要求(CSR)ファイル。公開鍵と組織情報を含む
.crt, .cer, .cert 証明書ファイル。.csrを署名したもの。.pem.derを使うこともある。
.pfx, .p12 秘密鍵 + 証明書。秘密鍵をパスワードで保護できる。Windowsでよく使われる。
.jks 秘密鍵 + 証明書。Javaで使用されるキーストアファイル。