Skip to content

Instantly share code, notes, and snippets.

View eruvanos's full-sized avatar

Maic Siemering eruvanos

View GitHub Profile
@JadenGeller
JadenGeller / Semaphore.swift
Last active May 16, 2017 15:51
Swift Semaphore
struct Semaphore {
let semaphore: dispatch_semaphore_t
init(value: Int = 0) {
semaphore = dispatch_semaphore_create(value)
}
// Blocks the thread until the semaphore is free and returns true
// or until the timeout passes and returns false
@wojteklu
wojteklu / clean_code.md
Last active November 17, 2024 20:34
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@butla
butla / wait_for_tcp_port.py
Last active December 8, 2022 19:52
Waiting for a TCP port to start accepting connections (Python >=3.6)
"""
MIT License
Copyright (c) 2017 Michał Bultrowicz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@eruvanos
eruvanos / log_util.py
Last active August 30, 2024 10:58
Better log config for Python
"""
Configures a logger to log <=INFO to stdout and >INFO to stderr
"""
import logging
import os
import sys
DEFAULT_FORMAT = '%(asctime)s - %(levelname)s - %(name)s - %(message)s'
NO_TIME_FORMAT = '%(levelname)s - %(name)s - %(message)s'
@jerblack
jerblack / Prevent_flask_production_environment_warning.py
Last active May 11, 2023 05:35
Disable ability for Flask to display warning about using a development server in a production environment.
"""
Flask will display a warning everytime you startup your application if you are not using it in behind a separate WSGI server.
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
This was not relevant for my scenario and I wanted the message gone,
so using this method will remove their ability to print that message
@kasteph
kasteph / workshop.md
Last active February 11, 2021 16:52
PyCon Berlin 2019: Poetry Workshop

Package and Dependency Management with Poetry

The Poetry repository can be found here and the website here.

For documentation on the pyproject.toml file specific to Poetry, go here.

The goal of this workshop is to have a pyproject.toml that poetry can use to build your package to a distribution and then publish it to a private repository.

@happy-monk
happy-monk / example.py
Created October 22, 2021 13:23
Coroutines in Pyglet
import pyglet
from pyglet.graphics import Batch
import tasks
window = pyglet.window.Window()
batch = Batch()
@window.event
// ==UserScript==
// @name CloudFormation 🌈
// @namespace http://tampermonkey.net/
// @version 0.1
// @description blinky blinky
// @author You
// @match https://*.console.aws.amazon.com/*
// @icon https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/240/whatsapp/326/rainbow_1f308.png
// @grant none
// ==/UserScript==
@acarril
acarril / bootable-win-on-mac.md
Created November 18, 2022 17:49
Create a bootable Windows USB using macOS

For some reason, it is surprisingly hard to create a bootable Windows USB using macOS. These are my steps for doing so, which have worked for me in macOS Monterey (12.6.1) for Windows 10 and 11. After following these steps, you should have a bootable Windows USB drive.

1. Download a Windows disc image (i.e. ISO file)

You can download Windows 10 or Windows 11 directly from Microsoft.

2. Identify your USB drive

After plugging the drive to your machine, identify the name of the USB device using diskutil list, which should return an output like the one below. In my case, the correct disk name is disk2.