Skip to content

Instantly share code, notes, and snippets.

View mrmanc's full-sized avatar

Mark Crossfield mrmanc

View GitHub Profile
class SwissArmyKnife implements Screwdriver, Corkscrew {
public boolean canScrew(String item) {
// return ITEM.equals(item); // can’t do this as ITEM is ambiguous.
return Screwdriver.ITEM.equals(item) || Corkscrew.ITEM.equals(item);
}
}
interface Screwdriver {
public static String ITEM = "Screw";
@mrmanc
mrmanc / agile-octopus-2023-12.json
Created February 25, 2024 18:30
agile octopus costs 2023-12
[
{
"value_exc_vat": 17.43,
"value_inc_vat": 18.3015,
"valid_from": "2024-01-05T23:30:00Z",
"valid_to": "2024-01-06T00:00:00Z",
"payment_method": null
},
{
"value_exc_vat": 15.75,
@mrmanc
mrmanc / test.md
Last active January 22, 2024 17:14
test
mindmap
    root((Pairing Cards))
        Things to say
            What do you think the next step is
            How would you solve this problem with a pen and paper
            Let us get something working
        Concepts
            YAGNI
 Red, Green, Refactor
mindmap
    root((Pairing Cards))
        Things to say
            What do you think the next step is
            How would you solve this problem with a pen and paper?
            Let‘s get something working
            Tell me what you think our objective is
            Where do you think we are up to?
            What is the simplist test we could write?
@mrmanc
mrmanc / disable-macos-man-page-shortcuts.md
Last active July 28, 2024 14:32
Turn off annoying macOS man page shortcuts via the command line

Turn off annoying macOS man page shortcuts via the command line

Context

macOS 10.14.4 introduced a keyboard shortcut that conflicts with one of IntelliJ IDEA’s best shortcuts. cmd-shift-a pops open a Terminal window running an apropos search on the text selection, rather than the command palette.

You can manually disable these keyboard shortcuts via System Preferences, but this script does this programmatically. I was unable to find any existing information about how to do this via the command line, so I rolled my own solution.

It took a long time to work out which defaults domain to find the plist for this. I probably worked out the pbs domain from this post.

@mrmanc
mrmanc / backat.md
Last active December 10, 2018 11:59

Back at 13:00

@mrmanc
mrmanc / folder-structure-liquid-jekyll
Created August 24, 2017 16:26
WIP to create a directory structure in a list for a Jekyll site
{% assign level = 0 %}
{% assign previous_level = 1 %}
{% assign sorted_pages = site.pages | sort:'url' %}
{% for page in sorted_pages %}
{% assign level = page.dir | split:"/" | size | minus:1 %}
{% if level > previous_level %}
<ul>
{% elsif level < previous_level %}
</ul>
{% endif %}
@mrmanc
mrmanc / gist:14bdf23b4bd0ab868e90ddb723404685
Last active July 29, 2017 01:06
macos top snapshot with cpu
top -stats pid,cpu,command -l 2 -o cpu | awk 'BEGIN{sampleNumber=0} /^PID/ {sampleNumber += 1;} {if (sampleNumber == 2) {print $0}}'
@mrmanc
mrmanc / D20BAEAA64554E0BAB202019343671CF
Created November 16, 2016 15:11
Missing exception type
Exception: Exception caught in LocalLB::urn:iControl:LocalLB/Pool::remove_member_v2()
Exception: Common::OperationFailed
primary_error_code : 16908342 (0x01020036)
secondary_error_code : 0
error_string : 01020036:3: The requested Pool Member (/Production/shippr_live_shippr-application_94d3b798f708dec8413fe75e3025d41ec72f0a90.2692_a4cce7eb-0e5f-4397-b4a6-35efa0c09311 /Production/shippr_live_shippr-application_94d3b798f708dec8413fe75e3025d41ec72f0a90.2692_172.28.139.102 8080) was not found.
at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
@mrmanc
mrmanc / 1AB6305599F94840A97F3E51A04DDF7C
Created November 16, 2016 15:08
Missing cause type in stacktrace
Exception: uk.co.autotrader.shippr.f5.F5AuthorisationException: Authorisation failed whilst trying to Remove pool members from pools 'XXXXXXXXXX, XXXXXXXXXX' using F5 user 'XXXXXXXXXX
Caused by: (401)F5 Authorization Required
at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:744)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)