Skip to content

Instantly share code, notes, and snippets.

View nosahama's full-sized avatar

Emmanuel Evbuomwan nosahama

View GitHub Profile
@nosahama
nosahama / forwarder.py
Created March 4, 2024 20:51 — forked from LiveOverflow/forwarder.py
TCP Forwarder
import socket
import select
from logzero import logger
# python forwarder.py localhost:1337 ipinfo.io:80
# curl -v http://localhost.com:1337 -H "Host: ipinfo.io"
# video: https://www.youtube.com/watch?v=32KKwgF67Ho
class Forwarder:
@nosahama
nosahama / all_pdf_dl.py
Created March 16, 2023 18:29 — forked from hibetterheyj/all_pdf_dl.py
Download all pdf files from a website
import os
import requests
from urllib.parse import urljoin
from bs4 import BeautifulSoup
import argparse
#%% Example
# one pdf
# python all_pdf_dl.py -l https://memento.epfl.ch/academic-calendar/ --save-here
# many pdfs
@nosahama
nosahama / docker-compose.yml
Created July 12, 2022 09:30 — forked from gschmutz/docker-compose.yml
Docker Compose with Kafka Single Broker, Connect, Schema-Registry, REST Proxy, Kafka Manager
version: '2'
services:
zookeeper:
image: confluentinc/cp-zookeeper:3.3.0
hostname: zookeeper
ports:
- "2181:2181"
environment:
ZOOKEEPER_CLIENT_PORT: 2181
@nosahama
nosahama / Base64.sol
Created May 31, 2022 22:57 — forked from ryancharris/Base64.sol
Solidity Base64 utilities
pragma solidity >=0.8.0 <0.9.0;
// SPDX-License-Identifier: MIT
/// [MIT License]
/// @title Base64
/// @notice Provides a function for encoding some bytes in base64
/// @author Brecht Devos <brecht@loopring.org>
library Base64 {
bytes internal constant TABLE =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
@nosahama
nosahama / templatetags.py
Created June 11, 2019 11:31 — forked from benbacardi/templatetags.py
Django query_transform templatetag
from django import template
register = template.Library()
@register.simple_tag(takes_context=True)
def query_transform(context, **kwargs):
'''
Returns the URL-encoded querystring for the current page,
updating the params with the key/value pairs passed to the tag.
@nosahama
nosahama / Dockerfile
Created May 16, 2019 21:48 — forked from wodCZ/Dockerfile
django, postgres, redis, celery, nginx, uwsgi docker setup
FROM python:latest
ADD requirements.txt /requirements.txt
RUN python3.6 -m venv /venv \
&& /venv/bin/pip install -U pip \
&& LIBRARY_PATH=/lib:/usr/lib /bin/sh -c "/venv/bin/pip install --no-cache-dir -r /requirements.txt"
ENV PYTHONUNBUFFERED 1
# Copy your application code to the container (make sure you create a .dockerignore file if any large files or directories should be excluded)
RUN mkdir /code/
@nosahama
nosahama / cooccurrence.py
Last active March 1, 2018 18:13
Cooccurrence Question
## This is the text editor interface.
## Anything you type or change here will be seen by the other person in real time.
import itertools
from collections import defaultdict
class Cooccurrence:
def __init__(self):
self.__counts = defaultdict(int)
def append(self, line):
@nosahama
nosahama / gist:1a2177748d59aa0097a59b960fccb444
Created May 25, 2017 20:41 — forked from jason-w/gist:4969476
Helper functions that converts a MongoEngine Document to a Python Dict so it can be easily converted to JSON.
class Person (db.Document):
name = db.StringField(required=True)
created_date = db.ComplexDateTimeField(default=datetime.datetime.utcnow(), required=True)
def to_dict(self):
return helper.mongo_to_dict(self,[])
#helper.py
def mongo_to_dict(obj, exclude_fields):
@nosahama
nosahama / README.rst
Created February 14, 2017 22:54 — forked from dupuy/README.rst
Common markup for Markdown and reStructuredText

Markdown and reStructuredText

GitHub supports several lightweight markup languages for documentation; the most popular ones (generally, not just at GitHub) are Markdown and reStructuredText. Markdown is sometimes considered easier to use, and is often preferred when the purpose is simply to generate HTML. On the other hand, reStructuredText is more extensible and powerful, with native support (not just embedded HTML) for tables, as well as things like automatic generation of tables of contents.