Skip to content

Instantly share code, notes, and snippets.

View jessekanner's full-sized avatar

Jesse Kanner jessekanner

  • Los Angeles, CA
View GitHub Profile
@jessekanner
jessekanner / create_db_and_user.sql
Created March 30, 2023 00:13
MySQL: Create DB & User
CREATE DATABASE dbname;
USE dbname;
CREATE USER 'dbusr'@'localhost' IDENTIFIED WITH mysql_native_password BY 'xxxxxxxxxxxxxxxxx';
GRANT ALL PRIVILEGES ON dbname.* TO dbusr@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
@jessekanner
jessekanner / wp_query_w_pagination.php
Created March 7, 2023 13:39
WordPress - Custom WP_Query with pagination
global $wp_query;
$paged = get_query_var('paged', 1);
$args = array(
'post_type' => '{your_post_type_name}',
'meta_query' => array('{add your meta query argument if need}'),
'orderby' => 'modified',
'order' => 'DESC',
'posts_per_page' => 20,
'paged' => $paged
@jessekanner
jessekanner / nginx-redirects.conf
Created February 27, 2023 22:26
nginx redirects
server {
listen 80;
server_name www.domain.com domain.com;
return 301 https://domain.com$request_uri;
}
server {
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/thewritekit.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/thewritekit.com/privkey.pem; # managed by Certbot
@jessekanner
jessekanner / social-share-links.html
Created February 22, 2023 15:37
Social Share Links (2023)
@jessekanner
jessekanner / skip-link-implemation.html
Last active May 6, 2022 12:22
Implementation for tabbed Skip Link
@jessekanner
jessekanner / how-to-install-node-app.md
Created January 5, 2022 13:26
How To install a Node.js application on Ubuntu 20.04
@jessekanner
jessekanner / install-google-chrome-headless.sh
Last active December 30, 2021 12:49
Installing Google Headless Chrome on Ubuntu
sudo apt-get install -y libappindicator1 fonts-liberation
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome*.deb
sudo apt-get -f install
google-chrome-stable -version
// docs https://developers.google.com/web/updates/2017/04/headless-chrome
@jessekanner
jessekanner / laravel-php-dynamo-db-example.php
Last active December 8, 2021 16:06
Read and Insert data into DynamoDB in Laravel controllers (and plain PHP)
## Reference: https://github.com/aws/aws-sdk-php-laravel
## Setup 1. Include AWS SDK into composer
composer require aws/aws-sdk-php-laravel
## Setup 2. Publish AWS Class into Laravel
php artisan vendor:publish --provider="Aws\Laravel\AwsServiceProvider"
@jessekanner
jessekanner / wordpress-basic-ajax.txt
Created November 11, 2021 20:22
WordPress Basic Ajax Handling
Requirements
-------------------------
In wp-admin you do not need to do anything, the js library is always loaded
In the front-end you need to enqueue the script wp-util, like this:
add_action( 'wp_enqueue_scripts', 'my_enqueue_function' );
function my_enqueue_function() {
// Option 1: Manually enqueue the wp-util library.
wp_enqueue_script( 'wp-util' );
@jessekanner
jessekanner / wordpress_display_pdf_thumbnail.php
Created August 27, 2021 15:10
Display a PDF thumbnail in WordPress front end
/* --- Used to display thumbnails automatically created by WordPress --- */
// Get attachement ID (this is circuitous, but seems to be the most "wordpress" way w/o needing plugins, etc
$attachment_id = array_keys(get_attached_media('*,*',$post->ID))[0];
// Once you have the attachment_id, proceed as normal
echo wp_get_attachment_image( $attachment_id, 'full', $icon, $attr );