Skip to content

Instantly share code, notes, and snippets.

Avatar
🚴‍♂️
Making my way downtown

Brian Muhia poppingtonic

🚴‍♂️
Making my way downtown
View GitHub Profile
View raw_qs_to_qs.py
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():
View kenya-countylevel-teenage-pregnancy-statistics.csv
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
View pbs.py
#!/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.
#
View silver map url
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 Aug 1, 2019
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
View passphrase_gen.py
#!/usr/bin/env python
# requires python 3.6 and requests
import os
import re
import secrets
import requests
wordlist_file = 'diceware.wordlist.asc'
View bot_web_server.py
# 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 Nov 2, 2018
convert a PDF to TIFF using gs, convert from TIFF to txt using tesseract
View extract.sh
# $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
View gist:e4ebe6e68d4ba8ae7e76ac8a4a9d629d
https://docs.google.com/presentation/d/1nApyvRZSAdvomrgaWNRuP90UVAlp6OufnU7Vpo0a1Ck/edit?usp=sharing
View pretrain_lm.py
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)
View journalctl.log
Mar 22 09:13:30 metabox systemd-udevd[342]: seq 2902 queued, 'change' 'power_supply'
Mar 22 09:13:30 metabox systemd-udevd[342]: seq 2902 forked new worker [4117]
Mar 22 09:13:30 metabox systemd-udevd[4117]: seq 2902 running
Mar 22 09:13:30 metabox systemd-udevd[4117]: RUN '/usr/local/bin/aclidswitch AC' /usr/lib/udev/rules.d/98-aclidswitch.rules:5
Mar 22 09:13:30 metabox systemd-udevd[4117]: RUN 'lmt-udev auto' /usr/lib/udev/rules.d/99-laptop-mode.rules:1
Mar 22 09:13:30 metabox [4118]: starting '/usr/local/bin/aclidswitch AC'
Mar 22 09:13:30 metabox systemd-udevd[4117]: '/usr/local/bin/aclidswitch AC'(err) '/usr/bin/xbacklight: -set requires an argument'
Mar 22 09:13:30 metabox systemd-udevd[4117]: '/usr/local/bin/aclidswitch AC'(err) 'usage: /usr/bin/xbacklight [options]'
Mar 22 09:13:30 metabox systemd-udevd[4117]: '/usr/local/bin/aclidswitch AC'(err) ' where options are:'
Mar 22 09:13:30 metabox systemd-udevd[4117]: '/usr/local/bin/aclidswitch AC'(err) ' -display <display> or -d <display>'