Skip to content

Instantly share code, notes, and snippets.

View chumaumenze's full-sized avatar
🏠
Working from home

Chuma Umenze chumaumenze

🏠
Working from home
View GitHub Profile
@chumaumenze
chumaumenze / context.py
Created July 10, 2018 08:13 — forked from bradmontgomery/context.py
simple examples of a context manager in python
"""
Simple example of building your own context manager.
Resources:
- http://preshing.com/20110920/the-python-with-statement-by-example/
- https://docs.python.org/3/library/contextlib.html
- PEP 343 -- the "with" statement: https://www.python.org/dev/peps/pep-0343/
"""
@chumaumenze
chumaumenze / jinjalink_loader.py
Created July 17, 2018 18:34 — forked from Suor/jinjalink_loader.py
Jinja2 template loader for django
@chumaumenze
chumaumenze / knight-moves.js
Created January 18, 2019 08:38
Toptal Codility Problem: Can Knight reach square?
'use strict';
function getNextPositions(start) {
var moves = [
{ x: -2, y: -1 },
{ x: -2, y: +1 },
{ x: -1, y: -2 },
{ x: -1, y: +2 },
{ x: +1, y: -2 },
{ x: +1, y: +2 },
@chumaumenze
chumaumenze / find_replace.py
Last active August 15, 2019 00:56
Find and Replace with Regex
"""
Find and Replace with Regex
Requires Python 3.6+
"""
import re
TEST_STRING = "Hello <name>! Welcome to <place_name>. The date is <date2today>." \
"<place_name> is a great place."
@chumaumenze
chumaumenze / Dockerfile
Created August 13, 2019 00:51
Using Pipenv in Docker
FROM python
ENV RUNNING_MODE production
WORKDIR /app
COPY Pipfile Pipfile.lock /app/
RUN pip install pipenv && \
pipenv install --system --deploy --ignore-pipfile
@chumaumenze
chumaumenze / linkedin_interview_prep_downloader.py
Created March 27, 2020 01:13
Another midnight scraper tool
import asyncio
import os
from asgiref.sync import sync_to_async
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
class Crawler(object):
@chumaumenze
chumaumenze / gunicorn_config.py
Last active May 21, 2020 15:34
Basic Gunicorn/Supervisor/Nginx config for deploying Python apps.
import multiprocessing
bind = '0.0.0.0:8000'
workers = multiprocessing.cpu_count()
worker_class = 'gevent'
accesslog = '/var/log/progam_name/gunicorn/access.log'
errorlog = '/var/log/progam_name/gunicorn/error.log'
loglevel = 'debug'
access_log_format = '[%(h)15s] (%(s)s) [%(D)8sms] %(r)s | %(b)sb'
proc_name = 'progam_name_gunicorn'
@chumaumenze
chumaumenze / rest.py
Created May 29, 2020 12:40 — forked from tliron/rest.py
Simple and functional REST server for Python (2.7) using no dependencies beyond the Python standard library.
#!/usr/bin/env python
'''
Simple and functional REST server for Python (2.7) using no dependencies beyond the Python standard library.
Features:
* Map URI patterns using regular expressions
* Map any/all the HTTP VERBS (GET, PUT, DELETE, POST)
* All responses and payloads are converted to/from JSON for you
@chumaumenze
chumaumenze / tut.md
Created June 7, 2020 23:37 — forked from rain1024/tut.md
Install pdflatex ubuntu

PdfLatex is a tool that converts Latex sources into PDF. This is specifically very important for researchers, as they use it to publish their findings. It could be installed very easily using Linux terminal, though this seems an annoying task on Windows. Installation commands are given below.

  • Install the TexLive base
sudo apt-get install texlive-latex-base
  • Also install the recommended and extra fonts to avoid running into the error [1], when trying to use pdflatex on latex files with more fonts.
@chumaumenze
chumaumenze / .vimrc
Created June 9, 2020 15:13 — forked from miguelgrinberg/.vimrc
My .vimrc configuration for working in Python with vim
" plugins
let need_to_install_plugins = 0
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
"autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
let need_to_install_plugins = 1
endif
call plug#begin()