Skip to content

Instantly share code, notes, and snippets.

View someguy9's full-sized avatar
🏠
Working from home

Andy Feliciotti someguy9

🏠
Working from home
View GitHub Profile
@DavidKuennen
DavidKuennen / minimal-analytics-snippet.js
Last active May 3, 2024 12:55
Minimal Analytics Snippet
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@akshuvo
akshuvo / WordPress Repeater MetaBox.php
Last active April 18, 2024 09:23
Creating a “repeater meta-box” without a Plugin in WordPress
<?php
add_action('admin_init', 'gpm_add_meta_boxes', 2);
function gpm_add_meta_boxes() {
add_meta_box( 'gpminvoice-group', 'Custom Repeatable', 'Repeatable_meta_box_display', 'page', 'normal', 'default');
}
function Repeatable_meta_box_display() {
global $post;
$gpminvoice_group = get_post_meta($post->ID, 'customdata_group', true);
@oousmane
oousmane / get_sunrisesunset.r
Created November 5, 2023 19:12
Get sunrise and sunset time for any location and date from sunsetsunrise.io API
#' Get sunrise and sunset time for any location and date from sunsetsunrise.io API
#'
#' @param lon longitude in decimal degree of the location
#' @param lat latitude in decimal degree of the location
#' @param date a date string in 'yyy-mm-dd' format.
#'
#' @return a tibble with sunset/sunrise time, day length, location timezone and date
#' @export
#'
#' @examples
/* https://go.tacodewolff.nl/minify */
enScroll=!1,enFdl=!1,extCurrent=void 0,filename=void 0,targetText=void 0,splitOrigin=void 0;const lStor=localStorage,sStor=sessionStorage,doc=document,docEl=document.documentElement,docBody=document.body,docLoc=document.location,w=window,s=screen,nav=navigator||{},extensions=["pdf","xls","xlsx","doc","docx","txt","rtf","csv","exe","key","pps","ppt","pptx","7z","pkg","rar","gz","zip","avi","mov","mp4","mpe","mpeg","wmv","mid","midi","mp3","wav","wma"];function a(e,t,n,o){const j="G-XXXXXXXXXX",r=()=>Math.floor(Math.random()*1e9)+1,c=()=>Math.floor(Date.now()/1e3),F=()=>(sStor._p||(sStor._p=r()),sStor._p),E=()=>r()+"."+c(),_=()=>(lStor.cid_v4||(lStor.cid_v4=E()),lStor.cid_v4),m=lStor.getItem("cid_v4"),v=()=>m?void 0:enScroll==!0?void 0:"1",p=()=>(sStor.sid||(sStor.sid=c()),sStor.sid),O=()=>{if(!sStor._ss)return sStor._ss="1",sStor._ss;if(sStor.getItem("_ss")=="1")return void 0},a="1",g=()=>{if(sStor.sct)if(enScroll==!0)return sStor.sct;else x=+sStor.getItem("sct")+ +a,sSto
@krmd
krmd / gist:a66896838b23f0712cea
Created May 30, 2014 15:33
Gravity Forms: Exclude field from notification
//to exclude a field from notifications assign the field the CSS Class Name gf_exclude and then use the {all_fields:exclude} merge tag
add_filter( 'gform_merge_tag_filter', 'exclude_from_all_fields', 10, 4 );
function exclude_from_all_fields( $value, $merge_tag, $options, $field ) {
$options_array = explode( ",", $options ); //breaks options into an array
$exclude = in_array( "exclude", $options_array ); //returns TRUE if 'exclude' is found in the array
$class_array = explode( " ", $field["cssClass"] ); //breaks the fields CSS classes into an array
$exclude_class = in_array( "gf_exclude", $class_array ); //returns TRUE if 'gf_exclude' is found in the array
if ( $merge_tag == "all_fields" && $exclude == true && $exclude_class == true )
return false;
@PaulKinlan
PaulKinlan / criticalcss-bookmarklet-devtool-snippet.js
Last active April 2, 2024 02:45
CriticalCSS Bookmarklet and Devtool Snippet.js
(function() {
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {};
var css = {};
var pushCSS = function(r) {
if(!!css[r.selectorText] === false) css[r.selectorText] = {};
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for(var i = 0; i < styles.length; i++) {
if(!!styles[i] === false) continue;
var pair = styles[i].split(": ");
@sareiodata
sareiodata / empty-wp-plugin.php
Created July 2, 2014 08:45
Empty WordPress plugin
<?php
/**
* Plugin Name: Name Of The Plugin
* Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates
* Description: A brief description of the Plugin.
* Version: The Plugin's Version Number, e.g.: 1.0
* Author: Name Of The Plugin Author
* Author URI: http://URI_Of_The_Plugin_Author
* License: A "Slug" license name e.g. GPL2
*/
@Abban
Abban / WordPress Theme Customizer Sample.php
Created June 21, 2012 21:09
WordPress Theme Customizer Sample
<?php
function themename_customize_register($wp_customize){
$wp_customize->add_section('themename_color_scheme', array(
'title' => __('Color Scheme', 'themename'),
'priority' => 120,
));
// =============================
@robcalcroft
robcalcroft / createSha256CspHash.js
Created May 20, 2018 22:23
Create a sha256 hash of a string in Node.js to use in a CSP
const crypto = require('crypto');
function createSha256CspHash(content) {
return 'sha256-' + crypto.createHash('sha256').update(content).digest('base64');
}
@someguy9
someguy9 / generatepress-dark-mode.css
Last active May 6, 2022 12:23
Starter for adding darkmode to your Generatepress site
@media (prefers-color-scheme: dark) {
:root {
--contrast: #fff;
--contrast-2: #000;
--contrast-3: #000;
--base: #1e1e1e;
--base-2: #212121;
--base-3: #212121;
--accent: #1e90ff;
--global-color-8: rgba(180, 180, 191, 0.1);