Skip to content

Instantly share code, notes, and snippets.

View osule's full-sized avatar
✝️
ecce homo

Oluwafemi Sule osule

✝️
ecce homo
View GitHub Profile
@osule
osule / list_bucket.sh
Created June 3, 2022 03:08
List S3 buckets in an account with Terraform
#!/bin/bash
# List the S3 buckets in an account
aws s3api list-buckets | jq '[.Buckets[]] | map({ (.Name): .Name }) | add'
@osule
osule / lemma.py
Last active May 17, 2022 06:16
Lemmatizing words in a sentence based on part of speech.
import nltk
import pandas as pd
from nltk.tokenize import word_tokenize
from collections import defaultdict
nltk.download('wordnet')
nltk.download('punkt')
nltk.download('averaged_perceptron_tagger')
nltk.download('universal_tagset')
@osule
osule / airflow-debug-container.md
Created July 1, 2021 11:08
Airflow container task instance profiling

Install procps

docker exec -u 0 -ti <container-id> bash -c "apt-get update && apt-get install -y procps"

docker exec -u 0 -ti cbe1c06b96c7 bash -c "apt-get update && apt-get install -y procps"

Install py-spy

docker exec -ti <container-id> pip install py-spy
@osule
osule / redis-docker.md
Last active September 21, 2020 07:49
Experimenting with redis python client

I enrolled in the just concluded Redislabs course.

I didn't want to install redis locally because of storage contraints on my computer for the assignments and exams, and set to doing it all using Docker containers.

I document the steps for my setup for the courseware. The course also provides this image for the courseware on Docker Hub.

Set up Redis server

Start up server using host network mode.

@osule
osule / occupancy_status.sql
Last active August 10, 2020 12:48
Query history of vehicle occupation
WITH -- Get information for shift in given schedules
shift_info AS (
SELECT
DISTINCT s.id AS shift_id
,s.scheduled_at
,s.vehicle_license_plate AS license_plate
,s.organization_id
,s.operating_period_id
,s.region_id
FROM
@osule
osule / process_sequence_in_chunks.py
Created May 28, 2020 09:35
Apply function to sequence in chunks
#!/bin/env python
import time
from itertools import islice
def process_sequence_in_chunks(fn, seq, chunk_size=100):
"""
Apply function to sequence in chunks.
Params
------
@osule
osule / amazon_linux_ami.md
Last active February 11, 2020 11:08
Older Amazon Linux AMI

Amazon announced EOL for Amazon Linux AMI.

https://aws.amazon.com/de/amazon-linux-ami/

It's important to do an audit of all instance reservations in your platform and migrate away from these images before the announce date.

The steps below should provide a list of instance reservations still using Amazon Linux AMI

@osule
osule / golang-tips.md
Created February 3, 2020 14:18
Golang tips

Remove debugging information and symbol table

Reason: This reduces binary size

go build -ldflags "-w -s"
@osule
osule / scheduler_job.md
Last active April 28, 2020 15:55
What Airflow v1.0.3 Scheduler Job is doing

It sets taskinstance state in the following transition

State.SCHEDULED -> State.QUEUED

Task dependencies are not checked until task is running :(

There is no direct way to change delay scheduling of a TaskInstance using a custom dependency that subclasses BaseTiDep unless dep_context.QUEUED_DEPS is patched during run time.

@osule
osule / setup-errors.md
Last active October 16, 2019 16:47
Errors encountered in solution setup
  1. First, I ran setup target defined in Makefile as per documentation

    make setup
    

Error logs

 Error response from daemon: OCI runtime create failed: container_linux.go:345: starting container process caused "process_linux.go:424: container init caused \"rootfs_linux.go:58: mounting \\\"/home/beebox/d2d-data-challenge-master/app/init_db.py\\\" to rootfs \\\"/var/lib/docker/overlay2/701b781612fb56ef3bc68cffefa7d7deacd10c9e0957cdd667f00ccc69f88eb4/merged\\\" at \\\"/var/lib/docker/overlay2/701b781612fb56ef3bc68cffefa7d7deacd10c9e0957cdd667f00ccc69f88eb4/merged/data/app/init_db.py\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
make: *** [Makefile:16: initdb] Error 1