Skip to content

Instantly share code, notes, and snippets.

Making an impact

Mark McDonnell Integralist

Making an impact
View GitHub Profile
simonw /
Last active Oct 26, 2020
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using and

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
mivade /
Last active Oct 7, 2020
Tornado server-sent events
"""Demonstration of server-sent events with Tornado. To see the
stream, you can either point your browser to ``http://localhost:8080``
or use ``curl`` like so::
$ curl http://localhost:8080/events
import signal
from tornado import web, gen
Integralist / 1. Setup.bash
Last active Nov 8, 2019
DynamoDB (using Spurious)
View 1. Setup.bash
boot2docker init
boot2docker up
spurious-server start
spurious init
spurious start

Install the netcat nc command with Homebrew (otherwise Mac OS X version is really old and the interface is different):

brew install netcat

Use netcat to listen for incoming TCP connections on port 3000:

nc -l -p 3000
View Rack
use Rack::Lint # gives more descriptive error messages when responses aren't valid

class LogIt
  def initialize(app)
    @app = app
  def call(env)
    status, headers, body  = { |chunk| p "LogIt: #{chunk}" }
Integralist / 1. Designing Systems and
Last active Jun 7, 2020
Designing Systems and Applications
View 1. Designing Systems and

Designing Systems and Applications

This is a short document of tips and notes I've accumulated while learning more about designing distributed systems and building concurrent applications. It is by no means definitive and merely scratches the surface of what is needed to be considered when designing an architecture expected to handle large scale traffic.

Distributed Systems

Scale out, not up

There reaches a point in your application's design where by merely throwing more hardware at the problem (i.e. "scaling up") will fail to resolve the scalability issues you're encountering.

View testing a ruby

Version 1

# Long way of doing things (new files need to be added to staging area *before* building the gem)
git add . && gem build my_gem.gemspec && gem install my_gem-0.0.0.gem

Version 2

Integralist / 1. [CURRENT] Brew
Last active Jun 15, 2020
[Brew switch to custom versions of software] #homebrew #brew #install #versions #switch
View 1. [CURRENT] Brew

If you wish to switch your python command to use a different Python interpreter (and it's a Python version you previously had installed using Homebrew):

brew info python           # To see what you have previously installed
brew switch python 3.x.x_x # Ex. 3.6.5_1

NOTE: this might not be wise to do as you might have other software that relies on the Python interpreter you have currently (i.e. before the switch).

Otherwise to install multiple Python versions using Homebrew (instead of something like pyenv)...

View Software
  • Simplicity !== Easy
  • Easy is short term and can sometimes even introduce complexity
  • Simplicity allows for easy while avoiding complexity
  • Complect == tangling/braiding together
  • Complexity is the result of something that has been complected
  • Untangle complected code (e.g. decoupling of components)
  • Do not chain calls (i.e. Law of Demeter)
  • Consider Channels as form of asynchronous flow control
  • Ask yourself all the time: "can this thing be moved? does it have well defined boundaries?"
Integralist / ruby string formatting.rb
Created Aug 22, 2014
Ruby string formatting functionality (like PHP's sprintf)
View ruby string formatting.rb
"foo-%s-baz" % "bar" # => "foo-bar-baz"
"foo-%s-baz" % 123 # => "foo-123-baz"
You can’t perform that action at this time.