Skip to content

Instantly share code, notes, and snippets.

Excerpt from the README.rst with some useful pointers:

Getting started

If you already know about Bayesian statistics:

@markgreene74
markgreene74 / update-all-the-packages-nixos.md
Last active January 20, 2024 12:36
NixOS - update all the packages
@markgreene74
markgreene74 / find-files.md
Created June 24, 2023 12:27
Find the file modified after the last rebase

My solutions to rustlings are kept in a branch in my fork of the repo (markgreene74/rustlings:solutions), and also in a separate repo rustlings_solutions. After a rebase of the branch to main some solutions need to be modified and the changes pushed.

This simple bash script can be used to find the file modified so that thay can also be updated in rustlings_solutions.

cd github

for src_file in $(find rustlings/exercises -type f -name "*.rs"); do \
  dst_file=$(echo ${src_file} | sed 's/rustlings/rustlings_solutions/')
 echo "Comparing ${src_file} and ${dst_file}";
@markgreene74
markgreene74 / random-notes-2023-02-19.md
Created February 19, 2023 15:10
random-notes-2023-02-19
>>> l = list(range(10))
>>> def f(l,d=False):
...  for i in l:
...   if d:
...    l.remove(i)
...   else:
...    yield i
... 
>>> list(f(l))
@markgreene74
markgreene74 / git-intro.md
Last active April 24, 2021 10:40
git introduction for UoL MSc Data Science

what is git

What is git and why is it so widely used?

git is a very powerful version control system, but it's not the only one. You may have heard of mercurial, subversion, CVS ...

In simple and practical terms, it solves two very real problems:

  • how can I keep track of the codebase I am working on
  • how can I collaborate with other programmers/engineers/data scientist making changes on the same piece of code
@markgreene74
markgreene74 / change_branch_name
Created February 15, 2021 23:22
Change the branch name in the local environment
# https://github.com/<USERNAME>/<REPOSITORY>/settings/branches
git branch -m master <BRANCH>
git fetch origin
git branch -u origin/<BRANCH> <BRANCH>
# example, change from master to main
git branch -m master main
git fetch origin
@markgreene74
markgreene74 / pipenv_workflow
Last active September 15, 2021 22:01
pipenv workflow
# https://github.com/pypa/pipenv
pip install --upgrade pip --user
pip install --upgrade pipenv --user
# https://pipenv.pypa.io/en/latest/install/#installing-packages-for-your-project
cd myproject
# install packages
pipenv install requests

A simple Python in docker workflow

Build the container

Create the dockerfile

$ cat ~/docker/Dockerfile 
FROM python:3
RUN apt-get update && apt-get install -y vim
kubectl cluster-info
kubectl config view
kubectl describe nodes
kubectl describe pods --all-namespaces
kubectl get services --all-namespaces
kubectl api-resources -o wide
@markgreene74
markgreene74 / python-mock-patch.md
Created November 21, 2019 22:44
simple mock.patch
(env) [lon1-01 tmp]$ cat something.py
def afunction(arg=None):
    counter = 0
    try:
        arg += 1
    except:
        # do nothing, increase the counter
        counter += 1
    return counter