Skip to content

Instantly share code, notes, and snippets.

View ORESoftware's full-sized avatar
🏐
Focusing

Alexander Mills ORESoftware

🏐
Focusing
View GitHub Profile

ctrlaltshiftp

@ORESoftware
ORESoftware / init.md
Created February 11, 2020 05:56
initializing vars in Golang

In this simple golang example it appears that we don't need to initialize the wg variable. Why do we do this:

var wg sync.WaitGroup
func main() {
        // do some stuff
        wg.Wait()  //     // blocks/waits for waitgroup
}
@ORESoftware
ORESoftware / private.md
Last active August 13, 2022 17:55
reading private struct field

Currently I am getting this error when I attempt to read a private value of a struct using the reflect package:

panic: reflect.Value.Interface: cannot return value obtained from unexported field or method

So, yeah want to read the private value of a struct:

type Foo struct {
 thisIsPrivate string
@ORESoftware
ORESoftware / app.md
Created February 6, 2020 20:13
404 vs 405 vs 501

Your API server should respond with a 405 or 501 status code, not a 404 (When a route handler is missing)

// catch 501 and forward to error handler
app.use((req, res, next) => {
  const err = new Error('Not implemented.');
 err.status = 501;
@ORESoftware
ORESoftware / print.bash
Created February 5, 2020 20:15
re-using the same node process to interpret and print strings
#!/bin/bash
cm_env_exp() {
rm -rf /tmp/srv-input
mkfifo /tmp/srv-input
rm -rf /tmp/srv-output
mkfifo /tmp/srv-output
@ORESoftware
ORESoftware / old-way.md
Last active February 5, 2020 18:13
The old way of creating private fields/methods

The old way of creating private class data in JS prior to ES6:

export class MyClass {
  
 constructor(){
   
   const privateField = {};
   const privateMethod = () => {
 return privateField;
@ORESoftware
ORESoftware / using-symbols.md
Last active February 5, 2020 18:12
private methods and fields with JS

The optimal way to create private data on a class:

'use strict';

const privateField = Symbol('private field: for debugging')
const privateMethod = Symbol('private method: this name is just for debugging');

export class MyClass1 {
@ORESoftware
ORESoftware / gsutil_help_cp_output.out
Created January 24, 2020 20:35
Output of `gsutil help cp`
NAME
cp - Copy files and objects
SYNOPSIS
gsutil cp [OPTION]... src_url dst_url
gsutil cp [OPTION]... src_url... dst_url
gsutil cp [OPTION]... -I dst_url
@ORESoftware
ORESoftware / cluster.log
Last active September 10, 2019 03:04
docker-compose logs for mongodb cluster
Attaching to rydell-mongo-config-03, rydell-mongo-config-02, rydell-mongo-config-01, rydell-shard-03-node-a, rydell-shard-01-node-a, rydell-shard-02-node-a, rydell-router-02, rydell-router-01, rydell-shard-03-node-b, rydell-shard-01-node-b, rydell-shard-02-node-b, rydell-shard-02-node-c, rydell-shard-03-node-c, rydell-shard-01-node-c
rydell-mongo-config-02 | 2019-09-10T02:57:20.550+0000 I STORAGE [main] Max cache overflow file size custom option: 0
rydell-mongo-config-02 | 2019-09-10T02:57:20.552+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
rydell-mongo-config-02 | 2019-09-10T02:57:20.555+0000 I CONTROL [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/configdb 64-bit host=c569f8378ff2
rydell-mongo-config-02 | 2019-09-10T02:57:20.555+0000 I CONTROL [initandlisten] db version v4.0.12
rydell-mongo-config-02 | 2019-09-10T02:57:20.555+0000 I CONTROL [initandlisten] git version:
@ORESoftware
ORESoftware / using-extra-fd.md
Last active August 26, 2019 06:03
Stdout/stderr for writing between procs can be faulty if extra stdio is included

Here is some node.js code:

#!/usr/bin/env node

const fs = require('fs');

const header = '#!/usr/bin/env bash\n\n';
try {
 const bytes = fs.writeSync(3, header, 0);