Skip to content

Instantly share code, notes, and snippets.

@edward-jimenez
edward-jimenez / HeroView.swift
Last active March 25, 2023 20:27
Add Hero Parallax Scrolling Header
//
// HeroView.swift
// Roku Clone
//
// Created by Edward Jimenez on 3/19/23.
//
import SwiftUI
struct HeroView: View {
@edward-jimenez
edward-jimenez / replace-string.php
Created May 6, 2018 22:59
Example on using PHP substr_replace function
<?php
/*
Print the last 4 charactrs of a credit card number replacing the first 12 characters with asterisks
using the PHP substr_replace function
*/
@edward-jimenez
edward-jimenez / check-email.php
Created May 6, 2018 22:39
Check whether a POST variable contains the '@' symbol in an email input
<?php
/*
Checking if an email address contains the '@' symbol
using the PHP strpos function
*/
@edward-jimenez
edward-jimenez / child-theme.php
Created January 17, 2017 04:09
WordPress recommended method for child theme creation
<?php
/*
In your functions.php file on the child theme, enter the following code
*/
function prefix_theme_enqueue_styles() {
$parent_style = 'parent-style'; // style.css of the parent theme
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style',
@edward-jimenez
edward-jimenez / .htaccess
Created January 16, 2017 16:35
Basic htaccess file for WordPress
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
@edward-jimenez
edward-jimenez / enable_compression
Last active January 15, 2017 22:58
Enable gzip compression via .htaccess
/*
Add the following to the .htaccess file to enable gzip compression
*/
<IfModule mod_deflate.c>
# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
@edward-jimenez
edward-jimenez / remove_script_version
Created January 2, 2017 04:18
Removes the version of your css and javascript files to speed up performance
/*
Put the following function in your functions.php file to remove the query strings from css and javascript files
*/
function prefix_remove_script_and_style_version( $src ){
$ver = explode( '?ver', $src );
return $ver[0];
}
add_filter( 'script_loader_src', 'prefix_remove_script_and_style_version', 15, 1 );
add_filter( 'style_loader_src', 'prefix_remove_script_and_style_version', 15, 1 );
@edward-jimenez
edward-jimenez / css_versioning.php
Last active December 3, 2016 00:13
Version your style.css file in WordPress
<?php
/*
Add this function to your fuctions.php to
version your style.css. Make sure to
define a constant to hold your CSS version.
*/
define( 'OUR_APP_VERSION', '2.0' );
function prefix_default_style( $styles ) {
/* Use our default version style */
<!DOCTYPE html>
<html lang="en-US" >
<head>
<meta http-equiv="Content-Type" content="text/html" charset="utf-8" />
<meta name="author" content="Edward Jimenez">
<meta name="description" content="Site Description">
<!-- CSS stylesheets -->
<link rel="stylesheet" tye="text/css" href="style.css" >
@edward-jimenez
edward-jimenez / Browser caching-WordPress
Created October 15, 2016 03:37
Browser caching in WordPress
# Expires Caching Start #
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/css "access 8 days"
ExpiresByType text/html "access 8 days"
ExpiresByType image/gif "access 8 days"
ExpiresByType image/png "access 8 days"
ExpiresByType image/jpg "access 8 days"
ExpiresByType image/jpeg "access 8 days"
ExpiresByType image/x-icon "access 8 days"