Skip to content

Instantly share code, notes, and snippets.

View nsbingham's full-sized avatar

Nathan Bingham nsbingham

  • optional
  • United States
View GitHub Profile
@MelMacaluso
MelMacaluso / expose_ACF_fields_to_REST.php
Created June 4, 2019 22:54
Automatically expose all the ACF fields to the Wordpress REST API in Pages and in your custom post types.
<?php
function create_ACF_meta_in_REST() {
$postypes_to_exclude = ['acf-field-group','acf-field'];
$extra_postypes_to_include = ["page"];
$post_types = array_diff(get_post_types(["_builtin" => false], 'names'),$postypes_to_exclude);
array_push($post_types, $extra_postypes_to_include);
foreach ($post_types as $post_type) {
register_rest_field( $post_type, 'ACF', [
@gbalbuena
gbalbuena / superagent.js
Last active November 3, 2022 10:50 — forked from charleskorn/superagent.js
A Jest mock for superagent. Place in your __mocks__ directory.
llet mockDelay;
let mockError;
let mockResponse = {
get: jest.fn(),
ok: true,
status: 200,
toError: jest.fn(),
};
let mockResponseBodies;
@rtpHarry
rtpHarry / animation.js
Last active September 11, 2024 02:25
Three.js - play an AnimationAction in reverse. There are a bunch of threads saying this isn't possible but I found a way so I wanted to post it online in a place that people will hopefully stumble upon it.
// The class itself is based on the animation helper class in
// https://github.com/paulmg/ThreeJS-Webpack-ES6-Boilerplate
// but I have changed almost everything except for the class name and the update function.
import * as THREE from 'three';
export default class Animation {
constructor(scene, animations) {
this.scene = scene;
this.animations = animations;
@Hyperparticle
Hyperparticle / config.yml
Last active November 9, 2021 09:29
CircleCI 2.0 Jekyll build and Firebase deploy
### Taken from https://github.com/Hyperparticle/hyperparticle.github.io/blob/2365749469b1eea3e8c4b18af24a4865fc426fd3/.circleci/config.yml
# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2
jobs:
build:
docker:
@patrickkunka
patrickkunka / configuration-1.js
Last active November 17, 2022 02:15
Configuration Patterns
/**
* Configuration #1: Basic Configuration Class
*
* A basic example utilising a sealed instance of a configuration
* class, with user-provided options merged in upon instantation
* of the implementation.
*/
class Config {
constructor() {
@thorsten
thorsten / setUserAgent.js
Created May 9, 2016 15:12
Override user agent on all browsers
function setUserAgent(window, userAgent) {
// Works on Firefox, Chrome, Opera and IE9+
if (navigator.__defineGetter__) {
navigator.__defineGetter__('userAgent', function () {
return userAgent;
});
} else if (Object.defineProperty) {
Object.defineProperty(navigator, 'userAgent', {
get: function () {
return userAgent;
@ttscoff
ttscoff / gifsicle.sh
Last active November 25, 2015 16:36
% brew install gifsicle
# modify colors as needed, it will warn you if you specify more than necessary
% gifsicle --colors 128 -O3 -o output.gif input.gif
@lamchau
lamchau / ember-component-fadeout.js
Created August 17, 2015 19:53
`fadeIn` and `fadeOut` for Ember Component (ES6; ember-cli)
export default Ember.Component.extend({
fadeDurationInMilliseconds: 300,
didInsertElement() {
let duration = this.get("fadeDurationInMilliseconds"),
element = this.$();
element.fadeIn(duration);
},
@chrism
chrism / utils.preload-images.js
Created May 26, 2015 15:21
Preloading images using Ember.JS util
import Ember from 'ember';
var Promise = Ember.RSVP.Promise;
export default function preloadImages(...urls) {
let promises = urls.map(url => {
return new Promise((resolve, reject) => {
let image = new Image();
image.onload = resolve;
image.onerror = reject;
image.src = url;
@kristianmandrup
kristianmandrup / Converting libraries to Ember CLI addons.md
Last active April 21, 2023 17:14
Guide to Developing Addons and Blueprints for Ember CLI

Converting libraries to Ember CLI addons

In this guide we will cover two main cases:

  • Ember specific library
  • vendor library

Ember library

The Ember library will assume that Ember has already ben loaded (higher in the loading order) and thus will assume it has access to the Ember API.