Skip to content

Instantly share code, notes, and snippets.

View AGhost-7's full-sized avatar
🤖
Discombobulating the hive mind

Jonathan Boudreau AGhost-7

🤖
Discombobulating the hive mind
  • The land of maple syrup
View GitHub Profile
@AGhost-7
AGhost-7 / lazy-iterator.js
Last active November 30, 2020 23:41
Example of a lazy collection which only creates one new array even with multiple combinator calls
const assert = require('assert');
class BaseIter {
map(fn) {
return new MapIter(this, fn);
}
filter(fn) {
return new FilterIter(this, fn);
}
collect() {
import http from './http.mjs';
const createRecipe = http.createRecipe();
createRecipe.request({
name: 'Dhal',
author: 'AGhost-7'
});
if (createRecipe.loading) {
@AGhost-7
AGhost-7 / ssd-scrub.md
Last active December 23, 2019 04:44
How to clear your ssd

For some reason you need to set a password to use hdparm:

hdparm --user-master u --security-set-pass PASS /dev/sdx

And then the actual command:

hdparm --user-master u --security-erase PASS /dev/sdx
openapi: "3.0.0"
info:
title: Leaps of Sounds
version: 2.0.0
paths:
/scales:
get:
summary: List all scales
parameters:
- name: system
@AGhost-7
AGhost-7 / unprivileged.c
Last active December 19, 2018 14:46
Strip supplementary groups from new process (requires setuid)
/*
* Removes supplementary groups (e.g., sudo and docker) of the current process
* then uses `exec` to make a different program take over the process. This
* allows me to run certain programs (such as npm) with lowered permissions.
*
* Note that this requires the container option `--cap-add SETGID` to work.
* It will fail silently and simply exec the program otherwise.
*
* For example:
* alias npm='unpriviledged npm'
#include <stdlib.h>
#include <stdint.h>
#include <stddef.h>
struct history_record {
uint8_t line;
uint8_t column;
char * characters;
};
describe('delegate', () => {
let lastArgs, delegated;
before(() => {
const handler = (args) => {
lastArgs = args;
return args.cmd === 'save' ? args.ent : [];
};
seneca.add({
@AGhost-7
AGhost-7 / vimrc
Created April 3, 2018 02:46
Simple vimrc for containers
syntax on
set nocompatible autoindent wildmenu incsearch mouse=2 tabstop=2
'use strict'
const _ = require('lodash')
const teams = _.range(1, 20)
const chunkSize = 5
const {groupings} = _(teams)
.map((team) => ({ number: team, order: Math.random() }))
.sortBy('order')
@AGhost-7
AGhost-7 / migrations-are-trees.md
Last active December 21, 2017 03:33
Migrations are not sequential

Migrations are trees.

Migration #1:

create table user(
  id text,
  name text,
  password bytea
);