Skip to content

Instantly share code, notes, and snippets.

View nathanchere's full-sized avatar
💭
I've moved to https://gitlab.com/nathanchere - these repos no longer maintained

Nathan Chere nathanchere

💭
I've moved to https://gitlab.com/nathanchere - these repos no longer maintained
View GitHub Profile
@nathanchere
nathanchere / UpcCode.cs
Last active March 31, 2020 06:31
EAN / UPC validation
public class UpcCode
{
public static bool IsValid(string code)
{
if (string.IsNullOrEmpty(code)) return false;
if (!code.All(char.IsDigit)) return false;
if (code.Length < 12 || code.Length > 13) return false;
var digits = code.Select(c => int.Parse(c.ToString())).Reverse().Skip(1).ToArray();
var checkBit = int.Parse(code.Last().ToString());
@nathanchere
nathanchere / Luid.cs
Last active March 5, 2020 11:03
LUID - Locally unique identifier
using System.Security.Cryptography;
using System.Text;
namespace TrotenLib
{
/// <summary>
/// Generate unique-enough pseudo-random identifiers where GUID is for some reason unsuitable
/// Explanation: https://stackoverflow.com/a/37099588/243557
/// </summary>
public static class LUID
@nathanchere
nathanchere / config.rasi
Created November 20, 2019 03:03
rofi config
/**
* rofi -dump-theme output.
* Rofi version: 1.5.4
**/
* {
colorTextHighlightEmphasis: bold underline rgba ( 190, 255, 0, 100 % );
colorTextDim: var(mutedPlum);
limeGreen: rgba ( 160, 255, 0, 100 % );
colorAccent: var(limeGreen);
colorText: var(ivoryShadow);
@nathanchere
nathanchere / EGKB---the-Endgame-Keyboard-_ANSI_.kbd.json
Last active June 2, 2019 17:13
EGKB - the Endgame Keyboard (ANSI)
[
{
"backcolor": "#555",
"name": "EGKB - the Endgame Keyboard (ANSI)",
"author": "Nathan Chere",
"radii": "11px",
"switchMount": "cherry",
"switchBrand": "cherry",
"switchType": "MX1A-C1xx",
"plate": true
@nathanchere
nathanchere / webstoemp-gulpfile.js
Created January 24, 2019 16:18 — forked from jeromecoupe/webstoemp-gulpfile.js
Gulp 4 sample gulpfile.js
"use strict";
// Load plugins
const autoprefixer = require("autoprefixer");
const browsersync = require("browser-sync").create();
const cp = require("child_process");
const cssnano = require("cssnano");
const del = require("del");
const eslint = require("gulp-eslint");
const gulp = require("gulp");
@nathanchere
nathanchere / Powershell profile
Created July 17, 2018 10:06
My powershell profile / prompt
# Requires nerdfont to display correctly
Import-Module posh-git
start-sshagent
function Test-Administrator {
$user = [Security.Principal.WindowsIdentity]::GetCurrent();
(New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}
@nathanchere
nathanchere / downsample.bat
Created January 19, 2018 09:35
Downsample mp4s in directory to 360p with ffmpeg
for %%f in (*.mp4) do call ffmpeg -i "%%~nf.mp4" -vcodec libx264 -vf scale=-1:360 -r 12 -preset fast -acodec copy "%%~nf.360p.mp4"
@nathanchere
nathanchere / a.ps1
Last active March 5, 2024 17:09
Determining if you are in the main script or being run/imported from another script
Import-Module ./common.psm1
Write-Host "This is a.ps1!"
./b.ps1
If(IsMain()){
Write-Host "This is a protected part of a.ps1"
}
### Keybase proof
I hereby claim:
* I am nathanchere on github.
* I am nathanchere (https://keybase.io/nathanchere) on keybase.
* I have a public key ASDKIp2yEyGl6wV4FmvCLhrosIbv30oF0Uo52bEZmK_koQo
To claim this, I am signing this object:
@nathanchere
nathanchere / disable_dotnetcore_telemetry.bat
Created September 18, 2017 08:47
Permanently disable .Net Core spying ('telemetry') on Windows
setx DOTNET_CLI_TELEMETRY_OPTOUT 1