Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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;
@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 / react-component-es6.sublime-snippet
Last active February 9, 2016 14:58
React JSX Sublime Text Snippets
<snippet>
<content><![CDATA[
import React, { Component } from 'react';
export default class ${TM_FILENAME/(.?\w*)(?:\.\w+)*$/$1/g} extends Component {
static propTypes = {
};
render() {
return (
@aortbals
aortbals / zippable.rb
Last active September 24, 2015 02:28
Zip a directory in memory with ruby
require 'find'
require 'zip'
module Zippable
def to_zip
return zipped_file_path if File.exists? zipped_file_path
validate_file_exists
::Zip::File.open(zipped_file_path, ::Zip::File::CREATE) do |zipfile|
if File.directory? file_path