Skip to content

Instantly share code, notes, and snippets.

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

Olúwátóósìn Anímáṣahun takwas

🏠
Working from home
View GitHub Profile
# THE SOLUTION IS THE FUNCTION `generate_first_elements`
# write a function which takes an iterable of iterators as
# an argument and returns a generator of first elements of
# the input iterators
def generate_first_elements(iterable_arg):
# return a "generator object" that produces the first
@qoomon
qoomon / conventional-commits-cheatsheet.md
Last active March 14, 2025 21:42
Conventional Commits Cheatsheet

Conventional Commit Messages starline

See how a minor change to your commit message style can make a difference.

Tip

Have a look at git-conventional-commits , a CLI util to ensure these conventions, determine version and generate changelogs

Commit Message Formats

Default

@bennylope
bennylope / create_db_restore.sh
Last active August 20, 2020 13:12
Create a named database and restore from the lastest downloaded file
#!/usr/bin/env bash
LATEST_DB="$HOME/Downloads/$(ls -t ~/Downloads | head -1)"
BACKUP_PATH=${2-$LATEST_DB}
DB=$1
echo "Creating database name $DB from $BACKUP_PATH"
psql -c "CREATE DATABASE $DB;"
@knowsuchagency
knowsuchagency / Dockerfile
Created July 16, 2018 05:08
Makefile Docker Git GitHub multi-stage build ssh private key recipe
FROM python:3 as build-system
RUN pip install -U pip
COPY requirements.txt requirements.txt
### create temporary image used to download and vendor packages using private key ###
FROM build-system as intermediate
# add credentials on build
@sdnts
sdnts / example.md
Last active January 10, 2023 20:50
Postman pm.sendRequest example

To send a request via the sandbox, you can use pm.sendRequest.

pm.test("Status code is 200", function () {
    pm.sendRequest('https://postman-echo.com/get', function (err, res) {
        pm.expect(err).to.not.be.ok;
        pm.expect(res).to.have.property('code', 200);
        pm.expect(res).to.have.property('status', 'OK');
    });
});
@takwas
takwas / demo.py
Created August 14, 2017 18:23
Exception message printing demo
###########
# Python 2:
###########
try:
raise Exception
except Exception as e:
s,r = getattr(e, 'message') or str(e), getattr(e, 'message') or repr(e)
print 's:', s, 'len(s):', len(s)
print 'r:', r, 'len(r):', len(r)
@robertpainsi
robertpainsi / commit-message-guidelines.md
Last active March 5, 2025 16:55
Commit message guidelines

Commit Message Guidelines

Short (72 chars or less) summary

More detailed explanatory text. Wrap it to 72 characters. The blank
line separating the summary from the body is critical (unless you omit
the body entirely).

Write your commit message in the imperative: "Fix bug" and not "Fixed
bug" or "Fixes bug." This convention matches up with commit messages
@prashnts
prashnts / asyncdownload.py
Created February 15, 2017 08:00
Asyncio Python -- Download in parallel
import aiohttp
import asyncio
BATCH_SIZE = 20
POOL_SIZE = 5
async def get_content(client, url):
async with client.get(url) as response:
return await response.text()
@jesugmz
jesugmz / 60-jetbrains.conf
Last active April 24, 2023 17:32
Avoid the message 'External file changes sync may be slow: The current inotify(7) watch limit is too low.' from JetBrains products
#
# Avoid the message 'External file changes sync may be slow: The current inotify(7) watch limit is too low.' from JetBrains products.
#
# 1. Create the file /etc/sysctl.d/60-jetbrains.conf and paste this code
# 2. Restart the sysctl service: sudo sysctl -p --system
# 3. Restart the IDE
#
# More info:
# https://confluence.jetbrains.com/display/IDEADEV/Inotify+Watches+Limit
@doobeh
doobeh / acetakwas_context.py
Created September 20, 2016 17:47
Context scopes.
from flask import Flask, current_app, render_template_string
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
db = SQLAlchemy(app)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///'
class Example(db.Model):
id = db.Column(db.Integer, primary_key=True)