Skip to content

Instantly share code, notes, and snippets.

View wagoodman's full-sized avatar
🤓

Alex Goodman wagoodman

🤓
View GitHub Profile
#define _GNU_SOURCE
#include <errno.h>
#include <sched.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
@Mattemagikern
Mattemagikern / Certificates.go
Created May 9, 2019 08:31
Create x509 certificate chain using Golang. Root CA, Designated CA, server CA
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
"fmt"
"math/big"
@unlockedmutex
unlockedmutex / .bashrc
Last active February 7, 2022 07:18
Automatically enter/exit/hop pipenv virtualenvironments
# This will enter any virtualenvironment when there is a pipfile
# to be found in the current directory or a directory higher up
# in the hierarchy. It will exit if none is found, and switch if
# You cd into a different pipenv.
# Append this to your bashrc and it will work whenever you cd around
function search_up_pipfile {
ORIG_DIRECTORY=$PWD
if ! [[ -z $VIRTUAL_ENV ]]; then
@tux-00
tux-00 / configparser_to_dataclasses.py
Created August 20, 2018 18:20
Converts python config parser to dataclasses (easier access)
import configparser
from dataclasses import dataclass
@dataclass
class Sections:
raw_sections: dict
def __post_init__(self):
for section_key, section_value in self.raw_sections.items():
@jdarpinian
jdarpinian / executable.c
Last active April 2, 2025 15:41
Add one line to your C/C++ source to make it executable.
///$(which true);FLAGS="-g -Wall -Wextra --std=c17 -O1 -fsanitize=address,undefined";THIS_FILE="$(cd "$(dirname "$0")"; pwd -P)/$(basename "$0")";OUT_FILE="/tmp/build-cache/$THIS_FILE";mkdir -p "$(dirname "$OUT_FILE")";test "$THIS_FILE" -ot "$OUT_FILE" || $(which clang || which gcc) $FLAGS "$THIS_FILE" -o "$OUT_FILE" || exit $?;exec bash -c "exec -a \"$0\" \"$OUT_FILE\" $([ $# -eq 0 ] || printf ' "%s"' "$@")"
#include <stdio.h>
int main() {
printf("Hello world!\n");
return 0;
}
@danrigsby
danrigsby / gist:8346b842d1446628de5223b600668dca
Created December 12, 2017 14:34
Copy kubernetes secrets between namespaces
kubectl get secrets -o json --namespace old | jq '.items[].metadata.namespace = "new"' | kubectl create -f -
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active May 7, 2025 16:00
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
@tknerr
tknerr / ci_jobs.groovy
Created October 6, 2017 10:00
JobDSL example for setting up master / release branch builds + PR builds via bitbucket-branch-source-plugin (using the generated JobDSL)
// define the bitbucket project + repos we want to build
def bitbucket_project = 'awesome'
def bitbucket_repos = ['foo','bar','baz']
// create a pipeline job for each of the repos and for each feature branch.
for (bitbucket_repo in bitbucket_repos)
{
multibranchPipelineJob("${bitbucket_repo}-ci") {
// configure the branch / PR sources
branchSources {
@pre
pre / python_cmd.rb
Created September 7, 2017 09:55
Run Python from Ruby, stream stdout to logs and print stderr as the exception message
require 'pty'
class PythonCmd
class ExecutionError < StandardError; end
attr_reader :file
def initialize(file, args = [])
@file = file
@args = args
@mryan43
mryan43 / gist:f160fb29cbad0da169fe007735c7307b
Created August 14, 2017 06:36
Nexus 3 script delete images not downloaded since X months.
import groovy.time.TimeCategory
import org.sonatype.nexus.repository.storage.Asset
import org.sonatype.nexus.repository.storage.Component
import org.sonatype.nexus.repository.storage.Query
import org.sonatype.nexus.repository.storage.StorageFacet
def repo = repository.repositoryManager.get("sq-docker")
StorageFacet storageFacet = repo.facet(StorageFacet)
def tx = storageFacet.txSupplier().get()