Skip to content

Instantly share code, notes, and snippets.

View aortbals's full-sized avatar

Aaron Ortbals aortbals

View GitHub Profile
@aortbals
aortbals / ocr.bash
Created February 19, 2020 21:10
OCR all files in a folder using Tesseract, ignoring existing files.
#! /usr/bin/env bash
### ocr
#
# OCR all files in a folder using Tesseract, ignoring existing files.
#
## Functions
usage() {
@aortbals
aortbals / squash-and-merge-cli.md
Last active January 16, 2024 10:46
Squash and Merge on the Command line

With the introduction of GitHub's Squash and Merge feature, this has become less prevelant, however it's still useful in scenarios where GitHub's interface is unavailable.

Let's talk through two ways to do a squash and merge on the command line.

Take 1: Interactive Rebase

When to use it

  • When you have not merged main into your feature branch
  • There are no merge conflicts
@aortbals
aortbals / dispatch.py
Last active October 20, 2023 16:09
Synchronize two folders using python.
#! /usr/bin/python
# Dispatch - synchronize two folders
import os
import filecmp
import shutil
from stat import *
class Dispatch:
''' This class represents a synchronization object '''
@aortbals
aortbals / vm-create.bash
Created March 22, 2022 22:02
Create a kvm image using libvirt and uvtool. Image is configured with bridge networking.
#! /usr/bin/env bash
### Create VM
#
# Create a kvm image using libvirt and uvtool. Image is configured with
# bridge networking.
#
## Functions
@aortbals
aortbals / rsync_time_machine.sh
Created March 5, 2013 18:10
Time machine backup via rsync for any unix machine.
#!/bin/bash
# Title: rsync_time_machine.sh
# Description: Time machine backup via rsync for any unix machine
# Usage:
#
# - Set the following variables:
# `HOME`: the home directory on the local machine to be backed up
# `HOST`: the SSH destination to send the backup to
# `REMOTEBACKUPDIR`: the location on the remote destination to store the backup
@aortbals
aortbals / Moment.js React Component.md
Last active April 11, 2019 02:21
React <Moment /> Component

Basic Format API

Since the usage of format is so common, there is an easy API:

<Moment date={publishedAt} format="MMMM D, YYYY" />

Advanced API

@aortbals
aortbals / tsconfig.json
Created December 6, 2018 23:59
create-react-app TypeScript configs
{
"compilerOptions": {
"target": "esnext",
"allowJs": true,
"skipLibCheck": false,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
@aortbals
aortbals / csp-sha.js
Last active April 20, 2017 17:56
Generate a sha256-base64 string for a content security policy
#!/usr/bin/env node
const crypto = require('crypto');
if (!process.argv[2]) {
console.log('Usage: csp-sha <string>');
process.exit();
}
console.log(crypto.createHash('sha256').update(process.argv[2]).digest('base64'));
@aortbals
aortbals / app.css
Created April 5, 2017 21:40
CSS Modules and Global CSS with Webpack 1.x
/*
This file contains non-global CSS modules
*/
@import "css/variables";
@import "css/utilities";
:global html {
color: var(--black);
}
@aortbals
aortbals / checkStatus.js
Last active April 4, 2017 21:30
Check the status of a fetch response
/**
* Check the status of a fetch response.
*/
export default function checkStatus(response) {
if (response.ok) {
return response;
}
const error = new Error(response.statusText);
error.response = response;