Skip to content

Instantly share code, notes, and snippets.

View benmatselby's full-sized avatar

Ben Selby benmatselby

View GitHub Profile
@benmatselby
benmatselby / location.py
Created April 12, 2024 19:51
Geolocation investigation
# Script to get locations based on lat/long or IP address
#
# Installation:
# pip install geopy
# pip install ip2geotools
from geopy.geocoders import Nominatim
from ip2geotools.databases.noncommercial import DbIpCity
# ------------------------------
@benmatselby
benmatselby / pre-commit
Last active November 12, 2022 14:53
Example pre-commit hook
#!/usr/bin/env bash
#
# Git pre-commit hook
#
# Colours https://misc.flogisoft.com/bash/tip_colors_and_formatting
reset=$'\e[0m'
red=$'\e[1;31m'
@benmatselby
benmatselby / provider.tf
Last active April 11, 2021 10:41
Terraform GitHub Repo Admin
provider "github" {
token = var.github_token
owner = var.github_org
}
@benmatselby
benmatselby / Cobra vscode debug config
Last active August 26, 2023 19:42
Cobra vscode debug config
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch file",
"type": "go",
"request": "launch",
@benmatselby
benmatselby / gist:3a5c44afab7be20a3b69
Last active August 29, 2015 14:23
Open terminal to a set of servers using apple script
on run argv
tell application "Terminal"
set profile to item 1 of argv
set platform to item 2 of argv
set serverCount to item 3 of argv
tell app "Terminal" to set current settings of first window to settings set profile
repeat with theIncrementValue from 1 to serverCount
@benmatselby
benmatselby / Installed Sublime Text Plugins
Last active October 14, 2023 20:11
Installed Sublime Text Plugins
**Currently used**
- Package Control (Turned on, now built into Sublime)
- Phpcs
- [Formatter](https://packagecontrol.io/packages/Formatter#configuration)
- [Markdown Edtiging](https://packagecontrol.io/packages/MarkdownEditing)
- [Python 3](https://packagecontrol.io/packages/Python%203)
- [python-back](https://packagecontrol.io/packages/python-black) - Can this be replaced with formatter?
- UnitTesting
@benmatselby
benmatselby / Setting hostname on a mac
Created June 2, 2014 10:15
Setting hostname on a mac
With all the machines I now use, and the fact I’m getting older and my memory is going, I needed to add hostname into my bash prompt for the first time, and came across a little issue on Apple’s Mac OS X Mountain Lion.
When I updated my PS1 setting I was getting:
```
(null):~
```
Not so good. I was also getting similar responses when I was running “hostname” on the command line.
@benmatselby
benmatselby / Jenkins Plugins
Created June 2, 2014 10:13
Jenkins Plugins
Green Balls
Checkstyle
xUnit
HTML Publisher
Timestamper
AnsiColor
Cron Column
Build Monitor
@benmatselby
benmatselby / DocBlox checkstyle
Created October 6, 2011 18:34
DocBlox checkstyle
<checkstyle version="1.3.0">
<file name="Some/File.php">
<error line="1" severity="error" message="Some kind of error" source="DocBlox.DocBlox.DocBlox"/>
<error line="2" severity="critical" message="Some kind of critical issue" source="DocBlox.DocBlox.DocBlox"/>
<error line="3" severity="notice" message="Some kind of notice" source="DocBlox.DocBlox.DocBlox"/>
<error line="4" severity="warning" message="Some kind of warning" source="DocBlox.DocBlox.DocBlox"/>
</file>
</checkstyle>
@benmatselby
benmatselby / speed.php
Created April 19, 2011 02:44
Test to see which is quicker, explode or substring to find the last part of a php class name
<?php
// How many times to we want to iterate
$count = isset($argv[1]) ? $argv[1] : 1000;
// Which function are we wanting to test
if (isset($argv[2]) && in_array($argv[2], array('explodeVersion', 'substringVersion'))) {
$function = $argv[2];
} else {
$function = 'explodeVersion';