Skip to content

Instantly share code, notes, and snippets.

@monachilada
monachilada / gatsby-config.js
Last active October 16, 2020 19:03
Sample gatsby-config.js enabling live preview in Craft CMS
const { createHttpLink } = require('apollo-link-http');
const fetch = require('node-fetch');
const store = require('store');
const sourceNodes = require('gatsby/dist/utils/source-nodes');
require('dotenv').config();
const craftGqlUrl = process.env.CRAFT_GQL_URL;
const craftGqlToken = process.env.CRAFT_GQL_TOKEN;
module.exports = {

Namespace your flux action types to prevent collisions:

function constants(namespace, constants) {
  return Object.freeze(
    constants.reduce((obj, constant) => {
      return {
        ...obj,
        [constant]: `${namespace}/${constant}`
 }
@xjamundx
xjamundx / blog-webpack-2.md
Last active November 7, 2024 13:10
From Require.js to Webpack - Part 2 (the how)

This is the follow up to a post I wrote recently called From Require.js to Webpack - Party 1 (the why) which was published in my personal blog.

In that post I talked about 3 main reasons for moving from require.js to webpack:

  1. Common JS support
  2. NPM support
  3. a healthy loader/plugin ecosystem.

Here I'll instead talk about some of the technical challenges that we faced during the migration. Despite the clear benefits in developer experience (DX) the setup was fairly difficult and I'd like to cover some of the challanges we faced to make the transition a bit easier.

@hiddentao
hiddentao / gist:5946053
Last active November 13, 2018 18:18
Generate overridable getters and setters in Javascript
// see blog post: http://www.hiddentao.com/archives/2013/07/08/generate-overridable-getters-and-setters-in-javascript/
Function.prototype.generateProperty = function(name, options) {
// internal member variable name
var privateName = '__' + name;
options = options || {};
options.get = ('undefined' === typeof options.get ? true : options.get );
options.set = ('undefined' === typeof options.set ? true : options.set );
// pre-initialise the internal variable?
@devgeeks
devgeeks / bugherd-config-api-rfc.md
Created October 19, 2012 01:44
RFC - BugHerd Configuration API

This is a request for comment - this is a proposed configuration API for the BugHerd Public Feedback and Sidebar

The BugHerd sidebar can be configured to override some of its default behaviour as well as display extra information in any tasks that you pass in from a configuration object called BugHerdConfig.

When setting up BugHerd for the first time, you probably already know you need to add the following code to your site:

  <script type="text/javascript">
    (function (d, t) {
      var bh = d.createElement(t), s = d.getElementsByTagName(t)[0];