Skip to content

Instantly share code, notes, and snippets.

@acunniffe
acunniffe / docs.md
Last active December 1, 2021 17:03
Using "@useoptic/openapi-utilities" to produce changelogs

At Optic we work with a lot of different kinds of diffs. We call a diff between traffic and a spec, a "diff" and a diff between two versions of an OpenAPI document a "changelog"

Optic CI rules take advantage of this pipeline, which, also can support producing changelogs between any two OpenAPI files

  1. reads your disk / git repo to get the full spec, with all refs resolved
  2. compute facts about the API specification that are true, independent of formatting, ordering, etc. Notice how if you change the order of Operations in optic-ci there's no changelog, even though there's a git diff. This is essential to making a real changelog, that works across a variety of use cases
  3. facts are then compared to produce changes
  4. Optic CI Rules look for changes they care about and execute to give you results

If you stop at step 3, you have a changelog between the two files.

@sindresorhus
sindresorhus / esm-package.md
Last active June 1, 2024 19:35
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@aaronkjones
aaronkjones / k8s-pi.md
Last active June 11, 2020 08:08 — forked from alexellis/k8s-pi.md
K8s (v1.10.2) on Raspbian (April 2018)

Kubernetes on (vanilla) Raspbian Lite

Yes - you can create a Kubernetes cluster with Raspberry Pis with the default operating system called Raspbian. This means you can carry on using all the tools and packages you're used to with the officially-supported OS.

Pre-reqs:

  • You must use an RPi 2 or 3 for use with Kubernetes
  • I'm assuming you're using wired ethernet (Wi-Fi also works, but it's not recommended)
@primaryobjects
primaryobjects / commit.png
Last active May 31, 2023 09:34
How to setup prettier as a pre-commit hook for Git commits.
commit.png
@mrded
mrded / benchmark.sh
Created February 10, 2017 17:59
Simple wrapper around Apache benchmark
#!/bin/bash
# Copy into /usr/local/bin/benchmark
# Give permissions: chmod +x /usr/local/bin/benchmark
# Usage: `benchmark http://example.com`
ab -n20 -c1 $1 | grep 'Requests per second\|Time per request\|Transfer rate\|Total transferred'
@brickpop
brickpop / index.js
Last active May 5, 2017 11:08
Build ng-admin with Webpack
// CSS
require('../node_modules/ng-admin/build/ng-admin.min.css');
// ALL IN ONE
require('ng-admin/build/ng-admin-only.min');
// JS
// var angular = require('angular/angular.min.js');
require('angular-ui-bootstrap/dist/ui-bootstrap-tpls.js');
require('angular-bootstrap/ui-bootstrap.min');
@mrded
mrded / foo.php
Last active April 15, 2016 04:59
Drupal 7 - Useful hook_update_N
<?php
/**
* Uninstall modules.
*/
function foo_update_7001() {
module_disable(array('module1', 'module2'));
drupal_uninstall_modules(array('module1', 'module2'));
}
<?php
function build_some_render_array($field) {
$build = array(); // Drupal render array
// more stuff happens here
$entity = $field['entity'];
$entity_wrapper = entity_metadata_wrapper('node', $entity);
@alex-kirienko
alex-kirienko / Drupal_form_attach_field.php
Created January 29, 2016 15:11
Drupal form attach one field
<?php
function wj_users_reg_interests_form($form = array(), &$state) {
$account = user_load($GLOBALS['user']->uid);
field_attach_form('user', $account, $form, $state, NULL, array('field_name' => 'field_interests'));
// Add submit button.
$form['actions'] = array(
'#type' => 'actions',
'submit' => array(
'#type' => 'submit',
@mrded
mrded / backup.sh
Created January 18, 2016 20:22
Drupal: backup script
#!/bin/bash
USER='root'
PASS='root'
DATABASE='drupal'
# Create folders if it's not yet.
mkdir -p ~/backups/{database,files}
# Backup.