Skip to content

Instantly share code, notes, and snippets.

View espoirMur's full-sized avatar
🎯
Focusing

Espoir Murhabazi espoirMur

🎯
Focusing
View GitHub Profile
@MrEliptik
MrEliptik / text_preprocessing.py
Created January 14, 2019 12:01
A python script to preprocess text (remove URL, lowercase, tokenize, etc..)
import re, string, unicodedata
import nltk
import contractions
import inflect
from nltk import word_tokenize, sent_tokenize
from nltk.corpus import stopwords
from nltk.stem import LancasterStemmer, WordNetLemmatizer
def replace_contractions(text):
"""Replace contractions in string of text"""
@Bergvca
Bergvca / unnittestexample.py
Last active December 22, 2022 20:54
Some unnittest + Mock examples in Python. Includes examples on how to mock a entire class (ZipFile), mock an Iterator object and how to use side_effect properly
import unittest
import os
from zipfile import ZipFile
from mock import MagicMock, patch, Mock, mock_open
# The functions that are tested:
def function_to_test_zipfile(example_arg):
with ZipFile(example_arg, 'r') as zip_in:
for input_file in zip_in.infolist():
@Brachamul
Brachamul / command
Created December 26, 2016 11:40
Set an existing user to superuser using Django shell
python manage.py shell

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

@onjin
onjin / docker-compose.yml
Created September 5, 2016 09:17
example docker compose for postgresql with db init script
postgres:
image: postgres:9.4
volumes:
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
@PurpleBooth
PurpleBooth / README-Template.md
Last active April 18, 2024 00:56
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@kirang89
kirang89 / model_relation_ex.py
Created April 7, 2014 18:59
Example for many-to-many relationship with extra columns in SQLAlchemy
import sqlalchemy
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String, ForeignKey
from sqlalchemy.orm import sessionmaker, relationship
engine = sqlalchemy.create_engine('sqlite:///:memory:')
Base = declarative_base()