Skip to content

Instantly share code, notes, and snippets.

View AleksNeStu's full-sized avatar
💻
💻 Deep Dive Coding 🛸😎🏖️

Alex Nesterovich AleksNeStu

💻
💻 Deep Dive Coding 🛸😎🏖️
View GitHub Profile
@AleksNeStu
AleksNeStu / git_date_shifter.py
Last active March 4, 2025 17:57
GitDateShifter: A Python script to shift Git commit dates from an old range to a new one, constrained within daily work hours.
"""
GitDateShifter: A Python script to shift Git commit dates from an old range to a new one, constrained within specific hours.
It retrieves commits from a specified old range (e.g., 2025-03-02 00:00:00 to 2025-03-02 23:59:59), redistributes them evenly across a new range (e.g., 2025-03-03 09:30:00 to 2025-03-04 17:59:00) between new_min_time (09:00:00) and new_max_time (18:00:00), and updates both author and committer dates via Git rebase.
Features:
- Evenly spreads commits within specific hours (e.g., 9 AM to 6 PM) across days.
- Preserves commit order.
- Handles partial first/last days and multi-day ranges.
- Includes error handling and logging with rebase abort safety.
- Shows updated commit logs with --pretty=fuller.
"""
1. Store the image and create an instance of ImagefileProcessHistory with status NOT_STARTED
ImageFileProcessHistory
- local_path
- file_name
- status # enum: NOT_STARTED, STARTED, SUCCEEDED, FAILED
- bytes_processed
- bytes_total
"""
@AleksNeStu
AleksNeStu / flask_sitemap_generator.py
Created February 3, 2022 19:52 — forked from Julian-Nash/flask_sitemap_generator.py
Flask dynamic sitemap generator
@app.route("/sitemap")
@app.route("/sitemap/")
@app.route("/sitemap.xml")
def sitemap():
"""
Route to dynamically generate a sitemap of your website/application.
lastmod and priority tags omitted on static pages.
lastmod included on dynamic content such as blog posts.
"""
from flask import make_response, request, render_template
@AleksNeStu
AleksNeStu / camel_case_to_snake_case.py
Created March 27, 2018 08:22 — forked from jaytaylor/camel_case_to_snake_case.py
Convert camel-case to snake-case in python.
#!/usr/bin/env python
"""
Convert camel-case to snake-case in python.
e.g.: CamelCase -> snake_case
Relevant StackOverflow question: http://stackoverflow.com/a/1176023/293064
"""
# Copyright (C) 2018 Google Inc.
# Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>
"""Constants and methods for work with objects."""
import sys
class ClassRepr(object):
"""Properties for class representation."""
@property
@AleksNeStu
AleksNeStu / entities_factory.py
Created January 19, 2018 07:55
people_logic_ent_factory
class PeopleFactory(EntitiesFactory):
"""Factory class for Persons entities."""
def __init__(self, obj_name=objects.PEOPLE):
super(PeopleFactory, self).__init__(obj_name, self.default_user)
if self.child_cls not in [AssessmentTemplatesFactory,
CustomAttributeDefinitionsFactory]:
if self.child_cls == ProgramsFactory:
self.manager = self.obj_creator
class CommentItem(object):
"""Locators for single item in comments' panel."""
AUTHOR_CSS = (By.CSS_SELECTOR, ".person-holder")
DATETIME_CSS = (By.CSS_SELECTOR,
".comment-object-item__header-author-info")
CONTENT_CSS = (By.CSS_SELECTOR, ".comment-object-item__text")
@AleksNeStu
AleksNeStu / selenium_utils.py
Created December 20, 2017 12:31
get_url_and_wait
def open_url(driver, url):
"""Open URL in current browser session if it hasn't been opened yet."""
# driver.get(url)
f = 1
# driver.execute_script("window.open('http://google.com', 'new_window')")
# if driver.current_url != url:
# driver.switch_to_window(driver.window_handles[0])
if driver.current_url != url:
driver.execute_script("window.open('{}', '_self')".format(url))
# driver.get(url)
@AleksNeStu
AleksNeStu / string_utils.py
Created November 17, 2017 10:57
random_sample
BLANK = ''
STAR = "*"
WHITESPACE = " "
COMMA = "," # comma is used as delimiter for multi-choice values
LESS = "<"
MORE = ">"
DOUBLE_QUOTES = '\"'
SINGLE_QUOTE = "\'"
BACKSLASH = "\\"
SLASH = "/"
DB: Rich Text_d01d2475-3039__[=\'?$={.).:%($~{\'%-=)+$-`/+>>*~&;;~[[\'\n
Rich Text_d01d2475-3039__[=\'?$={.).:%($~{\'%-=)+$-`/+>>*~&;;~[[\'\\n\
Server's RESPONSE: Rich Text_d01d2475-3039__[='?$={.).:%($ {!_$[:%';'=�_@'
BAD SYMBOLS: \'
DB: Dropdown_fe22e33f-ce93_~{:*~++#^]~:@@|//.?[$?{*.#.:\
Server's RESPONSE: Dropdown_fe22e33f-ce93_ +.{@>
BAD SYMBOLS: \'