Skip to content

Instantly share code, notes, and snippets.

@grncdr
grncdr / 00-Readme.md
Last active March 3, 2023 05:57
Delete unused assets

Delete unused assets

This is an example script for deleting assets that aren't linked in your content model. It does this by walking through all assets and checking for any links back to them.

WARNING: This script does not take into account assets that are only linked inside of Text fields. If you primarily embed images directly using the markdown editor, this will very likely delete assets you depend on.

You must fill in your own CMA access token & space ID at the top before running

Usage

@grncdr
grncdr / data.csv
Created June 17, 2015 22:29
Demo of importing a CSV file into a Contentful space
first name last name age
Stephen Sugden 31
Tom Reznik 29
Justin Thomas 30
@grncdr
grncdr / protected-ipfs-api.md
Last active August 29, 2015 14:22
Ideas about using IPFS from browsers

@ehd and myself have been playing around with a concept that is sort of like an ipfs-backed-in-browser-code-editor-and-live-coding-environment.* For this to work properly the browser clearly needs access to IPFS. Luckily there is a nice API! Unfortunately, it defaults to disallowing CORS.

I'm aware of API_ORIGIN and ipfs/kubo#1215, but that approach requires the user to understand a lot of stuff: environment variables, IPFS, CORS, and other 4-letter-initialisms to make it work. This is way too high of a barrier for anybody but the most committed tech-savvy user. It also subtly encourages allowing too broad of access (e.g. allow origin of *), which is pretty sketchy in my opinion.

I'd like to propose that the IPFS API offer a more holistic approach to this problem, and will even dust off my pre-1.0 golang skills to implement it if people agree...

* I'll leave it up to him to present the proper German compound word 😉

Proposal: "Protected" API

@grncdr
grncdr / -
Created February 28, 2015 19:35
## THIS FILE IS MANAGED BY CHEF !
## ALL CHANGES WILL BE LOST !
storage: /var/lib/sinopia
users:
admin:
password: d033e22ae348aeb5660fc2140aec35850c4da997
stephen:
password: 50f549c3f7508d8a442df7979dabe656e28bea24
@grncdr
grncdr / echoHttpRequest.js
Created November 9, 2014 15:14 — forked from Marak/echoHttpRequest.js
Echo HTTP requests
require('bluebird');
module['exports'] = function echoHttp (hook) {
hook.debug("Debug messages are sent to the debug console");
hook.debug(hook.params);
hook.debug(hook.req.path);
@grncdr
grncdr / contentful2gengo.js
Last active August 29, 2015 14:09
Turn Contentful webhooks into Gengo jobs
var Bluebird = require('bluebird');
var createContentfulClient = require('contentful-management').createClient;
var createGengoClient = require('gengo');
var collectStream = Bluebird.promisify(require('collect-stream'));
var keys = Object.keys;
module.exports = checkForUntranslatedFields;
module.exports.schema = {
cmaAccessToken: {
@grncdr
grncdr / mergeHooks.js
Last active August 29, 2015 14:09 — forked from Marak/mergeHooks.js
Merge multiple Hooks into a single Hook
var http = require('http');
module['exports'] = function recieveHttp (hook) {
var hook2 = hook.open('http://hook.io/Marak/echo?foo=bar');
var hook3 = hook.open('http://hook.io/Marak/echo');
var hooks = 2;
function complete() {
@grncdr
grncdr / hook.js
Last active August 29, 2015 14:08
Collect untranslated fields in a contentful entry and forward them elsewhere.
var hyperquest = require('hyperquest');
module.exports = checkForUntranslatedFields;
module.exports.schema = {
access_token: 'string',
translation_url: 'string',
space_id: 'string',
entry_id: 'string'
};
@grncdr
grncdr / formatter.js
Created November 7, 2014 22:58
Prototype of formatter for tcomb errors
'use strict';
var xtend = require('xtend');
var op = require('object-path');
var isMeta = /^meta\./;
module.exports = function formatErrors (errors, options) {
options = options || {};
var byPath = options.paths || {};
var byType = options.types || {};
@grncdr
grncdr / why-wont-you-die.js
Created October 4, 2014 16:17
Sometimes it's hard to know who's keeping your process alive
var timeouts = [];
var intervals = [];
var sockets = [];
var setTimeout_ = setTimeout;
var clearTimeout_ = clearTimeout;
var setInterval_ = setInterval;
var clearInterval_ = clearInterval;
var Socket = require('net').Socket;
var emit = Socket.prototype.emit;