Skip to content

Instantly share code, notes, and snippets.

View poppingtonic's full-sized avatar
💭
I may be slow to respond.

Brian Muhia poppingtonic

💭
I may be slow to respond.
View GitHub Profile
@poppingtonic
poppingtonic / gist:197124f557c2872c0abac43453790c78
Created October 7, 2022 11:44
rsync multiple files from a server in parallel, reading from a filelist
cat dllist | parallel -j 8 rsync -aHvxz --relative user@host.domain:/path/to/files/./{} .
import operator
from functools import reduce
results = qs.model.objects.raw(sql, sql_params)
obj_ranks = (obj.id for obj in results)
return_objs = []
# inject rank
for obj_id, objs.items():
SNO Organisation unit/Data Adolescents (10-14 years) presenting with pregnancy Adolescents (15-19 years) presenting with pregnancy Total
1 Nairobi County 2028 9706 11734
2 Kakamega County 217 6469 6686
3 Homa Bay County 451 5481 5932
4 Nakuru County 456 5427 5883
5 Kajiado County 824 5010 5834
6 Narok County 310 5275 5585
7 Bungoma County 151 5426 5577
8 Meru County 209 5047 5256
9 West Pokot County 290 4722 5012
@poppingtonic
poppingtonic / pbs.py
Created November 28, 2019 16:44
COCOHub Gist
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This file is part of PyBOSSA.
#
# PyBOSSA is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
https://maps.googleapis.com/maps/api/staticmap?key=YOUR_API_KEY&center=47.65,-122.35000000000002&zoom=12&format=png&maptype=roadmap&style=element:geometry%7Ccolor:0xf5f5f5&style=element:labels.icon%7Cvisibility:off&style=element:labels.text.fill%7Ccolor:0x616161&style=element:labels.text.stroke%7Ccolor:0xf5f5f5&style=feature:administrative.land_parcel%7Celement:labels%7Cvisibility:off&style=feature:administrative.land_parcel%7Celement:labels.text.fill%7Ccolor:0xbdbdbd&style=feature:poi%7Celement:geometry%7Ccolor:0xeeeeee&style=feature:poi%7Celement:labels.text%7Cvisibility:off&style=feature:poi%7Celement:labels.text.fill%7Ccolor:0x757575&style=feature:poi.park%7Celement:geometry%7Ccolor:0xe5e5e5&style=feature:poi.park%7Celement:labels.text.fill%7Ccolor:0x9e9e9e&style=feature:road%7Celement:geometry%7Ccolor:0xffffff&style=feature:road.arterial%7Celement:labels.text.fill%7Ccolor:0x757575&style=feature:road.highway%7Celement:geometry%7Ccolor:0xdadada&style=feature:road.highway%7Celement:labels.text.fill%7Ccolor:
@poppingtonic
poppingtonic / passphrase_gen.py
Last active August 1, 2019 19:45
This script generates a list of 9 words as a "strong-enough" passphrase generator. My attempt, based on python 3.6's secrets module, to justifiably disobey the Diceware recommendation against computer-based RNGs: http://world.std.com/~reinhold/diceware.html
#!/usr/bin/env python
# requires python 3.6 and requests
import os
import re
import secrets
import requests
wordlist_file = 'diceware.wordlist.asc'
@poppingtonic
poppingtonic / bot_web_server.py
Created November 21, 2018 13:18
bot web server
# import the necessary packages
import ast
import logging
from PIL import Image
import numpy as np
import settings
import helpers
from classes import disease_classes
from quart import Quart, request, jsonify
import redis
@poppingtonic
poppingtonic / extract.sh
Last active November 2, 2018 22:57
convert a PDF to TIFF using gs, convert from TIFF to txt using tesseract
# $1 is the first argument
# remove result.txt
#rm output/result.txt
fname=`echo "$1" | awk -F "/" '{print $(NF)}'`
# convert the pdf to a group of tiffs
if [ ! -e extracted_tz_parliament/$fname.txt ];
then
@poppingtonic
poppingtonic / gist:e4ebe6e68d4ba8ae7e76ac8a4a9d629d
Created October 26, 2018 00:54
PyConKE 2018 Convnet Talk
https://docs.google.com/presentation/d/1nApyvRZSAdvomrgaWNRuP90UVAlp6OufnU7Vpo0a1Ck/edit?usp=sharing
import pandas as pd
from fastai.text import *
import html
LANG='fr'
def preprocess_wiki_lm(path):
DATA = Path(path)
trn_df = pd.read_csv(DATA/'train.csv', header=None)
val_df = pd.read_csv(DATA/'valid.csv', header=None)