Skip to content

Instantly share code, notes, and snippets.

View seppestas's full-sized avatar

Seppe Stas seppestas

View GitHub Profile
@seppestas
seppestas / parse_env.bat
Created August 19, 2022 17:24
Parses a .env files with Windows commander (cmd)
:: Parses a .env file with windows cmd similar to Posix source
:: Note: This only works for oneliners when delayed varaible extension is used
:: e.g with cmd /V:ON
:: Pass the /F flag to overwrite existing variables
@echo off
setlocal enabledelayedexpansion
set envfile=.env
set force=0
This is a test
Set variables
=============
Set a variable in different environments. Example sets `$VAR` to "fubar".
## Linux, MacOS, ...
```
VAR=fubar
```
@seppestas
seppestas / pre-push
Last active April 10, 2020 15:57
Gerrit anti-unintended changes pre-push hook
#!/bin/sh
# Git pre-push script to notify the user in case more than 1 commit is pushed.
# Handy when pushing to the gerrit review system where each commit will result
# in a change review. Pushing to or from an incorrect branch could result in a
# bunch of unintended change reviews to be created and/or changes dependent on
# unsubmitted changes.
remote="$1"
url="$2"
@seppestas
seppestas / git-tricks.md
Last active March 23, 2020 13:01
Git tricks and tips

Git tricks

A place to store git tricks I use (and still forget sometimes).

Access branches using working trees

Sometimes it's usefull to access multiple branches of a git repository at the same time, e.g to compare different versions of CAD designs or to allow copying parts from one brach to the other. One way to do this is cloning the repository multiple times, but this typicaly takes a while. For copying things from text files like code a web based repository browser like gitweb or Github works fine, but this isn't always availible.

A more efficient method is using [git's work-tree command][git-worktree]. This allows to check out multiple versions of the same repository, using the same gitdir as the original repo, saving time and space. To do this:

One can use MD5 or plain text diff to see differences in PDF files. If that's not enough, here's how to use diffpdf which knows how to diff based on appearance or words:

  • brew install diff-pdf
  • edit your ~/.gitconfig to add this:
[difftool "diffpdf"]
  cmd = diff-pdf --view \"$LOCAL\" \"$REMOTE\"
@seppestas
seppestas / export_repo_issues_to_csv.py
Created March 6, 2019 08:41 — forked from unbracketed/export_repo_issues_to_csv.py
Export Issues from Github repo to CSV (API v3)
"""
Exports Issues from a specified repository to a CSV file
Uses basic authentication (Github username + password) to retrieve Issues
from a repository that username has access to. Supports Github API v3.
"""
import csv
import requests
var xhr = new XMLHttpRequest();
xhr.open('POST', './mac-address', true);
var formData = new FormData();
formData.append('mac-address', mac);
xhr.send(formData);
@seppestas
seppestas / kicad-cmake-macos.sh
Created May 1, 2018 22:59
cmake command to set up KiCad MacOS build
cmake -DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_OSX_DEPLOYMENT_TARGET=${$(defaults read loginwindow SystemVersionStampAsString)%.*} \
-DwxWidgets_CONFIG_EXECUTABLE=/usr/local/opt/kicad-wxwidgets/bin/wx-config \
-DKICAD_SCRIPTING=ON \
-DKICAD_SCRIPTING_MODULES=ON \
-DKICAD_SCRIPTING_WXPYTHON=ON \
-DKICAD_SCRIPTING_ACTION_MENU=ON \
-DPYTHON_EXECUTABLE=/usr/local/bin/python2 \
-DPYTHON_SITE_PACKAGE_PATH=/usr/local/opt/kicad-wxpython/lib/python2.7/site-packages \
@seppestas
seppestas / get-n-last-chars-foo.sh
Last active March 14, 2018 14:53
Get the last $n characters of a variable $foo in a posix-compatible shell
${foo:$((${#foo}-$n))}