Skip to content

Instantly share code, notes, and snippets.

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

Sherif Abdalla ZeroDeth

🏠
Working from home
View GitHub Profile
@ZeroDeth
ZeroDeth / gpg_git_signing.md
Created April 24, 2022 10:23 — forked from alopresto/gpg_git_signing.md
Steps to enable GPG signing of git commits.

If anyone is interested in setting up their system to automatically (or manually) sign their git commits with their GPG key, here are the steps:

  1. Generate and add your key to GitHub
  2. $ git config --global commit.gpgsign true ([OPTIONAL] every commit will now be signed)
  3. $ git config --global user.signingkey ABCDEF01 (where ABCDEF01 is the fingerprint of the key to use)
  4. $ git config --global alias.logs "log --show-signature" (now available as $ git logs)
  5. $ git config --global alias.cis "commit -S" (optional if global signing is false)
  6. $ echo "Some content" >> example.txt
  7. $ git add example.txt
  8. $ git cis -m "This commit is signed by a GPG key." (regular commit will work if global signing is enabled)
@ZeroDeth
ZeroDeth / example.nix
Created February 2, 2022 15:00 — forked from damianbaar/example.nix
nix expression that provides a way to copy your zsh configuration files
{ pkgs ? import <nixpkgs> {}
, zdotdir ? import (builtins.fetchurl {
url = "https://gist.githubusercontent.com/damianbaar/57aff242d06c75444dbd36bf5400060e/raw/83d074d45c81a18402146cadc595a20b91bb1985/zdotdir.nix";
}) { inherit pkgs; }
}:
pkgs.stdenv.mkDerivation {
name = "withZshEnv";
shellHook= zdotdir {
zshenv = builtins.path { path = ./zdotdir/zshenv; };
zshrc = builtins.path { path = ./zdotdir/zshrc; };
@ZeroDeth
ZeroDeth / nix_example_upgrade_terraform.txt
Created January 29, 2022 22:19 — forked from pschyska/nix_example_upgrade_terraform.txt
Example: Upgrading a nixpkgs package with a new version - terraform
# acquire nix-prefetch
$ cat > default.nix <<-"EOF"
with import <nixpkgs> { };
pkgs.mkShell rec { nativeBuildInputs = [ pkgs.nix-prefetch ]; }
EOF
$ nix-shell
# N.B.: in nix-shell my PS1 changes to (impure) *
# override terraform derivation with new source, but without sha256 and vendorSha256
(impure) * cat > terraform.nix <<-"EOF"
@ZeroDeth
ZeroDeth / flake-direnv.md
Created January 25, 2022 18:13 — forked from inscapist/flake-direnv.md
Nix Flakes and Direnv on Mac OSX (Catalina)

Development environment with Nix Flakes and Direnv

This document is targeted at those who seek to build reproducible dev environment across machines, OS, and time.

It maybe easier for remote teams to work together and not spending hours each person setting up asdf/pyenv/rbenv, LSP servers, linters, runtime/libs. Nix is probably the closest thing to Docker in terms of development environment.

Flake is used here because it provides hermetic build, with absolutely no reliance on system environment (be it Arch/Catalina/Mojave). Also it freezes dependencies in flake.lock so builds are reproducible.

This gist provides the setup to develop Java/Clojure/Python applications on Nix. But it can be easily adapted to ruby, nodejs, haskell.

@ZeroDeth
ZeroDeth / op-add-identities
Created January 4, 2022 11:20 — forked from eritbh/op-add-identities
1password SSH identity management helpers
#!/bin/bash
echo "Signing into 1password..."
eval $(op signin $@)
items=($(op list items | jq '.[] | select(.templateUuid == "110") | .uuid' --raw-output))
for uuid in "${items[@]}"; do
item_data="$(op get item "$uuid")"
private_key="$(echo "$item_data" | jq '.details.sections[0].fields[] | select(.t == "ssh private key") | .v' --raw-output)"
item_title="$(echo "$item_data" | jq '.overview.title' --raw-output)"
@ZeroDeth
ZeroDeth / my-nixos-installation.md
Created December 31, 2021 18:21
NixOS installation guide, tailored to my needs

Preface

This manual describes how to install, use and extend NixOS, a Linux distribution based on the purely functional package management system Nix, that is composed using modules and packages defined in the Nixpkgs project.

Installation

This section describes how to obtain, install, and configure NixOS for first-time use.

Obtaining NixOS

NixOS ISO images can be downloaded from the NixOS download page. There are a number of installation options. In this manual we will assume that the chosen option is Minimal ISO image (64bit). You can burn it on a USB stick with:

# Instructions for fresh install
$ sh <(curl -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume --daemon
# reboot
$ source /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
$ echo 'export NIX_PATH=darwin-config=$HOME/.nixpkgs/darwin-configuration.nix:$HOME/.nix-defexpr/channels${NIX_PATH:+:}$NIX_PATH' | tee -a ~/.zshrc
$ echo 'source $HOME/.nix-profile/etc/profile.d/hm-session-vars.sh' | tee -a ~/.zshrc
$ nix-channel --add https://nixos.org/channels/nixpkgs-unstable
$ nix-channel --add https://github.com/LnL7/nix-darwin/archive/master.tar.gz darwin
$ nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@ZeroDeth
ZeroDeth / Makefile_include_exclude
Created September 8, 2020 17:01 — forked from davidlu1001/terraform_include_exclude
Makefile for Terraform to support include/exclude
PLAN_OPTIONS ?=
APPLY_OPTIONS ?=
EXCLUDE ?=
INCLUDE ?=
define PLAN_OPTIONS_EXCLUDE
$(shell terraform show current.plan | perl -pe 's//\n/ if $$. == 1' | perl -pe 's/\x1b\[[0-9;]*[mG]//g' | perl -ne 'if ($$p) { print unless /^$$/; $$p = 0 } $$p++ if /^$$/'| awk '{print $$2}' | grep -E -v '$(1)' | sed -e 's/^/-target="/g' -e 's/$$/"/g' | awk BEGIN{RS=EOF}'{gsub(/\n/," ");print}')
endef
define PLAN_OPTIONS_INCLUDE