Skip to content

Instantly share code, notes, and snippets.

// node --max-old-space-size=8192 test-_id-random-lookup.js
var fs = require('node:fs');
var numDocs = 1e6;
async function main() {
var { MongoClient, ObjectId } = require('mongodb');
var client = await MongoClient.connect('mongodb://localhost:27017/test');
console.log('Connected');
var db = client.db('testing');
try {
[Unit]
Description=service that simply pipes certain docker events to logs
[Service]
ExecStart=/usr/local/bin/docker-events-to-logs.sh
Restart=on-failure
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
terraform {
required_version = ">= 0.14.9"
}
variable "random" {
type = number
}
module "my_animal_module" {
source = "./my-animal-module"
@sgpinkus
sgpinkus / main.tf
Last active September 23, 2021 21:24
terraform destroy gives "Error: The terraform-provider-aws_v3.59.0_x5 plugin crashed!"
2021-09-24T07:17:39.305+1000 [DEBUG] Adding temp file log sink: /tmp/terraform-log410799907
2021-09-24T07:17:39.305+1000 [INFO] Terraform version: 1.0.6
2021-09-24T07:17:39.305+1000 [INFO] Go runtime version: go1.16.4
2021-09-24T07:17:39.305+1000 [INFO] CLI args: []string{"/usr/bin/terraform", "destroy", "-auto-approve", "-target=module.eks"}
2021-09-24T07:17:39.305+1000 [DEBUG] Attempting to open CLI config file: /home/sam/.terraformrc
2021-09-24T07:17:39.305+1000 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2021-09-24T07:17:39.305+1000 [INFO] Loading CLI configuration from /home/sam/.terraform.d/credentials.tfrc.json
2021-09-24T07:17:39.305+1000 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2021-09-24T07:17:39.305+1000 [DEBUG] ignoring non-existing provider search directory /home/sam/.terraform.d/plugins
2021-09-24T07:17:39.305+1000 [DEBUG] ignoring non-existing provider search directory /home/sam/.local/share/terraform/plugins

Overview

This document provides a brief numerical analysis of the use of the JSON Schema $id keyword in schema documents contained in the schemastore.org collection. Scripts to generate stats are attached.

Overview Statisitics

TOTAL FILES: 310
SCHEMAS USED:
      1 http://json-schema.org/draft-03/schema
      5 http://json-schema.org/draft/2019-09/schema
      6 http://json-schema.org/draft-06/schema
@sgpinkus
sgpinkus / both-dirs-try.html
Last active August 14, 2020 12:11
Example of how "infinite scroll" works out of the box.
<!DOCTYPE html>
<html>
<head>
<title>Simplified Infinite Scroll</title>
<meta charset="utf-8" />
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<style type='text/css'>
* { border: 0; padding: 0; margin: 0; box-sizing: border-box; }
html, body { height: 100%; }
body { display: flex; flex-flow: column wrap; }
# git clone git@github.com:sgpinkus/mime-db.git && cd mime-db && git checkout origin/add-mime-support
const db = require('./db');
const fs = require('fs');
const lodash = require('lodash');
let mimeSupport = lodash.pickBy(db, x => x.source === 'mime-support');
mimeSupport = Object.entries(mimeSupport).map(([k, v]) => { return { mime: k, ...v }; });
fs.writeFileSync('mime-support-additional.json', JSON.stringify(mimeSupport, null, 2));
import Foundation
enum Gender : String, Codable {
case M, F
}
struct User : Codable {
let name: String
let email: String
let gender: Gender
let verified: Bool
@sgpinkus
sgpinkus / mongoose-map.js
Created February 18, 2020 03:29
mongoose-map.js
var mongoose = require('mongoose');
var getTestConnection = require('./getTestConnection.js');
var UserSchema = new mongoose.Schema({
name: { type: String, required: true },
notes: {
type: Map,
of: String,
default: {},
}
''' Override certain function from built-in json module to allow formatting of JSON two container types
, arrays and objects, to be optionally specified separately by allowing `indent` to be a 2-tuple.
I copied this from Python 3.5.3 but looks about the same in 3.4-3.6. Probably wont work in >=3.7.
'''
def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
_key_separator, _item_separator, _sort_keys, _skipkeys, _one_shot,
## HACK: hand-optimized bytecode; turn globals into locals
ValueError=ValueError,
dict=dict,