Skip to content

Instantly share code, notes, and snippets.

View jamesfacts's full-sized avatar

James White jamesfacts

View GitHub Profile
$hk-grotesk-path: '../fonts/hkgrotesk-';
$weights: 300, 400, 500, 600, 700, 800, 900;
@each $weight in $weights {
@font-face {
font-family: 'hk grotesk';
src: url('#{$hk-grotesk-path}#{$weight}-webfont.woff2') format('woff2'),
url('#{$hk-grotesk-path}#{$weight}-webfont.woff') format('woff');
font-weight: $weight;
font-style: normal;
const chalk = require('chalk')
const {join} = require('path')
const sharp = require('sharp')
const request = require('request')
const {GraphQLClient} = require('graphql-request')
const SITEURL = `http://kellymears.vagrant`
/**
* Process image
@Jany-M
Jany-M / wp_ics.php
Last active September 19, 2023 03:15 — forked from jakebellacera/ICS.php
[WP] Generate a downloadable .ics file from any WordPress post or custom post type
<?php
/*
For a better understanding of ics requirements and time formats
please check https://gist.github.com/jakebellacera/635416
*/
// UTILS
// Check if string is a timestamp
@Bobz-zg
Bobz-zg / redirect-wp-post.php
Last active April 12, 2023 09:37
Redirects wordpress posts to new url: site.com/blog/post-name
<?php
/**
* Add new rewrite rule
*/
function create_new_url_querystring() {
add_rewrite_rule(
'blog/([^/]*)$',
'index.php?name=$matches[1]',
'top'
);
@kerimdzhanov
kerimdzhanov / random.js
Last active September 21, 2024 11:44
JavaScript: get a random number from a specific range
/**
* Get a random floating point number between `min` and `max`.
*
* @param {number} min - min number
* @param {number} max - max number
* @return {number} a random floating point number
*/
function getRandomFloat(min, max) {
return Math.random() * (max - min) + min;
}
@kosinix
kosinix / custom-nav-walker-usage.php
Last active November 1, 2024 03:36
WordPress: Using a custom nav walker to create navigation menus in plain <a> tags. That is the <ul> and <li> tags are not present. Very useful if you want to create simple links that can be centered with a simple text-align:center on the containing element.
<?php
// In your template files like footer.php
// The items_wrap value ('%3$s') removes the wrapping <ul>, while the custom walker (Nav_Footer_Walker) removes the <li>'s.
wp_nav_menu(array('items_wrap'=> '%3$s', 'walker' => new Nav_Footer_Walker(), 'container'=>false, 'menu_class' => '', 'theme_location'=>'footer', 'fallback_cb'=>false ));
?>
@kingkool68
kingkool68 / rh-get-widget-data-for-all-sidebars.php
Last active February 15, 2021 03:51
WordPress function to get raw widget data for all of the widgets in a given sidebar
<?php
function rh_get_widget_data_for_all_sidebars() {
global $wp_registered_sidebars;
$output = array();
foreach ( $wp_registered_sidebars as $sidebar ) {
if ( empty( $sidebar['name'] ) ) {
continue;
}
$sidebar_name = $sidebar['name'];
@jakebellacera
jakebellacera / ICS.php
Last active October 11, 2024 10:58
A convenient script to generate iCalendar (.ics) files on the fly in PHP.
<?php
/**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*