Skip to content

Instantly share code, notes, and snippets.

View afreisinger's full-sized avatar
🏠
Working from home

Adrián Freisinger afreisinger

🏠
Working from home
View GitHub Profile
#!/bin/bash
IP="192.168.1.22"
SUBJECT_CA="/C=SE/ST=Stockholm/L=Stockholm/O=himinds/OU=CA/CN=$IP"
SUBJECT_SERVER="/C=SE/ST=Stockholm/L=Stockholm/O=himinds/OU=Server/CN=$IP"
SUBJECT_CLIENT="/C=SE/ST=Stockholm/L=Stockholm/O=himinds/OU=Client/CN=$IP"
function generate_CA () {
echo "$SUBJECT_CA"
openssl req -x509 -nodes -sha256 -newkey rsa:2048 -subj "$SUBJECT_CA" -days 365 -keyout ca.key -out ca.crt
@afreisinger
afreisinger / .zshrc
Created September 27, 2021 04:10 — forked from ktrysmt/.zshrc
using zplug in zsh
if [[ ! -d ~/.zplug ]];then
git clone https://github.com/zplug/zplug ~/.zplug
fi
source ~/.zplug/init.zsh
zplug "plugins/git", from:oh-my-zsh
zplug "plugins/git", from:oh-my-zsh
zplug "plugins/sudo", from:oh-my-zsh
zplug "plugins/command-not-found", from:oh-my-zsh
zplug "zsh-users/zsh-syntax-highlighting"
zplug "zsh-users/zsh-history-substring-search"
#### General PFCTL Commands ####
$ pfctl -d disable # packet-filtering
$ pfctl -e enable # packet-filtering
$ pfctl -q # run quiet
$ pfctl -v -v # run even more verbose
#### Loading PF Rules ####
$ pfctl -f /etc/pf.conf # load /etc/pf.conf
$ pfctl -n -f /etc/pf.conf # parse /etc/pf.conf, but dont load it
$ pfctl -R -f /etc/pf.conf # load only the FILTER rules
$ pfctl -N -f /etc/pf.conf # load only the NAT rules
@afreisinger
afreisinger / README.md
Created March 15, 2022 01:54 — forked from marcoieni/README.md
Localize json resume in different languages

JSON Resume internationalization

A simple way to add internationalization feature to the JSON Resume project.

Create a different entry for each field that you want to localize, named with the language and the name of the field separated by an underscore. For example if you want to create an italian version and an english version of your summary do the following:

"basics": {
  "name": "Richard",
 "label": "Programmer",
@afreisinger
afreisinger / github-forking.md
Created April 26, 2022 01:14
GitHub Fork & Pull Request Workflow

GitHub Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favo

@afreisinger
afreisinger / esp-wifi.cpp
Last active April 26, 2022 02:28
Establishing a wifi connection
#include <ESP8266WiFi.h>
void connectWiFi(const char* WIFI_SSID,const char* WIFI_PASS, const char* WIFI_HOSTNAME)
{
bool isConnected = false;
if (WiFi.status() == WL_CONNECTED && !isConnected) return;
Serial.printf("Connecting to WiFi %s/%s", WIFI_SSID, WIFI_PASS);
WiFi.disconnect();
WiFi.mode(WIFI_STA);
@afreisinger
afreisinger / github-deleting-branchs.md
Last active April 26, 2022 22:11
GitHub How to Delete a Git Branch Both Locally and Remotely

GitHub Delete a Git Branch Both Locally and Remotely

In most cases, it is simple to delete a Git branch. You'll learn how to delete a Git brach locally and remotely in this article.

TL;DR version

// delete branch locally
git branch -d localBranchName

// delete branch remotely
@afreisinger
afreisinger / nil.sh
Created January 1, 2023 16:54
nmap in infinite loop
#!/bin/bash
if [[ -z $1 ]];
then
echo "No parameter passed."
else
echo "Parameter passed = $1"
ip=$1
#nmap ${ip} -PN -p ssh | grep open
#If you're interested in the actual state of the ssh-port, you can substitute grep open with egrep 'open|closed|filtered'
res=$(nmap ${ip} -PN -p ssh | egrep 'open|closed|filtered')
@afreisinger
afreisinger / docker_without_sudo.sh
Last active January 10, 2023 23:25
A quick guide to enable sudoless docker commands on a Synology NAS
#! /bin/sh
sudo synogroup --add docker #Create a docker user group
sudo chown root:docker /var/run/docker.sock #Change the owner group of the docker.sock file
sudo synogroup --member docker $USER #Add your user to the new docker group
# After this, you may need to log out and back in, or even restart your NAS before the permissions take effect.
@afreisinger
afreisinger / dfimage.sh
Last active January 30, 2023 10:45
Generate a Dockerfile from an image
#!/bin/bash
#https://stackoverflow.com/questions/19104847/how-to-generate-a-dockerfile-from-an-image
docker history --no-trunc $argv | tac | tr -s ' ' | cut -d " " -f 5- | sed 's,^/bin/sh -c #(nop) ,,g' | sed 's,^/bin/sh -c,RUN,g' | sed 's, && ,\n & ,g' | sed 's,\s*[0-9]*[\.]*[0-9]*\s*[kMG]*B\s*$,,g' | head -n -1