Skip to content

Instantly share code, notes, and snippets.

View jgraham909's full-sized avatar

Jeff Graham jgraham909

View GitHub Profile
@jgraham909
jgraham909 / 57-add-emoji-support.conf
Created May 29, 2024 18:57 — forked from kylewlacy/57-add-emoji-support.conf
Add Emoji to Linux Fontconfig (edited to fix broken fonts for Zoom video conference)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!--
Author: Santiago Saavedra <[email protected]>, Kyle Lacy
License: CC0
Year: 2016-2017
Install:
Copy to $XDG_CONFIG_DIR/fontconfig/conf.d/57-add-emoji-support.conf
Run fc-cache -f
@jgraham909
jgraham909 / diff-to-html.sh
Created March 24, 2023 19:05
colored diff output to html
# uses diff, diffr, sed, aha
# pre.txt is original file, post.txt is updated file
diff -u pre.txt post.txt | diffr | aha | sed 's/color:gray/color:white/g' | sed 's/<pre>/<pre style="white-space: pre-wrap;">/g' > diff.html
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
// Excerpt from ad-block/scripts/generateDataFiles and inspired from ad-block/scripts/check.js
const url = require('url');
const path = require('path')
const fs = require('fs')
const {AdBlockClient, FilterOptions} = require('ad-block');
@jgraham909
jgraham909 / pdftotext.sh
Created November 30, 2016 17:25
Given a URL to a PDF convert it to text
#!/bin/bash
# This script requires curl and gs.
# Set ghostscript & curl options.
GSOPTIONS="-dNOPAUSE -dBATCH -sDEVICE=txtwrite -sOutputFile=%stdout -q"
CURLOPTIONS="-s"
# Check we have the appropriate number of parameters.
if [ "$#" -ne 1 ]; then
echo "Invalid number of parameters."
#!/bin/bash
RED='\e[31m'
GREEN='\e[32m'
YELLOW='\e[33m'
BLUE='\e[34m'
NC='\e[0m'
FAIL="${RED} FAIL: ${NC}"
PASS="${GREEN} PASS: ${NC}"
@jgraham909
jgraham909 / promises
Last active June 23, 2016 19:34
Javascript Promises. Where errors are silently swallowed with no indication.If you use promises and don't have something like this snippet in your code, good luck!
process.on('unhandledRejection', (reason, promise) => {
console.error('ERROR: Unhandled Rejection: ', reason);
console.dir(promise);
});
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Hello React</title>
<script src="https://fb.me/react-0.14.7.js"></script>
<script src="https://fb.me/react-dom-0.14.7.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js"></script>
</head>
<body>
@jgraham909
jgraham909 / fileLines2Array.sh
Created January 6, 2016 23:36 — forked from akwala/fileLines2Array.sh
Bash function to read the lines of a file into an array using the builtin, mapfile.
#!/bin/bash
### Pretty-print dedicated (array) var, MAPFILE.
prettyPrintMAPFILE() {
let i=0
echo "[MAPFILE]"
for l in "${MAPFILE[@]}"
do
echo "$i. |$l|"
let i++
done
#!/bin/bash
NEWRAND=$(cat /dev/urandom | env LC_CTYPE=C tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1)
echo "Type the following; '$NEWRAND'"
read var1
echo "You typed $var1"