Skip to content

Instantly share code, notes, and snippets.

View dantheman213's full-sized avatar
๐Ÿš€

Dan dantheman213

๐Ÿš€
View GitHub Profile
@dantheman213
dantheman213 / random_string.sh
Last active December 3, 2018 07:44
Bash Shell Script Cross-platform Generate Random String Easily With Pre-Installed System Tools
#!/bin/bash
# Bash Shell Script Cross-platform Generate Random String Easily With Pre-Installed System Tools
MD5_BIN="md5sum" # default for windows git bash and linux
COMMAND_OUTPUT=$(command -v md5sum)
if [ ${#COMMAND_OUTPUT} -lt 1 ]; then
MD5_BIN="md5" # OSX
fi
@dantheman213
dantheman213 / reset_files_lf_encoding.sh
Created March 7, 2018 20:35
Change all files in a dir from CRLF to LF file encoding
find . -type f -print0 | xargs -0 dos2unix
@dantheman213
dantheman213 / secrets_manager_kubernetes.sh
Created January 12, 2018 03:18
Easily get or set secrets to or from the Google Cloud to your local repo for Docker dev.
#!/bin/bash
# Description: Easily get or set secrets to or from the Google Cloud to your local repo for Docker dev.
# Dependencies: kubectl (logged in with permissions to access kubernetes), jq
# Installation: To install, just move into /usr/local/bin/ and make sure it has execute permissions
set -e # halt on errors
# Set script vars
@dantheman213
dantheman213 / encrypt_openssl.md
Created January 8, 2018 02:25 — forked from dreikanter/encrypt_openssl.md
File encryption using OpenSSL

Symmetic encryption

For symmetic encryption, you can use the following:

To encrypt:

openssl aes-256-cbc -salt -a -e -in plaintext.txt -out encrypted.txt

To decrypt:

@dantheman213
dantheman213 / docker_clean.sh
Last active October 6, 2023 09:01
Reset Docker to a clean vanilla state
#!/usr/bin/env bash
# Reset Docker to a clean vanilla state. Will destroy all containers, images, networks, volumes, and cache.
[ $(docker ps | wc -l) -ne 1 ] && echo "Stopping all containers..." && docker stop $(docker ps | sed -n '1d;p' | awk -F" " '{print $1}')
[ $(docker ps -a | wc -l) -ne 1 ] && echo "Deleting all containers..." && docker rm $(docker ps -a | sed -n '1d;p' | awk -F" " '{print $1}')
[ $(docker images | wc -l) -ne 1 ] && echo "Deleting all images..." && docker image rm $(docker images | sed -n '1d;p' | awk -F" " '{print $3}')
echo "Pruning networks, volumes, and cache..." && docker system prune -a -f --volumes
echo "Docker is back to Vanilla... COMPLETE!"
@dantheman213
dantheman213 / main.go
Created September 26, 2017 22:38
Simple Go Rest App
package main
import (
"fmt"
"encoding/json"
"github.com/gorilla/mux"
"log"
"net/http"
)
@dantheman213
dantheman213 / main.cpp
Last active April 29, 2018 21:11
LeagueHelperUrf - League of Legends Urf Mode Assist. Spam the QWER keys as fast as possible using C++.
#include <iostream>
#include <thread>
#include <windows.h>
#include <conio.h>
const WORD keyCodes[4] = {
0x51, // Q
0x57, // W
0x45, // E
@dantheman213
dantheman213 / count_lines_of_code_git.sh
Created May 27, 2017 19:06
Count how many lines of code are in git repo
git ls-files | xargs wc -l
@dantheman213
dantheman213 / transcode_media_ffmpeg.sh
Last active March 25, 2017 01:00
Batch transcode mp4 files from a directory, set bitrate, and output to another directory.
#!/bin/sh
#
# Batch transcode mp4 files from a directory,
# set bitrate, and output to another directory.
# User-defined parameters
INPUT_DIR="/home/user/Videos/pre"
OUTPUT_DIR="/home/user/Videos/post"
MEDIA_EXTENSION="mp4"
TARGET_BITRATE_VIDEO="8M"
#/bin/bash
# Get the Dependencies
# Copy and paste the whole code box for each step. First install the dependencies:
sudo apt-get update
sudo apt-get -y install autoconf automake build-essential libass-dev libfreetype6-dev \
libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev \
libxcb-xfixes0-dev pkg-config texinfo zlib1g-dev