Skip to content

Instantly share code, notes, and snippets.

View nightsparc's full-sized avatar

nightsparc nightsparc

  • Munich, Germany
View GitHub Profile
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
@nightsparc
nightsparc / remove_git_submodule.sh
Created February 28, 2019 11:59 — forked from moyaldror/remove_git_submodule.sh
Complete remove of git submoule
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage: $0 <submodule full name>"
exit 1
fi
MODULE_NAME=$1
MODULE_NAME_FOR_SED=$(echo $MODULE_NAME | sed -e 's/\//\\\//g')
@nightsparc
nightsparc / change_git_submodule.md
Created February 28, 2019 12:02 — forked from opyate/change_git_submodule.md
Change a git submodule remote

To change a git submodule's remote (in this case, from HTTPS to SSH):

SUB=my-submodule-name
$REMOTE=git@gitlab.com:path/to/remote.git

git submodule deinit $SUB
git rm $SUB
git commit -m "removed $SUB submodule at https remote"

rm -rf .git/modules/$SUB

@nightsparc
nightsparc / git.migrate
Created February 28, 2019 12:07 — forked from niksumeiko/git.migrate
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.
@nightsparc
nightsparc / gitignore
Created March 4, 2019 12:13 — forked from judy2k/gitignore
A script to manage a .gitignore file
#!/bin/bash
# To add two items to the current .gitignore file:
# gitignore '*.swp' bin
#
# To sort and de-dupe the current .gitignore file:
# gitignore
# Append each argument to its own line:
for item in "$@"; do
echo "$item" >> .gitignore;
@nightsparc
nightsparc / terminator.vbs
Created March 29, 2019 13:51 — forked from nistath/terminator.vbs
Script to start terminator on WSL from CMD or PowerShell
' Usage: terminator[.vbs] [path to starting directory]
' contents enclosed in square brackets optional
args = "-c" & " -l " & """DISPLAY=:0 terminator"""
' If there's a single argument, interpret it as the starting directory
If WScript.Arguments.Count = 1 Then
dir = WScript.Arguments(0)
Else
dir = ""
@nightsparc
nightsparc / shell_config.md
Created August 28, 2019 12:18 — forked from bahamat/shell_config.md
How are various shells configured, and in which order?

bash

login interactive files
N N $BASH_ENV
N Y ~/.bashrc
Y N /etc/profile, ~/.bash_profile, ~/.bash_login, ~/.profile
Y Y /etc/profile, ~/.bash_profile, ~/.bash_login, ~/.profile
@nightsparc
nightsparc / virtual_serial_ports.md
Created September 28, 2019 21:45 — forked from CMCDragonkai/virtual_serial_ports.md
Virtual Serial Ports #cli #serial #network

Virtual Serial Ports

We can use socat to create 2 virtual serial ports that are connected to each other locally. This can be useful for debugging serial port applications. Or simulating serial port communication. Or running 2 legacy programs that only communicate with each other over serial ports, such as old DOS games. And of course, for education, since serial communication is probably the most simple communication protocol there is, RS232 is considered at the bottom of the OSI stack, at the "Physical Layer". See: http://electronics.stackexchange.com/questions/31171/internet-vs-serial-communication

#!/bin/sh
MODEM="$(mmcli -L | grep -o '/org/freedesktop/ModemManager1/Modem/[0-9]*' | head -1)"
BEARER="$(mmcli -m $MODEM --list-bearers | grep -o '/org/freedesktop/ModemManager1/Bearer/[0-9]*' | head -1)"
mkdir -p /run/systemd/network
connect() {
MODEM="$(mmcli -L | grep -o '/org/freedesktop/ModemManager1/Modem/[0-9]*' | head -1)"
# hardcode all the things !! (this is for mobile vikings)
@nightsparc
nightsparc / xreadkeys.c
Created April 20, 2020 12:42 — forked from javiercantero/xreadkeys.c
A X11/Xlib program that reads the KeyPress and KeyRelease events from the window and prints them to the standard output. Used to debug the keyboard within X.
#include <X11/Xlib.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
Display *display;
Window window;
XEvent event;
int s;