Skip to content

Instantly share code, notes, and snippets.

@davidalpert
davidalpert / proof.md
Last active February 4, 2024 16:09
KeyBase Proof

Keybase proof

I hereby claim:

  • I am davidalpert on github.
  • I am davidalpert (https://keybase.io/davidalpert) on keybase.
  • I have a public key ASAU370tK4R4Lkl8hI9KNyXO0sYgmLwIXiA7d9wFjSZvhgo

To claim this, I am signing this object:

# Note: ~/.ssh/environment should not be used, as it
# already has a different pururpose in SSH
env=~/.ssh/agent.env
# Note: Don't bother checking SSH_AGENT_PID. It's not used
# by SSH itself, and it might even be incorrect
# (for example, when using agent-forwarding over SSH).
agent_is_running() {
@davidalpert
davidalpert / rsync_backup.sh
Created October 28, 2021 02:15 — forked from spyesx/rsync_backup.sh
Rsync backup excluding node_modules
# Backup files
#https://explainshell.com/explain?cmd=rsync+-azuv+--delete+--progress+--exclude+%27node_modules%27
rsync -auvhp --delete --exclude=node_modules [source] [destination]
# Remove all node_modules folders
# https://explainshell.com/explain?cmd=find+.+-name+%22node_modules%22+-type+d+-prune+-exec+rm+-rf+%27%7B%7D%27+%2B
find . -name "node_modules" -type d -prune -exec rm -rf '{}' +
package main
import (
"context"
kitlog "github.com/go-kit/kit/log"
"github.com/philippseith/signalr"
"net/http"
"os"
)
@davidalpert
davidalpert / prepare-commit-msg.js
Created December 10, 2020 11:49
git commit message prepare script (current branch prefix, git-mob support)
#!/usr/bin/env node
let { exec, execSync } = require('child_process'),
fs = require('fs');
const { stdout } = require('process');
const commitMessage = process.argv[2];
// expect .git/COMMIT_EDITMSG
if (/COMMIT_EDITMSG/g.test(commitMessage)) {
// opens .git/COMMIT_EDITMSG
let contents = fs.readFileSync(commitMessage) || '';
@davidalpert
davidalpert / normalize.jq
Created December 10, 2017 20:50
Sort json by keys and selected vaules
def sorted_walk(f):
. as $in
| if type == "object" then
reduce keys[] as $key
( {}; . + { ($key): ($in[$key] | sorted_walk(f)) } ) | f
elif type == "array" then map( sorted_walk(f) ) | f
else f
end;
def extradata_sort_key_for:
@davidalpert
davidalpert / SpoofCulture.cs
Created June 15, 2016 23:13
Spoof the current CultureInfo in a unit test.
public class SpoofCulture : IDisposable
{
private readonly CultureInfo _previousCultureInfo;
private readonly Thread _threadToSpoof;
public SpoofCulture(CultureInfo cultureToUse, Thread threadToSpoof = null)
{
_threadToSpoof = threadToSpoof ?? Thread.CurrentThread;
_previousCultureInfo = CultureInfo.CurrentCulture;
Function Add-Prefix([switch]$inputObject,$io) {
BEGIN {
if ($inputObject) {$io | &($MyInvocation.InvocationName) $args; break;}
$args = @($io) + $args
$prefix = $args[0]
Write-host "Adding $prefix as a prefix..."
}
PROCESS {
$name = $_.Name
if ($name.StartsWith($prefix)) {
@davidalpert
davidalpert / update.log
Created December 30, 2015 18:48
Cash Manager 2015 Update 3 install failure log
=================================================================
Log Opened: Mon May 18 12:49:24.319 2015
Operating System: Windows 7
Quicken Path: C:\PROGRA~2\QUICKEN
Patch Path: C:\ProgramData\Intuit\Quicken\inet\common\patch\
Common Files Path: C:\Program Files (x86)\Common Files
Common App data Folder: C:\ProgramData\Intuit\Quicken
Patch Exe path: C:\ProgramData\Intuit\Quicken\Inet\Common\patch\Update\
@davidalpert
davidalpert / ShowRawMail.js
Created August 18, 2015 03:23
Tampermonkey - Show Raw ePost Mail
// ==UserScript==
// @name Link to ePost content
// @namespace http://www.spinthemoose.com/
// @version 0.1
// @description adds a 'View Raw' link to the epost mail to view the PDF raw, which enables saving.
// @author David Alpert
// @match https://www.epost.ca/service/displayMail.a*
// @grant none
// ==/UserScript==
//