Skip to content

Instantly share code, notes, and snippets.

Jamis Charles jamischarles

  • PayPal
  • near Boulder, CO
Block or report user

Report or block jamischarles

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
- 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 / 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 / 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)
jamischarles / functions.php
Created Apr 25, 2012
Display links to WordPress blog posts on non-WP pages using the WordPress API.
View functions.php
//add this code at the end of "functions.php" (Theme Functions). This can be accessed through the WP admin menu under Appearance -> Editor -> Theme Functions
//this is the logic to get the posts you want
function displayHomePosts(){
//default values obj from post.php.
//pass these in as args that you really want
$defaults = array(
'numberposts' => 5, 'offset' => 0,
'category' => 0, 'orderby' => 'post_date',
jamischarles / .npm_install_autocomplete_bash
Last active Jul 13, 2016
npm install autocompletion for bash. Provides content of `~/.npm` as autocomplete options for `npm install`
View .npm_install_autocomplete_bash
#!/usr/bin/env bash #adding this to force silly gist highlighting. REMOVE THIS
# BASH standalone npm install autocomplete. Add this to ~/.bashrc file.
_npm_install_completion () {
local words cword
if type _get_comp_words_by_ref &>/dev/null; then
_get_comp_words_by_ref -n = -n @ -w words -i cword
You can’t perform that action at this time.