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 / set-window-bounds.applescript
Last active August 31, 2023 18:54
Resize front window to specific size.
tell application "System Events"
set frontmostApplication to name of the first process whose frontmost is true
end tell
-- The bounds are the top-left and bottom-right coordinates on your screen, eg. {x, y, x, y}
tell application frontmostApplication
set bounds of the first window to {15, 38, 1760, 995}
end tell
@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;
add_shortcode('SHORTCODE', function($atts){
$defaults = array();
$atts = wp_parse_args( $atts, $defaults );
ob_start();
// Do Stuff
return ob_get_clean();
});
@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%;
}
}