Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Making an impact

Mark McDonnell Integralist

🎯
Making an impact
View GitHub Profile
@Integralist
Integralist / Laptop Configuration. Summary.md
Last active Oct 14, 2020
[Laptop Configuration: Summary] #new #laptop #configuration #macos
View Laptop Configuration. Summary.md
  • Settings
    • Dock (Automatically hide and show the Dock)
    • Keyboard (Key Repeat = Fast, Delay Until Repeat = Short)
    • Accessibility > Zoom (Use keyboard shortcuts to zoom)
    • Date & Time > Clock (Show date + Display the time with seconds)
    • Mission Control (disable "Automatically rearrange Spaces based on most recent use")
  • https://www.expressvpn.com/setup#mac
  • https://www.mozilla.org/en-GB/firefox/new/
    • Preferences
      • General > Startup (Restore previous session + Warn you when quitting the browser)
@Integralist
Integralist / CRDT. conflict-free replicated data type.md
Created Oct 2, 2020
[CRDT: conflict-free replicated data type] #crdt #distributed
View CRDT. conflict-free replicated data type.md

Operations on CRDTs need to adhere to the following rules:

  • Associativity (a+(b+c)=(a+b)+c), so that grouping doesn't matter.
  • Commutativity (a+b=b+a), so that order of application doesn't matter.
  • Idempotence (a+a=a), so that duplication doesn't matter.

Data types as well as operations have to be specifically crafted to meet these rules. CRDTs have known implementations for counters, registers, sets, graphs, and others.

@Integralist
Integralist / Install Python package directly for the interpreter Vim is using.md
Created Oct 2, 2020
[Install Python package directly for the interpreter Vim is using] #vim #python
View Install Python package directly for the interpreter Vim is using.md

Sometimes Vim's Python binary can't find a package you've installed.

  • in vim
    :py3 import sys; print(sys.path)

  • navigate to that location and find the python binary, in my case:
    cd /usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/bin

  • install isort using this binary
    ./python3.8 -m pip install isort

@Integralist
Integralist / curl to json.bash
Created Oct 2, 2020
[Curl to JSON] #curl #bash #shell #json
View curl to json.bash
# https://daniel.haxx.se/blog/2020/03/17/curl-write-out-json/
#
curl --write-out '%{json}' https://example.com -svo /dev/null | jq
{
"url_effective": "https://example.com/",
"method": "GET",
"http_code": 200,
"response_code": 200,
"http_connect": 0,
@Integralist
Integralist / tornado logging when request has completed.py
Last active Sep 28, 2020
[Python tornado logging when request has completed] #python #python3 #tornado #logging #logs #server #http
View tornado logging when request has completed.py
"""
That Application.log_request approach uses very explicit naming,
and yet the tornado docs for RequestHandler.on_finish says...
> Override this method to perform cleanup, logging, etc.
So theres two ways to essentially do the same thing 🤔
My understanding for the difference would be log_request is useful for
generic logging behaviour, while on_finish could be customized per
@Integralist
Integralist / Asyncio built-in Socket Server.py
Created Sep 25, 2020
[Asyncio built-in Socket Server] #python #python3 #asyncio #server #socket #web #http
View Asyncio built-in Socket Server.py
import asyncio
async def handle_request(reader, writer):
writer.write("hello world".encode()) # needs to be bytes not string
writer.close()
async def main():
srv = await asyncio.start_server(handle_request, '127.0.0.1', 8081)
@Integralist
Integralist / 0. README.md
Last active Sep 25, 2020
[Python Context and ContextVars] #python #python3 #context #contextvars
View 0. README.md

Context variables are variables that can have different values depending on their context. They are similar to Thread-Local Storage in which each execution thread may have a different value for a variable. However, with context variables, there may be several contexts in one execution thread. The main use case for context variables is keeping track of variables in concurrent asynchronous tasks. -- https://realpython.com/python37-new-features/#context-variables

"""Example copied verbatim from Real Python."""

import contextvars

name = contextvars.ContextVar("name")
contexts = list()
@Integralist
Integralist / Golang Named Return Zero Value.go
Created Sep 23, 2020
[Golang Named Return Zero Value] #go #golang #zero #named #return
View Golang Named Return Zero Value.go
package main
import (
"fmt"
)
func GetString(key string) (val string) {
// 'named' return value are initialized to their zero value
// meaning we can proxy the zero value through to a nested function
//
@Integralist
Integralist / YouTube 'Watch' Channels.md
Created Sep 21, 2020
[YouTube 'Watch' Channels] #youtube #watches
View YouTube 'Watch' Channels.md
  • Bark and Jack: great down to earth personality, cool watches, very easy to listen to.
  • WatchFinder: awesome/expensive unique watches and their backgrounds (exquisite close-up footage)
  • Theo and Harris: high end quality pieces reviewed/discussed
  • The Urban Gentry: can waffle on, but he does great historical deep dives
  • Watch Advisor: I just enjoy listening to him talk because of his accent lol
  • Long Island Watches: cheaper end watches, interesting selections come up
  • Jenni: female watch reviewer (great quality footage)
  • WatchBox Reviews: short reviews
  • [WatchBox Studi
@Integralist
Integralist / Go Module Versioning.md
Last active Sep 22, 2020
[Go Module Versioning] #go #golang #modules #versioning #semver
View Go Module Versioning.md

Reference: https://blog.golang.org/v2-go-modules

You have a dependency you want to use, like github.com/integralist/delete-just-testing.

// delete-just-testing/foo/foo.go 
//
package foo

import "fmt"
You can’t perform that action at this time.