Skip to content

Instantly share code, notes, and snippets.

Avatar

Mandi Wise mandiwise

  • Edmonton, Canada
View GitHub Profile
View sass_and_less_compared.markdown

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.

Variables

@niallo
niallo / gist:3109252
Created Jul 14, 2012
Parse Github `Links` header in JavaScript
View gist:3109252
/*
* parse_link_header()
*
* Parse the Github Link HTTP header used for pageination
* http://developer.github.com/v3/#pagination
*/
function parse_link_header(header) {
if (header.length == 0) {
throw new Error("input must not be of zero length");
}
View FileUploadDataSource.js
import { RemoteGraphQLDataSource } from '@apollo/gateway';
import { fetch, Request, Headers } from 'apollo-server-env';
import { isObject } from '@apollo/gateway/dist/utilities/predicates';
import FormData from 'form-data';
import _ from 'lodash';
export default class FileUploadDataSource extends RemoteGraphQLDataSource {
async process(args) {
const { request, context } = args;
@tommcfarlin
tommcfarlin / add-custom-post-type-menu.php
Created Apr 25, 2013
[WordPress] Add a custom post type menu as a child of an existing custom post type menu.
View add-custom-post-type-menu.php
<?php
// Define the 'Portfolio' post type. This is used to represent galleries
// of photos. This will be our top-level custom post type menu
$args = array(
'labels' => array(
'all_items' => 'Gallery',
'menu_name' => 'Portfolio',
'singular_name' => 'Gallery',
'edit_item' => 'Edit Gallery',
@scottopolis
scottopolis / wp-api-user-meta.php
Last active Apr 18, 2020
Add user meta to the WP-API
View wp-api-user-meta.php
<?php
/* Adds all user meta to the /wp-json/wp/v2/user/[id] endpoint */
function sb_user_meta( $data, $field_name, $request ) {
if( $data['id'] ){
$user_meta = get_user_meta( $data['id'] );
}
if ( !$user_meta ) {
return new WP_Error( 'No user meta found', 'No user meta found', array( 'status' => 404 ) );
}
@budparr
budparr / jekyll-collections-prev-next.html
Last active Feb 21, 2020
Previous Next Links for Jekyll Collections
View jekyll-collections-prev-next.html
{% capture the_collection %}{{page.collection}}{% endcapture %}
{% if page.collection %}
{% assign document = site[the_collection] %}
{% endif %}
<h1>TITLE: {{ page.title }}</h1>
{% for links in document %}
{% if links.title == page.title %}
{% unless forloop.first %}
{% assign prevurl = prev.url %}
{% endunless %}
@spivurno
spivurno / gw-gravity-forms-random-field-order.php
Last active Apr 16, 2019
Gravity Wiz // Gravity Forms // Random Field Order
View gw-gravity-forms-random-field-order.php
<?php
/**
* Gravity Wiz // Gravity Forms // Random Fields
*
* Randomly display a specified number of fields on your form.
*
* @version 1.1
* @author David Smith <david@gravitywiz.com>
* @license GPL-2.0+
* @link https://gravitywiz.com/random-fields-with-gravity-forms/
@crondeau
crondeau / chilpages-looping.php
Last active Nov 2, 2018
I used this code to loop through child pages of a custom post type called work. Each Work piece had a title, featured image and pdf. The child pages, describe the details of the project or work piece and display as an accordion. So basically what we have is an accordion within an accordion.
View chilpages-looping.php
<?php
// loop through the sub-pages of your custom post type
$childpages = new WP_Query( array(
'post_type' => 'work',
'post_parent' => $this_page,
'posts_per_page' => 100,
'orderby' => 'menu_order'
));
while ( $childpages->have_posts() ) : $childpages->the_post(); ?>
@nachiket-p
nachiket-p / meteor_servercall.html
Created Jun 21, 2012
Meteor: Calling server method from client
View meteor_servercall.html
<head>
<title>meteor_servercall</title>
</head>
<body>
{{> simple}}
{{> passData}}
</body>
<template name="simple">
@annalinneajohansson
annalinneajohansson / order_by_multiple_meta_values.php
Last active Jan 17, 2018
Solution to order posts by two different meta values (the same way ORDER val1, val2 would with SQL) http://wordpress.stackexchange.com/a/67391/5045
View order_by_multiple_meta_values.php
<?php
/*
* Solution to order first by date, then by start time (both are meta values)
* http://wordpress.stackexchange.com/a/67391/5045
* */
add_action( 'pre_get_posts', 'pre_get_posts_programpunkter' );
function pre_get_posts_programpunkter( $query ) {
if( !is_admin() && is_post_type_archive( 'programpunkt' ) && $query->is_main_query() ) {
You can’t perform that action at this time.