Skip to content

Instantly share code, notes, and snippets.

Avatar

Aaron Ortbals aortbals

View GitHub Profile
@aortbals
aortbals / ocr.bash
Created Feb 19, 2020
OCR all files in a folder using Tesseract, ignoring existing files.
View ocr.bash
#! /usr/bin/env bash
### ocr
#
# OCR all files in a folder using Tesseract, ignoring existing files.
#
## Functions
usage() {
@aortbals
aortbals / tsconfig.json
Created Dec 6, 2018
create-react-app TypeScript configs
View tsconfig.json
{
"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 Sep 9, 2020
Squash and Merge on the Command line
View squash-and-merge-cli.md

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 master into your feature branch
  • There are no merge conflicts
@aortbals
aortbals / csp-sha.js
Last active Apr 20, 2017
Generate a sha256-base64 string for a content security policy
View csp-sha.js
#!/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 Apr 5, 2017
CSS Modules and Global CSS with Webpack 1.x
View app.css
/*
This file contains non-global CSS modules
*/
@import "css/variables";
@import "css/utilities";
:global html {
color: var(--black);
}
@aortbals
aortbals / checkStatus.js
Last active Apr 4, 2017
Check the status of a fetch response
View checkStatus.js
/**
* 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 Apr 11, 2019
React <Moment /> Component
View Moment.js React Component.md

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 Feb 9, 2016
React JSX Sublime Text Snippets
View react-component-es6.sublime-snippet
<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 Sep 24, 2015
Zip a directory in memory with ruby
View zippable.rb
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
@aortbals
aortbals / controllers.application.js
Last active Aug 29, 2015
Array Computed Properties
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
items: [
{ name: 'Fuu' },
{ name: 'Bar' },
{ name: 'Baz' },
{ name: 'Qix' }
You can’t perform that action at this time.