Skip to content

Instantly share code, notes, and snippets.

View csandman's full-sized avatar

Chris Sandvik csandman

View GitHub Profile
@csandman
csandman / squashing-commits.md
Last active May 1, 2020 16:55
A simple process for squashing commits before (or after) making a pull request

How to Squash Git Commits

Borrowed from wprig

Some applications that interact with git repos will provide a user interface for squashing. Refer to your application's document for more information.

If you're familiar with Terminal, you can do the following:

@csandman
csandman / get-number-with-ordinal.js
Created March 27, 2020 21:32
A function to get a number string with the ordinal suffix in JS
function getNumberWithOrdinal(n) {
const s = ["th", "st", "nd", "rd"];
const v = n % 100;
return n + (s[(v - 20) % 10] || s[v] || s[0]);
}
@csandman
csandman / aac-st.mmcp.xml
Created March 9, 2020 16:04
MakeMKV Profiles
<?xml version="1.0" encoding="utf-8"?>
<profile>
<!-- profile name -->
<name lang="eng">AAC-stereo</name>
<!-- Common MKV flags -->
<mkvSettings
ignoreForcedSubtitlesFlag="true"
useISO639Type2T="false"
setFirstAudioTrackAsDefault="true"
@csandman
csandman / handbrakecli-usage.txt
Created February 18, 2020 01:27
Documentation for the handbrake cli
Usage: HandBrakeCLI [options] -i <source> -o <destination>
General Options --------------------------------------------------------------
-h, --help Print help
--version Print version
--json Log title, progress, and version info in
JSON format
-v, --verbose[=number] Be verbose (optional argument: logging level)
-Z. --preset <string> Select preset by name (case-sensitive)
@csandman
csandman / makemkvcon-usage.txt
Created February 18, 2020 01:25
Documentation for makemkvcon
makemkvcon [options] Command Parameters
General options:
--messages=file
Output all messages to file. Following special file names are recognized:
-stdout - stdout
-stderr - stderr
-null - disable output
Default is stdout
@csandman
csandman / web.config
Created December 3, 2019 21:19
Web config file to make create-react-app routing work in an Azure app service
<?xml version="1.0"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="React Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
@csandman
csandman / popup-center.md
Last active November 26, 2019 14:19
Center a popup window with 1 or 2 monitors

A somewhat niche problem is opening a centered popup window when you have multiple monitors. One you case you might encounter for this is opening a Twitter Web Intent window, which creates a tweet for a user to post. Here is their recomended code for opening a Web Intent popup:

(function() {
  if (window.__twitterIntentHandler) return;
  var intentRegex = /twitter\.com\/intent\/(\w+)/,
      windowOptions = 'scrollbars=yes,resizable=yes,toolbar=no,location=yes',
      width = 550,
      height = 420,
      winHeight = screen.height,
@csandman
csandman / setup.md
Last active December 19, 2019 15:51
Setup for a React project using ESLint and Prettier

Setup for ESLint and Prettier

Here is a quick guide for getting set up with a basic react app with eslint and prettier

Installation

  1. First run
npx create-react-app app-name
cd app-name
@csandman
csandman / parse-emojis.js
Created September 24, 2019 02:48
A JS function to pull all emojis from a string into a new array (From lodash)
function parseEmojis(str) {
return str.match(/(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0]|\ud83c[\udffb-\udfff])?)*/);
}
@csandman
csandman / Contributing.md
Created September 20, 2019 14:51
Contributing to open source on github
  1. Fork the repo
  2. Clone the repo
  3. git checkout -b NEW_BRANCH
  4. git remote add upstream ORIGINAL_REPO_URL
  5. Make changes
  6. Commit and push changes
  7. Open your repo on Github
  8. Click Compare & pull request
  9. Enter description
  10. Click Create pull request