Skip to content

Instantly share code, notes, and snippets.

set-alias -name npp -value "${env:ProgramFiles}\Notepad++\notepad++.exe"
set-alias -name ed -value "code"
remove-item alias:curl -EA SilentlyContinue
$DefaultUser = 'hyrma'
# Chocolatey profile
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
if (Test-Path($ChocolateyProfile)) {
Import-Module "$ChocolateyProfile"
@hyrmn
hyrmn / hello.zig
Created January 27, 2020 03:41
Reading a file and counting carriage returns in Zig 0.5.x+master
const std = @import("std");
const os = std.os;
const fs = std.fs;
const File = std.fs.File;
pub fn main() !void {
const stdout = &std.io.getStdOut().outStream().stream;
//try stdout.print("Hello, {}!\n", .{"world"});
var file = try fs.openFileAbsolute("c:\\data\\bigsum.txt", File.OpenFlags{});
defer file.close();
@hyrmn
hyrmn / netcore linecount
Created January 21, 2020 01:49
netcore 3.1. hardcoded to the location of a 1.6gb text file
class Program
{
static void Main(string[] args)
{
var count = 0;
using var reader = File.OpenText(@"C:\code\go\src\github.com\hyrmn\lc\pkg\lc\testdata\bigsum.txt");
var buffer = new Span<char>(new char[1024]);
int readLength;
[user]
name = Ben Hyrman
email = ben.hyrman@gmail.com
[core]
autocrlf = true
editor = vim
excludesfile = C:\\Users\\B.Hyrman\\Documents\\gitignore_global.txt
[credential]
helper = manager
[merge]
public class PartitionedNamingStrategy
{
private static readonly Dictionary<string, Func<string, string>> NamingStrategies = new Dictionary<string, Func<string, string>>
{
{"none", s => s},
{"bymachine", s => $"{Environment.MachineName}_{s}"}
};
private readonly string _strategy;
@hyrmn
hyrmn / main.cs
Created October 29, 2019 00:35
Two simple local functions
static decimal CalculateBalance(AccountId accountId)
{
//assume these things come in externally
var charges = new[] {new Charge(100M)};
var payments = new[] {new Payment(20M)};
var chargeBalance = Σ(charges.Select(c => c.Amount));
var paymentCredit = Σ(payments.Select(p => p.Amount));
return chargeBalance - paymentCredit;
@hyrmn
hyrmn / dbmigrator.csproj
Created October 18, 2019 01:16
refuses to pick up new files unless I clean or delete bin/obj first
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net461</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DbUp-SqlServer" Version="4.2.0" />
<PackageReference Include="OctoPack" Version="3.0.31" />
</ItemGroup>
@hyrmn
hyrmn / capslockwarning.js
Created October 4, 2019 17:46
Show a little capslock warning if the user tries to log in while their capslock key is on.
<script>
(function() {
var capsLockEnabled = false;
document.onkeypress = function (e) {
e = e || window.event;
var s = String.fromCharCode(e.keyCode || e.which);
if (s.toLowerCase() === s.toUpperCase()) {
return;
}
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
[CoreJob]
//[MemoryDiagnoser]
//[InProcess()]
@hyrmn
hyrmn / richhickey.md
Created April 18, 2018 08:35 — forked from prakhar1989/richhickey.md
richhickey.md

Rich Hickey on becoming a better developer

Rich Hickey • 3 years ago

Sorry, I have to disagree with the entire premise here.

A wide variety of experiences might lead to well-roundedness, but not to greatness, nor even goodness. By constantly switching from one thing to another you are always reaching above your comfort zone, yes, but doing so by resetting your skill and knowledge level to zero.

Mastery comes from a combination of at least several of the following: