Skip to content

Instantly share code, notes, and snippets.

Avatar

Nigel Thorne NigelThorne

View GitHub Profile
@NigelThorne
NigelThorne / infinite_cube.scad
Created Jul 5, 2022
An OpenScad model of an infinite cube.
View infinite_cube.scad
$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 Mar 1, 2022
Col returns the specified columns from each line in stdin
View col
#!/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 Aug 28, 2020
AzureDevops Git aliases
View .gitconfig
[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 Jun 29, 2020 — forked from ttscoff/karabiner.json
Karabiner Elements hyper key with escape
View karabiner.json
"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 Sep 20, 2019
Highlight Active window in windows - using AHK
View active_window_boarder.ahk
#Persistent
SetTitleMatchMode, 2
SetTitleMatchMode, Fast
SetTimer, DrawRect, 50
border_thickness = 20
HideTime := A_TickCount
offset := 0
@NigelThorne
NigelThorne / everything.el
Created Mar 22, 2019
EmacsLisp to add everything search engine to emacs (https://www.emacswiki.org/emacs/Everything)
View everything.el
;;; 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
View .gitalias
# 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 Jan 16, 2017
AdHoc Scripts to compare regex files and look for strings that were not translated correctly.
View compare.rb
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 Dec 20, 2016
Scan log files and track number of subscribers over time. (for dumping into excel)
View scan.rb
# 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'
View cowsay.rb
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))}