Skip to content

Instantly share code, notes, and snippets.

View charterchap's full-sized avatar

Jeff Charter Chapman charterchap

View GitHub Profile
# ~/.config/starship.toml
# format = "$username$all$directory$character"
# [┌──$username─────────────────](bold green)
format = """
[\ue0b6$env_var\ue0b0](bold #039dfc)
[$python](bold green)[$username](bold green)$git_branch $git_status $character"""
[character] # The name of the module we are configuring is "character"
@charterchap
charterchap / .gitconfig
Last active October 3, 2022 14:47
git config
[alias]
lg1 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all
lg = log --graph --oneline
br = branch -a --sort=-committerdate --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'
permission-reset = !git diff -p -R --no-color | grep -E \"^(diff|(old|new) mode)\" --color=never | git apply
/* Use of lambda functions for fff custom_fake
*
* this file contains an example of how to have "nested functions"
* within a test case for setting an fff custom_fake for pass by reference args
*
* This method for custom fakes allows all your test code to be self contained
* inside a test case instead of having global functions cluttering your test
* code.
*
* note that lambda captures are not supported
#
# python_nanomsg_logger_consumer.py
# run me first
from __future__ import print_function
from nanomsg import Socket, PAIR, PUB, SUB, SUB_SUBSCRIBE
s2 = Socket(SUB)
s2.connect(b"ipc:///tmp/nanologger.ipc")
s2.set_string_option(SUB, SUB_SUBSCRIBE, b'')
@charterchap
charterchap / fnv1_32.rs
Last active February 28, 2017 02:04
fnv1_32 and fnv1a_32 in rust
// see libhashkit/fnv_32.cc from memcached
// Just using this as excuse to test out the Rust lang
// be warned on correctness, completeness, etc
// Should match libhashkit
// should also match https://www.nitrxgen.net/hashgen/
// FNV hash'es lifted from Dustin Sallings work
@charterchap
charterchap / atomic_writes.cpp
Created September 16, 2015 03:30
atomic writes linux c++, QT, Boost, GNU
// Practical snippets for loosely atomic writes on linux
// Important, even more so on allocate on flush file systems such as xfs and ext4.
// You can learn more here: https://www.flamingspork.com/talks/
// https://www.kernel.org/doc/Documentation/filesystems/ext4.txt
// These snippets are not perfect, if writing cross platform applications - marco guards
// Just trying to convey the gist
// The basic routine is:
// 1. Write data as file.new
@charterchap
charterchap / osm_get_road_lengths.cpp
Last active September 16, 2015 03:19
Figure out OSM road lengths
/*
This is an example tool that computes the sums of highway lengths.
by Frederik Ramm <frederik@remote.org>
notes from Charter Chapman:
I picked this up in 2015 and it didn't work :( so hammered it until it worked
You need the latest of the old Osmium
https://github.com/joto/osmium
@charterchap
charterchap / onelineart
Last active November 11, 2016 17:00
ascii art for my ps1 prompt
# I find it useful to have return codes printed on my terminal prompt
# I went overboard
### On success print fun art!
# |\/| /\ /
# .__.. \_/ \/
# \____/_ __/
# /_/_/ ~/Documents
### on fail
# :( ~/Documents
# I had a problem today where trying to load things into an Xvfb was not working because the xvfb
# was not yet initialized. The problem script is as follows:
# Start the Xvfb on DISPLAY :1,
`dirname $0`/Xvfb :1 -screen 0 1280x1024x24 -ac -br -fbdir /dev/shm & xvfbpid=$!
DISPLAY=:1 xli -onroot -fillscreen `dirname $0`/images/background.png
# The only solution I see on the web is to insert a sleep statement.
# I don't much like that. The solution I came up with is to wait for the display to be ready to use via xdpyinfo.
# The working script:
@charterchap
charterchap / fnv1a_32.js
Last active September 19, 2016 21:05
fnv1a_32 hash in javascript consistent w/ libhashkit
// J. Charter Chapman
// fnv1a_32 in javascript based on libhashkit
// this one actually outputs consistent with hashkit
// there are a couple of interesting implementations out there
// string to byte array [think char *]
function getBytes(s) {
var buf = [];
for (var i = 0; i < s.length; i++) {
buf.push(s.charCodeAt(i));