Skip to content

Instantly share code, notes, and snippets.

🎯
Making impact

Mark McDonnell Integralist

🎯
Making impact
Block or report user

Report or block Integralist

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Integralist
Integralist / 1. things tried.md
Last active Nov 14, 2019
[Python Tornado Graceful Shutdown] #python #python3 #tornado #graceful #shutdown #signals #sigterm #sigint
View 1. things tried.md

Working code (Python 3.7+)...

def sig_handler(server, sig, frame):
    io_loop = IOLoop.current()
    
    def stop_loop(deadline):
        now = time.time()
        if now < deadline and len(asyncio.all_tasks()) > 0:
            logging.info('waiting for next event loop tick')
@Integralist
Integralist / Golang Fastly Purge by URL and by Key.go
Created Nov 6, 2019
[Golang Fastly Purge by URL and by Key] #fastly #go #golang #purge #cdn #cache
View Golang Fastly Purge by URL and by Key.go
// purgeByKey purges the Fastly edge cache by Surrogate-Key
func purgeByKey(key, testCase string, config *settings.Config) {
serviceID := config.FastlyIDProd
if config.Environment == "stage" {
serviceID = config.FastlyIDStage
}
host := "https://api.fastly.com"
path := fmt.Sprintf("/service/%s/purge/%s", serviceID, key)
purgeURL := fmt.Sprintf("%s%s", host, path)
@Integralist
Integralist / Golang convert code into Assembly.bash
Created Nov 6, 2019
[Golang convert code into Assembly] #assembly #go #golang
@Integralist
Integralist / Security. Zero Trust Platform.md
Created Nov 6, 2019
[Security: Zero Trust Platform] #security #zerotrust #zero #trust #platform
View Security. Zero Trust Platform.md

A zero trust platform means that (in theory), we'd be able to run malicious code inside our platform with no risk – the code wouldn't be able to interact with anything dangerous without being granted special access by the platform's own security/infrastructure team.

The idea is that we don't want to trust just anything simply because it's inside our platform. Instead, we want individual services to be trusted based on a short and deliberate list of which other services they're allowed to interact with. This makes an attack substantially more difficult.

@Integralist
Integralist / Golang HTTP Web Server Parallel Tee Goroutine per Request.go
Created Nov 4, 2019
[Golang HTTP Web Server Parallel Tee Goroutine per Request] #go #golang #tee #parallel #http #web #server #request #pool #concurrency
View Golang HTTP Web Server Parallel Tee Goroutine per Request.go
package main
import (
"encoding/json"
"io/ioutil"
"net/http"
)
var largePool chan func()
var smallPool chan func()
@Integralist
Integralist / Fakes vs Stubs vs Mocks.md
Created Oct 24, 2019
[Fakes vs Stubs vs Mocks] #fakes #stubs #mocks #testing
View Fakes vs Stubs vs Mocks.md

Fakes

Fake objects actually have working implementations, but usually take some shortcut which makes them not suitable for production (e.g. a working version of a datastore that has a get and set method but writes to local disk rather than actually writing to a database).

Stubs

Stubs provide canned answers to calls made during the test, usually not responding at all to anything outside what's programmed in for the test. Stubs may also record information about calls, such as an email gateway stub that remembers the messages it 'sent', or maybe only how many messages it 'sent'.

Mocks

@Integralist
Integralist / bash string wildcard glob contains example.sh
Last active Oct 16, 2019
[Bash string wildcard glob conains example] #bash #wildcard #glob #contains
View bash string wildcard glob contains example.sh
#!/bin/bash
# our CDN was serving stale content for a request that shouldn't be
# so we wrote a quick script to verify the behaviour wasn't happening
# more often than it should.
function get {
local id=$1
local url="https://www.example.com/?id=$id"
@Integralist
Integralist / Bash Hash Bang.md
Last active Oct 16, 2019
[Bash Hash Bang] #bash #hash #bang
View Bash Hash Bang.md

A typical bash script will identify where its interpreter can be found...

#!/bin/bash

But this doesn't always work because bash might be installed in a different location.

For example, macOS has an old version of bash (or in more modern releases it has swapped bash completely for zsh) and so a user might manually install an updated version of bash which will go into a different directory...

@Integralist
Integralist / Fastly Clustering and Shielding Example.md
Created Oct 15, 2019
[Fastly Clustering and Shielding Example] #fastly #varnish #vcl #clustering #shielding #cluster #shield
View Fastly Clustering and Shielding Example.md
@Integralist
Integralist / Develop Streamlink Locally.bash
Last active Oct 8, 2019
[Develop Streamlink Locally] #streamlink #video #download #stream
View Develop Streamlink Locally.bash
You can’t perform that action at this time.