Skip to content

Instantly share code, notes, and snippets.

View scarstens's full-sized avatar
🌟
Automating workflows.

Seth Carstens scarstens

🌟
Automating workflows.
View GitHub Profile
View react-query-param-cap-firstletter.js
import { useRouter } from "next/router";
const function getAssetTypeFirstLetterUppercase(){
const { query } = useRouter();
// Format first letter to be capitalized
const assetType = query?.type
? query?.type[0].toUpperCase() + query?.type.slice(1)
: undefined;
}
@scarstens
scarstens / nodemailer-smpt-connection-test.mjs
Created August 12, 2022 16:54
Nodemailer SMTP connection test
View nodemailer-smpt-connection-test.mjs
// Make sure you run this file from the project root
// or use `npm run email`
import nodemailer from "nodemailer";
import * as dotenv from "dotenv";
import path from "path";
dotenv.config({
// path: path.resolve(path.basename(path.dirname(process.cwd())), ".env"),
});
console.log(
"Setup email config: ",
@scarstens
scarstens / Dockerfile
Created April 10, 2022 03:34
Dockerfile for production deploys
View Dockerfile
# Double-container Dockerfile for separated build process.
# If you're just copy-pasting this, don't forget a .dockerignore!
# We're starting with the same base image, but we're declaring
# that this block outputs an image called DEPS that we
# won't be deploying - it just installs our npm deps
FROM node:14-alpine AS deps
# If you need libc for any of your deps, uncomment this line:
# RUN apk add --no-cache libc6-compat
View azure-cli-jumphost-setup.md
@scarstens
scarstens / lando-wp-init.sh
Last active March 26, 2019 22:16
Lando Initializer
View lando-wp-init.sh
lando init --recipe=wordpress --webroot=. --option via=nginx --option php=7.2 --option database=mariadb --option xdebug=true --source=cwd --name=osp
lando start
lando wp core download
lando wp config create --dbname=wordpress --dbuser=wordpress --dbpass=wordpress
lando wp core install --quiet --admin_email="admin@lando.site" --title="LandoSite" --admin_user=admin --admin_password=password --url=https://osp.lndo.site
lando wp theme delete twentythirteen ; lando wp theme delete twentyfourteen; lando wp theme delete twentyfifteen; lando wp theme delete twentysixteen; lando wp plugin delete hello; lando wp plugin delete akismet;;
@scarstens
scarstens / vvv-nginx-image-fallback-prod.conf
Created June 21, 2018 21:49
Nginx configuration based on FanSided's local development shows has to setup nginx fallback for images that exist in production, so that you don't need to download them locally.
View vvv-nginx-image-fallback-prod.conf
#matches all .dev TLDs
log_format main 'MAIN: $remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" "$gzip_ratio"';
log_format wpc 'WPCONTENT: $remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" "$gzip_ratio"';
log_format PROXY 'PROXY: $remote_addr - $remote_user [$time_local] '
@scarstens
scarstens / sunrise.php
Created August 23, 2017 03:13
multisite-top-level-domain-config
View sunrise.php
<?php
if (!empty($_SERVER['HTTP_HOST']))
{
$site = get_site_by_path(strtolower($_SERVER['HTTP_HOST']), '/');
define('COOKIE_DOMAIN', '.'.$site->domain);
}
@scarstens
scarstens / class-an-injected-network-site-option.php
Created January 11, 2017 17:24
Site option example of injecting new section and fields into existing sm_options_page or sm_options_container from the fansided-vip plugin
View class-an-injected-network-site-option.php
<?php
/**
* Plugin Name: an-injected-network-site-option
* Description: Site option example of injecting new section and fields into existing sm_options_page or sm_options_container from the fansided-vip plugin
* Plugin URI: https://github.com/fansided
* Author: sethcarstens
* Author URI: https://fansided.com
* Version: 0.0.1
* Text Domain: fs
* License: GPLv2 or later
@scarstens
scarstens / sunrise.php
Created April 18, 2016 23:50
Custom sunrise for TLD wordpress multisite in 1 file
View sunrise.php
<?php
if ( !empty( $_SERVER['HTTP_HOST'] ) ) {
$site = get_site_by_path( strtolower( $_SERVER['HTTP_HOST'] ), '/');
define( 'COOKIE_DOMAIN', '.' . $site->domain );
}
@scarstens
scarstens / fix-dynamic-zindex-hoarders.js
Created June 27, 2015 01:33
Javascript snippet should be loaded "on page load" and it should attach itself to any elements on the page that are abusing z-index (anything over 999) and brings them back down to 99 by building a style element after the element found. Does not fix elements with inline !important styles, which are impossible to override.
View fix-dynamic-zindex-hoarders.js
//todo: needs to somehow use the .on function to attach to elements created after pageload
jQuery('[style*="z-index"]').each(function() {
var zi = $(this).css("z-index");
if(zi > 999){
newstyle = jQuery('<style class="zindex2big" type="text/css"> #'+this.id+'{ z-index=99 !important;} </style>').insertAfter(this);
}
});