Skip to content

Instantly share code, notes, and snippets.

@chrishoffman
chrishoffman / pki-setup.sh
Last active July 19, 2023 15:52
Vault Multi-Level CA Setup
vault mount pki
vault mount -path=pki1 pki
vault mount -path=pki2 pki
vault mount -path=pki3 pki
vault mount-tune -max-lease-ttl=87600h pki
vault mount-tune -max-lease-ttl=87600h pki1
vault mount-tune -max-lease-ttl=87600h pki2
vault mount-tune -max-lease-ttl=87600h pki3
vault write pki/root/generate/internal common_name="Vault Testing Root Authority" ttl=87600h
@bendc
bendc / interval.js
Created August 18, 2016 20:28
Better setInterval
const interval = (callback, delay) => {
const tick = now => {
if (now - start >= delay) {
start = now;
callback();
}
requestAnimationFrame(tick);
};
let start = performance.now();
requestAnimationFrame(tick);
@poteto
poteto / cp-macro.js
Created March 11, 2016 21:30
When you don't know what keys to observe for a CP, you can use a macro that determines the keys at runtime.
export default function makeComputed(objKey) {
let keys = Object.keys(get(this, objKey))
.filter((key) => {
// choose the keys using some logic
})
.map((key) => `${objKey}.${key}`);
return computed(...keys, {
get() {
// do stuff
@sebmarkbage
sebmarkbage / Enhance.js
Last active February 10, 2025 06:23
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@max-mapper
max-mapper / readme.md
Last active August 29, 2015 14:07
Node >= 0.10 Streams2 protips

@mafintosh said most of this, I just wrote it down

how to destroy/end streams in node >= 0.10

  • usually you call .destroy() if it has .destroy
  • if it doesnt have .destroy you are out of luck and the stream should upgrade to use e.g. newer through2
  • in request you call .abort() (this should get fixed to use .destroy())
  • .end() tries to end the stream gracefully

what about close

@johanobergman
johanobergman / 1. description.txt
Last active September 29, 2015 22:37
Sections in Ember.js components.
Simply register the two helpers "section" and "yield-section", and start right away!
See example below, using ember-cli:

Stuff you can do in Canvas JSX files

JSX

function foo(paths) {
  return <svg>{paths}</svg>;
}
@staltz
staltz / introrx.md
Last active May 9, 2025 12:50
The introduction to Reactive Programming you've been missing
@praxxis
praxxis / gist:88d156af12b26a6d9225
Created June 10, 2014 21:54
Sinon useFakeTimers and Ember
test('creates a local creation time property when saving', function () {
expect(1);
var now = new Date().getTime(),
clock = sinon.useFakeTimers(now),
model = App.Model.create(),
promise = Em.RSVP.resolve(),
superStub = sinon.stub(model, '_super').returns(promise);
model.save().then(function () {