Skip to content

Instantly share code, notes, and snippets.

@nikolaysm
nikolaysm / rest-api-response-format.md
Created April 11, 2025 12:51 — forked from igorjs/rest-api-response-format.md
REST API response format based on some of the best practices
@nikolaysm
nikolaysm / is_palindrome.py
Created August 29, 2024 23:27
A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward (ignoring spaces, punctuation, and capitalization). Function to test if a word is a palindrome
def is_palindrome(word):
"""
Check if a word is a palindrome.
Args:
word (str): The word to check.
Returns:
bool: True if the word is a palindrome, otherwise False.
"""
@nikolaysm
nikolaysm / python_decorator_functions.md
Last active August 29, 2024 23:20
Decorator - A function that takes another function as an argument, adds functionality, and returns the decorated function.

Timing Decorator

# Function decorator that times execution
from time import time

def timer(func):
    # Nested wrapper function

On August 15, 2013, Barlow participated in a Reddit AMA, where he shared his "Principles of Adult Behavior",

which were originally written in 1977 on the eve of his 30th birthday and have been in circulation ever since:

  1. Be patient. No matter what.

  2. Don’t badmouth: Assign responsibility, not blame. Say nothing of another you wouldn’t say to him in the same language and tone of voice.

  3. Never assume the motives of others are, to them, less noble than yours are to you.

https://developer.mozilla.org/en-US/docs/Web/API/Document/designMode
document.designmode = "on";
# pull official python alpine image
FROM python:3.7-alpine
# Set Environment Variable
ENV PYTHONUNBUFFERED 1
ENV C_FORCE_ROOT true
# Making source and static directory
RUN mkdir /src
RUN mkdir /static
#
# This small example shows you how to access JS-based requests via Selenium
# Like this, one can access raw data for scraping,
# for example on many JS-intensive/React-based websites
#
from time import sleep
from selenium import webdriver
from selenium.webdriver import DesiredCapabilities
[
{
"id": "1",
"title": "Manager de campagne Anvers",
"company": "Qiwie",
"duration": "7"
},
{
"id": "2",
"title": "Teamleader of Private Projects Construction",
[
{
"id": "1",
"candidates": "2",
"views": "1001"
},
{
"id": "2",
"candidates": "3",
"views": "639"
@nikolaysm
nikolaysm / pg_backup.config
Last active September 15, 2021 15:34
Automated Backup on Linux with admin notification by mail
##############################
## POSTGRESQL BACKUP CONFIG ##
##############################
# Optional system user to run backups as. If the user the script is running as doesn't match this
# the script terminates. Leave blank to skip check.
BACKUP_USER=
# Optional hostname to adhere to pg_hba policies. Will default to "localhost" if none specified.
HOSTNAME=