Skip to content

Instantly share code, notes, and snippets.

View ipokkel's full-sized avatar

Theuns Coetzee ipokkel

View GitHub Profile
@jonathantneal
jonathantneal / README.md
Last active November 9, 2023 21:10
createElement.js // a 300 byte DOM Element creator

createElement.js

createElement.js lets document.createElement use CSS selectors.

This is a pretty useful library for building out DOM elements. The whole thing runs on one regex and a for loop, so it’s plenty fast. The script is 300 bytes when compressed and gzipped. For 524 bytes (advanced), it includes nesting support and can generate entire DOM hierarchies, including text nodes.

Usage

document.createElement(); // generates <div />
@quawn
quawn / getWorkingDays.php
Last active October 11, 2023 17:04
PHP: GetWorkingDays excluding weekend and holidays
<?php
function getWorkingDays($startDate,$endDate,$holidays) {
// do strtotime calculations just once
$endDate = strtotime($endDate);
$startDate = strtotime($startDate);
//The total number of days between the two dates. We compute the no. of seconds and divide it to 60*60*24
//We add one to inlude both dates in the interval.
$days = ($endDate - $startDate) / 86400 + 1;
@KittyGiraudel
KittyGiraudel / main.scss
Last active April 5, 2022 19:11
From: Architecturing a Sass project
// Sass utilities
@import "helpers/variables";
@import "helpers/functions";
@import "helpers/mixins";
@import "helpers/placeholders";
// Vendors and external stylesheets
@import "vendors/bootstrap";
@import "vendors/jquery-ui";
@ain
ain / Array.prototype.compare.js
Last active September 25, 2020 07:17
JavaScript compare() method for Array
Array.prototype.compare = function(array) {
if (!array) {
return false;
}
if (this.length !== array.length) {
return false;
}
for (var i = 0, l = this.length; i < l; i++) {
if (this[i] instanceof Array && array[i] instanceof Array) {
if (!this[i].compare(array[i])) {
@strangerstudios
strangerstudios / update_currency_per_level.php
Created February 4, 2014 15:59
Change currencies depending on Paid Memberships Pro level. Add this code to your active theme's functions.php or a custom plugin. This is just an example that will need to be tweaked for your needs.
/*
Change currencies depending on Paid Memberships Pro level.
Add this code to your active theme's functions.php or a custom plugin.
This is just an example that will need to be tweaked for your needs.
Other places to look into swapping currencies:
* Levels page.
* Invoices page.
* In emails.
* In membership levels table in admin.
@derekconjar
derekconjar / wordpress-firebase.php
Last active April 25, 2024 15:21
An example of using Firebase and WordPress together. The idea is to use WP's custom post types and metaboxes to make content management easy, and sync with Firebase so that your websites have access to a real-time JSON feed of your custom data.
<?php
/**
* All custom functions should be defined in this class
* and tied to WP hooks/filters w/in the constructor method
*/
class Custom_Functions {
// Custom metaboxes and fields configuration
@jonathantneal
jonathantneal / README.md
Last active January 30, 2020 10:42
Simulating Element Queries

Simulating Element Queries

Until real element queries show up in a specification or a browser, these are the simulated techniques that I’m aware of. Am I missing others? Let me know.

Evaluating the pros and cons of each technique may help you decide which ones works best in your situation.

Technique #1: Window Resize Events

addEventListener('resize', function () {
@kamikat
kamikat / trig.scss
Last active December 7, 2023 12:50
SCSS/SASS module calculating sin/cos/tan using Taylor Expansion.
///////////////////////////////////////////////////////////
// Plain SASS Trigonometry Algorithm in Taylor Expansion //
// //
// Based on //
// http://japborst.net/posts/sass-sines-and-cosines //
///////////////////////////////////////////////////////////
$pi: 3.14159265359;
$_precision: 10;
@hofmannsven
hofmannsven / README.md
Last active November 8, 2023 22:49
SCSS Cheatsheet
@strangerstudios
strangerstudios / my_pmpros_series_registration.php
Created October 20, 2014 14:11
Use a different slug with PMPro Series.
/*
Use a different slug with PMPro Series
If another plugin/page/category is conflicting on the "series" slug/keyword,
you can change the slug used by PMPro Series by adding this code
to your active theme's functions.php or a custom plugin.
Be sure to reset your rewrite rules by going to
Settings --> Permalink Settings in the WP admin dashboard
and then saving for this change to take affect.