Skip to content

Instantly share code, notes, and snippets.

View tinytengu's full-sized avatar
👺
Doing tinytengu things

Daniel tinytengu

👺
Doing tinytengu things
View GitHub Profile
@tinytengu
tinytengu / python_linked_list.py
Created May 4, 2021 09:16
Python Linked List Implementation
class InvalidNodeIndex(Exception):
"""InvalidNodeIndex class"""
def __init__(self, index, node=None):
self.index = index
self.node = node
def __str__(self):
return "Invalid node index: %i" % (self.index)
@tinytengu
tinytengu / python_dict_object.py
Created May 4, 2021 09:17
Python Dictionary to an Object implementation
class DictObject:
"""DictObject class"""
def __init__(self):
self._fields = {}
def add_field(self, name, value):
"""Add field to the DictObject fields list
:param name: field name
:type name: str
@tinytengu
tinytengu / Python.sublime-build
Created May 4, 2021 09:18
Sublime Text 3 Custom Python Build System
{
"cmd": ["python", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python",
"variants": [
{
"name": "Terminal",
"shell": true,
"shell_cmd": "start cmd /k $file"
}
@tinytengu
tinytengu / C++.sublime-build
Created May 4, 2021 09:19
Sublime Text 3 C++ (G++) Custom Build System
{
"shell_cmd": "g++ \"$file\" -o \"$file_path/$file_base_name\"",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "$file_path",
"selector": "source.c, source.c++",
"variants":
[
{
"name": "Run",
@tinytengu
tinytengu / vector2d.java
Created May 5, 2021 11:22
Java 2D Vector Class Implementation
class Vector2D
{
public double vX;
public double vY;
public static int count = 0;
public Vector2D() {
this.vX = this.vY = 1.0;
count++;
@tinytengu
tinytengu / windesk.ahk
Created June 4, 2021 09:50
Windows Virtual Desktops Hotkeys Override
#^Up::
Send #^d
return
#^Down::
Send #^{F4}
return
@tinytengu
tinytengu / memz_auth.py
Created June 18, 2021 18:53
memz.fun authorization implementation
import re
from vk_api import VkApi
from vk_api.exceptions import VkApiError
from bs4 import BeautifulSoup
class MemzAuth:
OAUTH_URL = 'https://oauth.vk.com/authorize?client_id=7877542&redirect_uri=https://memz.fun/signin.php&display=page'
@tinytengu
tinytengu / prompt_yn.sh
Created June 25, 2021 18:09
Bash Yes/Now prompt implementation with default answer
prompt_yn() {
def=$2
# Normalize default answer and prompt
case $def in
[yY]) def="y"; read -r -p "${1} [Y/n] " input;;
[nN]) def="n"; read -r -p "${1} [y/N] " input;;
esac
# Echo 1 if yes else 0
@tinytengu
tinytengu / docker.sh
Last active September 23, 2021 17:05
Docker & Docker-Compose installation and configuration shell script
# Utils
prompt_yn() {
def=$2
case $def in
[yY]) def="y"; read -r -p "${1} [Y/n] " input;;
[nN]) def="n"; read -r -p "${1} [y/N] " input;;
esac
case $input in
@tinytengu
tinytengu / Dockerfile
Last active September 23, 2021 17:05
Alpine w/ latest Python 3 Dockerfile
FROM alpine:latest
ENV PYTHONBUFFERED=1
RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python \
&& python3 -m ensurepip