Skip to content

Instantly share code, notes, and snippets.

View Edwardtonnn's full-sized avatar
🎯
Focusing

Edward Edwardtonnn

🎯
Focusing
  • Los Angeles Web Club
  • South Gate, CA
View GitHub Profile
@Edwardtonnn
Edwardtonnn / renameInOrder.py
Created November 29, 2023 22:42
Renames all folders in numberic order 01 02 03...
import os
import sys
def rename_directories_to_sequential_numbers(path):
if not os.path.isdir(path):
print(f"The provided path '{path}' is not a valid directory.")
return
dirs = [d for d in os.listdir(path) if os.path.isdir(os.path.join(path, d))]
dirs.sort()
@Edwardtonnn
Edwardtonnn / lower.py
Created November 22, 2023 15:04
To lowercase all lazy-src=""
import os
import re
# Function to lowercase everything within the 'lazy-src' attribute in an HTML file
def lowercase_lazy_src(file_path):
with open(file_path, 'r', encoding='utf-8') as file:
content = file.read()
# Use regular expression to find all 'lazy-src' attributes and lowercase their values
modified_content = re.sub(r'lazy-src="([^"]+)"', lambda match: f'lazy-src="{match.group(1).lower()}"', content, flags=re.IGNORECASE)
@Edwardtonnn
Edwardtonnn / index.php
Created November 10, 2023 16:50
Blog Link Cards with Image
<div class="flexy flexy-pad equal-height is-multiline pv100">
<div class="flexy-item is-4 is-6-widescreen animate fadeIn no-delay">
<a class="card no-pad" href="/">
<img lazy-src="/assets/img/blog/gum-line-cavities.jpg" alt="<?php AltTag() ?>">
<div class="card-content">
<h2 class="title-sm uppercase mb65 animate fadeIn no-delay">Replace</h2>
<p class="animate fadeIn white small-subhead no-delay">Replace</p>
<p class="animate fadeIn no-delay">Replace</p>
<span class="button animate fadeIn no-delay mb50">Read More</span>
@Edwardtonnn
Edwardtonnn / index.js
Created August 17, 2023 16:56
Update logo color on scroll. Changes logo from white to black on scroll
const logo = document.querySelector('.navbar__logo');
const menuButton = document.querySelector('.menu-button');
let isScrolled = false;
let isMenuOpen = false;
function updateLogo() {
if (isMenuOpen || isScrolled) {
logo.src = '/assets/img/logo.svg';
} else {
logo.src = '/assets/img/logo-white.svg';
@Edwardtonnn
Edwardtonnn / index.html
Last active July 28, 2023 21:39
use of picsum
<img src="https://picsum.photos/seed/fun/2000/1000?grayscale" alt="Image 1">
<img src="https://picsum.photos/seed/art/2000/1000" alt="Image 2">
<!-- https://picsum.photos/ -->
@Edwardtonnn
Edwardtonnn / index.php
Created July 28, 2023 21:22
Default title and description section
<?php include $_SERVER['DOCUMENT_ROOT'] . "/assets/inc/variables.php" ?>
<?php
$seotitle = "REPLACE in $city $state | $sitename";
$seodesc = "$sitename offers premier $profession services in $city, $state. Call $phone today to schedule your REPLACE appointment today.";
$section = "procedure";
?>
@Edwardtonnn
Edwardtonnn / rename.py
Created July 16, 2023 23:17
Renames jpg or png files to sequence 01.jpg and output jpg
import os
def rename_files(extension):
files = [f for f in os.listdir() if f.endswith(extension)]
for i, file in enumerate(sorted(files), start=1):
os.rename(file, f"{str(i).zfill(2)}{extension}")
if __name__ == "__main__":
rename_files(".jpg")
rename_files(".png")
@Edwardtonnn
Edwardtonnn / rename.py
Created July 13, 2023 21:01
Rename Png images to sequence
import os
def rename_images():
image_files = [f for f in os.listdir() if f.endswith('.png')]
image_files.sort()
for i, filename in enumerate(image_files):
new_filename = '{:02d}.png'.format(i + 1)
os.rename(filename, new_filename)
print('Renamed {} to {}'.format(filename, new_filename))
@Edwardtonnn
Edwardtonnn / Rename.py
Created July 13, 2023 17:54
Python to rename files
import os
folder_path = os.getcwd()
for filename in os.listdir(folder_path):
if filename.endswith(".png.jpg"):
new_filename = filename.replace(".png", "")
os.rename(os.path.join(folder_path, filename), os.path.join(folder_path, new_filename))
print("Renamed '{}' to '{}'".format(filename, new_filename))
@Edwardtonnn
Edwardtonnn / index.html
Last active January 29, 2024 16:37
Card with Image no padding
<div class="flexy flexy-pad equal-height is-multiline pv100">
<div class="flexy-item is-4 is-6-widescreen animate fadeIn">
<a class="card no-pad" href="/">
<img lazy-src="/assets/img/blog" alt="">
<div class="card-content">
<h2 class="title-sm uppercase mb65 animate fadeIn"></h2>
<p class="animate fadeIn small-subhead"></p>
<p class="animate fadeIn"></p>
<span class="button animate fadeIn mb50">Read More</span>
</div>