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 / 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 / functions.php
Last active September 11, 2023 21:24
Genesis Enqueue Styles Function
<?php
//Do not include opening <?php tag
//* Load custom style sheet
add_action( 'wp_enqueue_scripts', 'load_styles' );
function load_styles() {
wp_enqueue_style(
'custom',
get_stylesheet_directory_uri() . '/css/custom.css',
@Edwardtonnn
Edwardtonnn / custom.js
Last active September 11, 2023 21:24
wp_enqueue script
(function($) {
// $ Works! You can test it with next line if you like
console.log("I'm alive!");
})( jQuery );
@Edwardtonnn
Edwardtonnn / functions.php
Last active September 11, 2023 21:24
Holy Grail of All Genesis
<?php
//Only Code Below This Line
//_________________________________________
//* Customize the entire footer
remove_action( 'genesis_footer', 'genesis_do_footer' );
add_action( 'genesis_footer', 'custom_footer' );
function custom_footer() {
@Edwardtonnn
Edwardtonnn / functions.php
Created September 18, 2018 22:07
Slick Slider
<?php
// Drop Slick Slider files inside of js folder and add the following to your functions.php
//Slick Slider JS
add_action('wp_enqueue_scripts', 'load_slick', 5);
function load_slick(){
// Slick Slider JS
wp_enqueue_script(
'slick',
get_stylesheet_directory_uri() . '/js/slick/slick.js',
@Edwardtonnn
Edwardtonnn / _functions.php
Last active September 11, 2023 21:23
Holy Grail Genesis Function Edits 2.0.0
//* Customize Footer
remove_action( 'genesis_footer', 'genesis_do_footer' );
add_action( 'genesis_footer', 'custom_footer' );
function custom_footer() {
?>
<p>&copy; Copyright 2018 <a href="#">My Domain</a> &middot; All Rights Reserved &middot; Powered by <a href="http://wordpress.org/">WordPress</a> &middot; <a href="http://mydomain.com/wp-admin">Aline Inc.</a></p>
<?php
}
//* Remove the edit link
add_filter ( 'genesis_edit_post_link' , '__return_false' );
@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.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/ -->