Skip to content

Instantly share code, notes, and snippets.

View NigelThorne's full-sized avatar

Nigel Thorne NigelThorne

View GitHub Profile
@NigelThorne
NigelThorne / infinite_cube.scad
Created July 5, 2022 00:06
An OpenScad model of an infinite cube.
$fn=40;
sz=10;
module ccube(x,y,z){
gap=0.4;
ch=(sz+gap)*0.25;
xoffset = sz * x;
yoffset = sz * y;
zoffset = sz * z;
@NigelThorne
NigelThorne / col
Last active March 1, 2022 00:34
Col returns the specified columns from each line in stdin
#!/usr/bin/bash
# Usage: col x x x
# where x is a column number or + to mean all following columns
#
# example: ls -al | col 6 7 9
# example: ls -al | col 2 7 +
# example: ls -al | col -1
# Here is a fun use... interleave lines from logs from several containers in timestamp order
# docker-compose logs --tail='all' -t | col 3 1 + | sort | col 2 +
@NigelThorne
NigelThorne / .gitconfig
Created August 28, 2020 09:13
AzureDevops Git aliases
[alias]
pushu = !git push --set-upstream origin `git symbolic-ref --short HEAD` && git rpr
current-branch-name = !git rev-parse --abbrev-ref HEAD
current-branch-name-escaped = !git escape-url `git current-branch-name`
escape-url = "!f() { perl -MURI::Escape -e \"print uri_escape('"$*"');\"; }; f"
current-push-url = !git remote get-url --push origin
raise-pull-request = !sh -c \"echo -e \\\" \\nRaise a pull request here: \\n `git current-push-url`/pullrequestcreate?sourceRef=`git current-branch-name-escaped`&targetRef=master\\\"\"
rpr = raise-pull-request
@NigelThorne
NigelThorne / karabiner.json
Last active June 29, 2020 02:06 — forked from ttscoff/karabiner.json
Karabiner Elements hyper key with escape
"complex_modifications": {
"rules": [
{
"manipulators": [
{
"description": "Change caps_lock to command+control+option+shift. Escape if no other key used.",
"from": {
"key_code": "caps_lock",
"modifiers": {
"optional": [
@NigelThorne
NigelThorne / active_window_boarder.ahk
Created September 20, 2019 06:48
Highlight Active window in windows - using AHK
#Persistent
SetTitleMatchMode, 2
SetTitleMatchMode, Fast
SetTimer, DrawRect, 50
border_thickness = 20
HideTime := A_TickCount
offset := 0
@NigelThorne
NigelThorne / everything.el
Created March 22, 2019 03:59
EmacsLisp to add everything search engine to emacs (https://www.emacswiki.org/emacs/Everything)
;;; everything.el --- Bridge to MS Windows desktop-search engine Everything
;; Copyright (C) 2012 Martin Weinig
;; Author: Martin Weinig <mokkaee@gmail.com>
;; Keywords: tools,windows,files,searching
;; Version: 0.1.5
;; Filename: everything.el
;; Compatibility: GNU Emacs 23.x
@NigelThorne
NigelThorne / .gitalias
Last active August 4, 2020 07:45
Git Aliases
# View abbreviated SHA, description, and history graph of the latest 20 commits
l = log --pretty=oneline -n 20 --graph --abbrev-commit
# View the current working tree status using the short format
s = status -s
# Show the diff between the latest commit and the current state
d = !"git diff-index --quiet HEAD -- || clear; git --no-pager diff --patch-with-stat"
@NigelThorne
NigelThorne / compare.rb
Last active January 16, 2017 05:48
AdHoc Scripts to compare regex files and look for strings that were not translated correctly.
if(ARGV.count < 2)
puts "Usage: #{__FILE__} file1.resx file2.resx"
exit -1
end
if(`gem list`.scan(/nokogiri/).count == 0)
puts "You need to install nokogiri. Type 'gem install nokogiri' at a command prompt"
exit -1
end
@NigelThorne
NigelThorne / scan.rb
Last active December 20, 2016 01:31
Scan log files and track number of subscribers over time. (for dumping into excel)
# Run through all zip files to get log files
# Process log files => events
# Process events => (event + initial_state) => new_state => to state stream
#
require 'rubygems'
require 'zip'
def has_arg(arg)
ARGV.include? arg
end
text = ARGV[0]
lines = text.scan(/.{0,40}(?:\b|$)/).map{|l| l.strip }
lines = (lines[-1] == "" ? lines[0...-1] : lines)
longest = lines.map{|l| l.length}.max
lines.map!{|l| l+ (" " * (longest - l.length))}