Skip to content

Instantly share code, notes, and snippets.


Jamis Charles jamischarles

View GitHub Profile
jamischarles / Sci-fi.txt
Last active Oct 5, 2020
Best books I've read
View Sci-fi.txt
## Military Scifi:
-Expeditionary Force Series
-Galaxy's Edge Series
## Unique Scifi
-Skyward (Top Gun in space)
-Bobiverse Series
-Enders Game (re-read this every few years)
-Murderbot Diaries Series (really great)
-Artemis (Andy Weir)
jamischarles / sanitize_json.js
Created Jun 25, 2011
JavaScript: Sanitize JSON string before saving, so it can be read again. (Escapes newlines etc)
View sanitize_json.js
function sanitizeJSON(unsanitized){
return unsanitized.replace(/\\/g, "\\\\").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t").replace(/\f/g, "\\f").replace(/"/g,"\\\"").replace(/'/g,"\\\'").replace(/\&/g, "\\&");
jamischarles / get.js
Last active Jan 8, 2020
Rebuilding simple version of _.get()
View get.js
function get(base, pathQuery, returnOnUndefinedValue) {
var pathArr = pathQuery.split('.');
var currentVal = base;
for (var i=0; i<pathArr.length; i++) {
var key = pathArr[i];
currentVal = currentVal[key];
if (!currentVal) {
return returnOnUndefinedValue ;
- my normal flow?
- good commit messages ******
- searching commit messages (group by keywords)
- searching code *
- working with history (viewing, time traveling)
- rebasing (for pulling & squashing, splitting a commit) *
- undoing local commits (soft, hard reset)
- forgot to add / change message (amend)
- LOST commits? *
jamischarles /
Last active Feb 21, 2019
Git move - Move file to new repo and preserve history
# $ ./gitmove [destGitRepo] [src_file]
# get the earliest hash of a source file to copy
HASH=$(git log --format=%H $SOURCE_FILE | tail -1)
# echo $HASH
jamischarles / mdx
Created Feb 20, 2019
Generated mdx file
View mdx
slug: introducing-the-react-testing-library
date: 2019-02-18
title: Introducing the react-testing-library 🐐
description: "NOTE: This is a cross-post from my newsletter. I publish each email two weeks after it’s sent. Subscribe to get more content like this earlier right in your inbox! 💌 Two weeks ago, I wrote a new…"
categories: ['React']
keywords: [React,JavaScript,Testing]
banner: './images/banner.jpg'
jamischarles / chainMiddleware.js
Last active Dec 9, 2017
Simple example showing how to chain functions similar to how middleware is chained in express.js
View chainMiddleware.js
// simple example of how to create a function that calls a middleware chain, similar to express middleware
var req = {type: "req"};
var res = {type: "res"};
// 3 middlewares
var first = function(req, res, next) {
req.first = true; //easy way to verify that all have been executed
res.first = true;
return next();
jamischarles / main.js
Last active Nov 26, 2017
node debugging via inspector api
View main.js
var http = require('http')
// Expectation: When I curl localhost:3000, I want to be able to
var server = http.createServer(function (req, res)
res.statusCode = 200;
res.write(e.stack); // throws exception
View npm_completion_with_install
#!/usr/bin/env bash #adding this to force silly gist highlighting. REMOVE THIS
# This is a modified version of the script generated by to include `npm install` autocompletion.
# Basically we added `if` blocks to check for `install` subcommand.
# npm command completion script
# Installation: npm completion >> ~/.bashrc (or ~/.zshrc)
You can’t perform that action at this time.