Skip to content

Instantly share code, notes, and snippets.

View corypina's full-sized avatar

Cory Piña corypina

View GitHub Profile
@corypina
corypina / check-for-capslock.js
Created March 13, 2024 01:51
Detect caps lock
// via https://davidwalsh.name/detect-caps-lock
document.querySelector('input[type=password]').addEventListener('keyup', function (keyboardEvent) {
const capsLockOn = keyboardEvent.getModifierState('CapsLock');
if (capsLockOn) {
// Warn the user that their caps lock is on?
}
});
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible).
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export.
var FORMAT_ONELINE = 'One-line';
var FORMAT_MULTILINE = 'Multi-line';
var FORMAT_PRETTY = 'Pretty';
var LANGUAGE_JS = 'JavaScript';
var LANGUAGE_PYTHON = 'Python';
@corypina
corypina / check-role-by-capability.php
Created September 12, 2023 04:29
Check WP roles by capability
<?php
// Administrator
current_user_can('manage_options')
// Editor or higher
current_user_can('edit_others_posts')
// Author or higher
current_user_can('publish_posts')
@corypina
corypina / custom-header-shape.css
Last active March 31, 2023 19:07
Beaver Builder Snippets
header.fl-builder-content {
position:relative;
}
header.fl-builder-content:before {
content: "";
background: rgba(255,255,255,0.52);
width: 100%;
height: 12px;
display: block;
@corypina
corypina / align-to-bottom.css
Created December 9, 2022 22:31
Beaver Bulider Snippets
/* Align a single column to the bottom of a row, where the row has a set height */
#rowSelector .fl-row-content-wrap {
display: flex;
align-items: flex-end;
}
@corypina
corypina / moveElementOnWidth.js
Created November 3, 2022 00:02
Move an element from one place to another based on browser/device width
let breakPoint = 768
let moveThis = document.querySelector('.nodeToMove')
let newParent = document.querySelector('.newParentNode')
let origin = document.querySelector('.originalParentNode')
const moveTheNode = () => {
let viewportWidth = window.innerWidth || document.documentElement.clientWidth;
if (viewportWidth < breakPoint) {
newParent.after(moveThis)
} else {
@corypina
corypina / wp-cron.js
Created September 9, 2021 16:48
Ping WordPress cron to manage cron jobs externally. For use in AWS Lambda, etc.
const https = require("https");
let url = "https://domain.com/wp-cron.php?doing_wp_cron";
exports.handler = function (event, context, callback) {
https
.get(url, (res) => {
callback(null, res.statusCode);
})
.on("error", (e) => {
callback(Error(e));
@corypina
corypina / frosted-glass.css
Created August 9, 2021 15:50
Frosted glass effect in CSS
.adaptive-glass {
--glass-lightness: 100%;
background: hsl(0 0% var(--glass-lightness) / 50%);
backdrop-filter: blur(40px);
@media (prefers-color-scheme: dark) {
--glass-lightness: 0%;
}
}
@corypina
corypina / cron-requests.csv
Created July 7, 2021 21:54
Example Cron Requests
We can make this file beautiful and searchable if this error is corrected: It looks like row 5 should actually have 9 columns, instead of 6. in line 4.
timestamp,method,host,url,ip,referer,user_agent,http_status,cache_status
2021-07-07 21:15:16 UTC,POST,www.ourdomain.com,/wp-cron.php?doing_wp_cron=1625692516.2409739494323730468750,34.135.50.59,https://www.ourdomain.com/wp-cron.php?doing_wp_cron=1625692516.2409739494323730468750,WordPress/5.7.2; https://www.ourdomain.com,200,PASS
2021-07-07 21:14:59 UTC,POST,www.ourdomain.com,/wp-cron.php?doing_wp_cron=1625692499.0113999843597412109375,34.135.50.59,https://www.ourdomain.com/wp-cron.php?doing_wp_cron=1625692499.0113999843597412109375,WordPress/5.7.2; https://www.ourdomain.com,200,PASS
2021-07-07 21:14:40 UTC,POST,www.ourdomain.com,/wp-cron.php?doing_wp_cron=1625692480.4495329856872558593750,34.135.50.59,https://www.ourdomain.com/wp-cron.php?doing_wp_cron=1625692480.4495329856872558593750,WordPress/5.7.2; https://www.ourdomain.com,200,PASS
2021-07-07 21:14:32 UTC,POST,www.ourdomain.com,/wp-cron.php?doing_wp_cron=1625692471.9752209186553955078125,34.135.50.59,https://www.ourdomain.com/wp-cron.php?doing_wp_cron=1
.required:after {
content: " *";
font-size: .5em;
color: red;
vertical-align: super;
}