Skip to content

Instantly share code, notes, and snippets.

@jmrnilsson
jmrnilsson / how_to_save_ssh_auth.markdown
Created May 15, 2019 20:22
ssh auth using git bash (mingw) on win 10

For file, open in notepad:

C:\Users\YOUR_USERNAME\.bash_profile

Add the lines:

#use fix path for SSH_AUTH_SOCK so it works more then one instance of gitbash
export SSH_AUTH_SOCK="$TEMP/ssh_agent_socket"

ps | grep ssh-agent > /dev/null

@jmrnilsson
jmrnilsson / draw.py
Created May 14, 2019 21:16
Generate emojis for agile estimation and planning polls
from PIL import Image, ImageDraw, ImageFont
# https://get.slack.help/hc/en-us/articles/206870177-Add-custom-emoji
estimations = ['1h', '2h', '4h', '6h', '1d', '2d', '3d', '4d', '1w', '2w', 'inf']
fnt_ = ImageFont.truetype('C:\\WINDOWS\\FONTS\\CONSOLA.ttf', 96)
for e in estimations:
fnt = fnt_ if len(e) < 3 else ImageFont.truetype('C:\\WINDOWS\\FONTS\\CONSOLA.ttf', 65)
img = Image.new('RGB', (128, 128), color = (73, 109, 137))
@jmrnilsson
jmrnilsson / sh.sh
Created May 8, 2019 10:20
Git thingies
First git tag with commit
https://unix.stackexchange.com/questions/47659/how-to-find-the-first-tag-that-contains-a-git-commit
git name-rev --tags --name-only <SHA>
@jmrnilsson
jmrnilsson / 32and64bit.cs
Last active May 9, 2020 05:43
Fowler–Noll–Vo 1 A (FNV1) in 32 bit and 64 bit variants
using System;
using System.Text;
namespace Hashing
{
public static class FowlerNollVo
{
public static string ToFnv1aHashInt64(this string text)
{
string Fnv1a(byte[] bytes_)
@jmrnilsson
jmrnilsson / shaAhead.sh
Last active April 29, 2019 11:41
Find commits ahead of branch no merge commits
git log --no-merges --format=format:%H master..a_branch | sort > master.ahead
git log --no-merges --format=format:%H development..a_branch.development | sort > development.ahead
diff master.ahead development.ahead
@jmrnilsson
jmrnilsson / readme.markdown
Created April 12, 2019 10:22
Useful stuff - GIT

C#

Add a some file available at several arbitrary pathsl

git ls-files | grep .ruleset | xargs git add
@jmrnilsson
jmrnilsson / fixing_indentation_and_trailing_whitespaces_in_visual_studio.markdown
Last active February 13, 2020 08:50
Switching from mixed space-tab intent to tab indentation in visual studio professional (2017)

Regex indentation and line-endings tricks

Switching to tab indentation

Note: Has to be run multiple times until it will not match anything. Has been verified in Visual Studio Professional 2017.15.7

  • Search RegularExpression (?<=(^[\t]*))[ ]{4}.
  • Replace with \t.
  • File mask *.cs.
#show settings
git config --list --show-origin
$ git config --list --show-origin | grep crlf
file:"C:\\ProgramData/Git/config" core.autocrlf=false
#csharp .gitattributes
*.sln text eol=crlf
*.config text eol=crlf
@jmrnilsson
jmrnilsson / revert.sh
Created October 10, 2018 11:03
Git revert if there are merge commits also
#!/usr/bin/env bash
SHA=$1
echo "Creating file list for $SHA"
git diff-tree --no-commit-id --name-only -r "$SHA" >
vim diff-tree.filelist
cat diff-tree.filelist | xargs -0 -I -r {} git checkout "$SHA^" {}
rm diff-tree.filelist
@jmrnilsson
jmrnilsson / simple_cb.py
Last active October 2, 2018 22:49 — forked from DavidYKay/simple_cb.py
Simple color balance algorithm using Python 2.7.8 and opencv-python=3.4.3.18. Ported from: http://www.morethantechnical.com/2015/01/14/simplest-color-balance-with-opencv-wcode/
import cv2
import math
import numpy as np
import sys
def apply_mask(matrix, mask, fill_value):
masked = np.ma.array(matrix, mask=mask, fill_value=fill_value)
return masked.filled()
def apply_threshold(matrix, low_value, high_value):