Skip to content

Instantly share code, notes, and snippets.

View mekicha's full-sized avatar
🎯
Focusing

Emeka Icha mekicha

🎯
Focusing
  • Sennder GmbH
  • Germany
View GitHub Profile
@mekicha
mekicha / Readme.md
Last active November 24, 2021 19:38
PostgreSQL specific Django Percentile aggregation function

Inspired by this gist

The class extends to calculate any percentile (not just median).

Example usage:

Percentile('some_field', percentile=0.5) # calculates median for the field
Percentile('some_field', percentile=0.9) # calculates the 90th percentile

For completeness, I can calculate the median age of some Student model like so:

"""
1. Store the image and create an instance of ImagefileProcessHistory with status NOT_STARTED
ImageFileProcessHistory
- local_path
- file_name
- status # enum: NOT_STARTED, STARTED, SUCCEEDED, FAILED
- bytes_processed
- bytes_total
"""
@mekicha
mekicha / index_profile.md
Last active October 1, 2018 14:48
Profiling list indexing in a python loop using the timeit module

There are a couple of ways to index through a list in a python loop.

  1. Using a while loop
arr = [i*2 for i in range(1001)]
i = 0
while i < len(arr):
  print(arr[i])
  i += 1
package main
import (
"golang.org/x/tour/wc"
"strings"
)
func WordCount(s string) map[string]int {
list := strings.Fields(s)
m := make(map[string]int)
@mekicha
mekicha / great-software-engineers.md
Last active August 10, 2018 17:24
In your opinion, what attributes best describe great software engineers.

In my opinion, great software engineers are not afraid.

They are not afraid of technical(or any kind of) challenges, as they derive joy in overcoming them.

They are not afraid to admit their mistakes(or that they don't know something), as they see it as an opportunity to learn and grow.

They are not afraid to reach out or communicate with others, because they know that no man is an island.

Also, great software engineers are caring.

def qsort(get_list):
if len(get_list) < 2:
return get_list
pivot = get_list.pop()
left = list(filter(lambda x: x <= pivot, get_list))
right = list(filter(lambda x: x > pivot, get_list))
return qsort(left) + [pivot] + qsort(right)
@mekicha
mekicha / environs.md
Created July 11, 2018 12:37
Python libraries for working with environment variables