Skip to content

Instantly share code, notes, and snippets.

View shoemoney's full-sized avatar

Jeremy Schoemaker shoemoney

View GitHub Profile
@shoemoney
shoemoney / sample.php
Created January 24, 2022 11:50 — forked from robertuniqid/sample.php
PHP : empty vs == vs ===
<?php
$t = '';
$before = microtime(true);
for ($i=0 ; $i<100000 ; $i++) {
$dummy = empty( $t );
}
#!/bin/bash
############################---Usage---#########################################
#source this function in your bashrc
# Copy below functions (delay and progress fuctions) into your shell script directly
# Then invoke progress function to show progress bar
# In other way, you could import source indirectly then using. Nothing different
@shoemoney
shoemoney / backup.tar
Created December 28, 2021 12:56 — forked from jasontbradshaw/backup.tar
A simple backup script using tar.
#!/usr/bin/env sh
# arguments
name="${1}"
src="${2}"
dest_dir="$(dirname "${3}/gets_removed")"
# validate arguments
if [ -z "${name}" ]; then
echo "Invalid backup name (first argument)"
@shoemoney
shoemoney / backup.bup
Created December 28, 2021 12:56 — forked from jasontbradshaw/backup.bup
A backup script using bup.
#!/usr/bin/env bash
# Strict mode (see: http://redsymbol.net/articles/unofficial-bash-strict-mode/).
set -euo pipefail
IFS=$'\n\t'
# We name the repository directory after the system's hostname and the current
# year/month. We include the year/month combo so our backup repository doesn't
# continue to grow forever, and we can manually delete old ones as necessary.
name="$(hostname)"
@shoemoney
shoemoney / AllowSSHFromIP.php
Created October 20, 2021 20:19 — forked from oddergaard/AllowSSHFromIP.php
Complementary code and IAM policy for "You don't need that Bastion host"
<?php
// For laravel 5 based systems
// /path/to/project/app/Console/Commands/AllowSSHFromIP.php
namespace App\Console\Commands;
use Aws\Ec2\Ec2Client;
use Carbon\Carbon;
use Illuminate\Console\Command;
@shoemoney
shoemoney / understanding_systemd_boot_execution_graph.md
Created October 5, 2021 14:56 — forked from CMCDragonkai/understanding_systemd_boot_execution_graph.md
Understanding systemd Boot Execution Graph #systemd
@shoemoney
shoemoney / http_streaming.md
Created October 5, 2021 14:53 — forked from christianromney/http_streaming.md
HTTP Streaming (or Chunked vs Store & Forward)

HTTP Streaming (or Chunked vs Store & Forward)

The standard way of understanding the HTTP protocol is via the request reply pattern. Each HTTP transaction consists of a finitely bounded HTTP request and a finitely bounded HTTP response.

However it's also possible for both parts of an HTTP 1.1 transaction to stream their possibly infinitely bounded data. The advantages is that the sender can send data that is beyond the sender's memory limit, and the receiver can act on

#!/usr/bin/env bash
set -o pipefail
slow_compute_hash() {
find "$1" -type f -exec md5sum {} \; | sort -k 2 | md5sum
}
fast_compute_hash() {
find "$1" -type f -print0 | sort -z | xargs -0 md5sum | md5sum
}
@shoemoney
shoemoney / README.md
Created October 5, 2021 10:42 — forked from socheatsok78/README.md
lnav — Laravel Log Formatter

Laravel Log Formatter for Lnav


Installation

lnav -i https://gist.github.com/80d1d179c5706f85b281a5558217a5fe.git
# or
lnav -i git@gist.github.com:80d1d179c5706f85b281a5558217a5fe.git

Usage

@shoemoney
shoemoney / mkramdisk-mac-osx.sh
Created October 3, 2021 09:28
Make a ram disk on mac in 2021. !!
//this makes a 8gb RAM DISK
diskutil erasevolume HFS+ "ramdisk" `hdiutil attach -nomount ram://16384000`