Skip to content

Instantly share code, notes, and snippets.

View fortybelowzero's full-sized avatar
💭
Lurking

Rick Harrison fortybelowzero

💭
Lurking
View GitHub Profile

Some bad bots i've found hammering some of our client sites, and how i'm blocking them.

Caveats: These are all guesswork, they might be incorrect or may block more than intended, but they work for me.

NB, i have a robots.txt file specifying a crawl-rate of one request every 5 seconds, the below appear to be ignoring this. Generally i turn a blind eye to anything thats not invoking a server-generating url multiple times a second - these are people being excessive and causing undue load on relatively-modest servers.

robots.txt:

User-agent: *
Allow: /
Crawl-delay: 5
@fortybelowzero
fortybelowzero / record-server-logsin-into-a-google-chat-space.md
Last active March 3, 2023 18:50
Record server logins into a google chat space

Record server logins into a google chat space

So you'd like to get notifications in a private google chat space (room) whenever someone logs into a server as a bit of an audit trail.

First, create your a space in google chat, go into [Apps and Integrations] for the space, and create a webhook. give it a name, and copy the resulting webhook url.

Now on the server in question, create a shell script (ideally somewhere not especially obvious) with the following contents (put in the correct space-id, key and token from the webhook you've copied)

#!/bin/sh
@fortybelowzero
fortybelowzero / workflowmax-api-laravel-php.md
Last active March 25, 2021 14:39
Accessing the WorkflowMax (Xero) API with PHP and Laravel via Socialite

Accessing the Xero WorkflowMax API with PHP and Laravel

Making some notes, as i couldnt find any 100% clear explanations online (there is a more general info on accessing the XERO api via vanilla PHP here tho: https://devblog.xero.com/use-php-to-connect-with-xero-31945bccd037 )

I'm still getting my head around this, will clean up the explanation below, but this might give you a few hints on what to do in the mean time.

Composer packages required

Assuming you're already using Laravel, you can install Laravel Socialite ( https://laravel.com/docs/8.x/socialite#installation ) to do the heavy lifting for the oauth2 authentication.

Notes on creating a facebook API access token that doesnt expire for accessing page posts (via a long-lived access token)

Just collating notes on how to create a non-expiring facebook API access token for accessing posts from a facebook page as I have to create them occasionally for the a social posts website plugin i wrote (but not often enough to remember how to do it :-)

Assuming we have a facebook app created already, note down app ID and secret and head over to:

https://developers.facebook.com/tools/explorer

@fortybelowzero
fortybelowzero / laravel-mix-webpack-4-minified-gzip.md
Created July 3, 2019 12:54
Laravel Mix (Webpack 4) Minify() -> gZip

How to gzip minified css/js when using Laravel Mix (webpack 4)

These are a couple of quick notes on how we're gzipping minified css/js files in Laravel Mix (based on Webpack 4) given I couldn't find any real discussion/solution to it online. It's a bit of a hack - let me know if there's a better way! (It's also based on our setup, so you'll need to modify to meet your own needs).

(This is a work in progress - I may find a better solution in which case i'll update this gist).

The problem

@fortybelowzero
fortybelowzero / expression-engine--404-pages.md
Created June 24, 2019 11:14
ExpressionEngine 404 Pages

Managing 404 pages in Expression Engine

A couple of notes for my own reference on 404 pages when building Expression Engine websites.

While you can nominate a template to use for a 404 page, it only really covers top-level urls that just use a single segment - doesn't deal with urls 2 segments and above as it assumes it may be a segment_1 url that handles all sub-urls itself.

To get around this, we can add this to the page templates (or a shared include):

@fortybelowzero
fortybelowzero / expression-engine-EE2-migration--structure_entries.md
Last active March 15, 2019 10:10
Migrating expressionengine structure_entries to EE3/EE4/EE5

Couple of quick notes on fixing templates that used the {structure_entries} tag under EE2 when you've upgraded to EE3/EE4/EE5/+

I've inerited a number of EE2 sites that we want to upgrade to EE5, they were built using {structure_entries} but that plugin hasn't been updated since EE2 and no-longer works with newer expression engine versions...

So, generally structure_entries is used for building a sub-nav, listing page links from a branch of the nav tree. I assume this functionality didn't originally exist in Structure, hence someone created structure_entries, but (for my use-case at least) you can achieve the same functionality in Structure itself these days with a pretty simple code translation, meaning you can ditch {structure_entries} completely.

I found code like this in a template to build a sub-nav:

{exp:structure_entries depth="1" parent="/{segment_1}/{segment_2}" }
...
@fortybelowzero
fortybelowzero / expression-engine-cookbook.md
Created September 18, 2018 13:46
ExpressionEngine cookbook

Tag Parsing

If you want to embed a tag within a tag, expression-engine won't resolve the inner tag unless you add parse="inward" within the parent tag (adding this will cause a slight processing overhead so only use when needed) eg:

{exp:channel:entries parse="inward" parameter="{exp:plugin:method parameter='value'}" }
@fortybelowzero
fortybelowzero / expression-engine-construct-cookbook.md
Last active August 31, 2018 12:01
Expression Engine - Construct Plug-in Cookbook

Expression Engine - Construct Plugin

Some useful snippets for the Construct Plugin from buzzingpixel.com that aren't in the documentation

Get sibling nodes for the current page

Useful for if you want to create a list of "also in this section" links:

@fortybelowzero
fortybelowzero / css-darken-element.md
Last active May 24, 2018 23:14
Add a dark wash to an element (eg a Hero, or darken an image) with CSS

Add a dark wash to an element (eg a Hero, or darken an image) with CSS

(This example snippet is in SCSS/Sass. Note that children of the element with the darken class will be set to position: relative; z-index: 1 so that any child content sits above the dark wash)

(tested and working with Internet Explorer 11 (IE11) and above, Chrome & Firefox - should be widely supported)

Example usage