Skip to content

Instantly share code, notes, and snippets.

View jorgeborges's full-sized avatar
🤖
[WORKING]

George A. Borges jorgeborges

🤖
[WORKING]
View GitHub Profile

Pragmatic Paranoia

This chapter is about defensive coding practices, both against users of your software and against yourself. Pragmatic Programmers, after all, understand that everyone makes mistakes, even themselves.

Design by Contract

This confused the shit out of me. I wasn't entirely sure what the difference was between a contract and a unit test.

Contracts are introduced in the context of employment contracts. That is, before any work is done, the responsibilities of both parties are defined, as well as the consequences of failing. Contracts in programming are similar. As I mentioned before, I wasn't able to make a strong distinction between contracts and unit tests (given some condition, when some event, then this should happen, though I may be confusing this with [BDD][bdd]). It's all a bit jumbled in my head.

@jorgeborges
jorgeborges / auto-ts-ignore.ts
Created February 11, 2023 07:30 — forked from zorji/auto-ts-ignore.ts
A script to auto add // @ts-ignore to lines with TypeScript compilation error
/**
* A script to auto add // @ts-ignore to lines with TypeScript compilation error
* Example usage:
* $ npx tsc > compilation-errors.log
* $ npx ts-node auto-ts-ignore.ts compilation-errors.log
*/
import { readFile, writeFile } from 'fs/promises'
const errorLogFile = process.argv[2]
@jorgeborges
jorgeborges / README.md
Created January 7, 2023 03:53 — forked from koshatul/README.md
use Apple Keychain to store GPG Passphrases

gpg-agent setup

Need to setup gpg-agent first, on OSX I use keychain (it also does ssh-agent)

$ brew info keychain
keychain: stable 2.8.5
User-friendly front-end to ssh-agent(1)
https://www.funtoo.org/Keychain
/usr/local/Cellar/keychain/2.8.5 (7 files, 108.5KB) *

Installing Brew

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Installing MSSQL Tools

brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
@jorgeborges
jorgeborges / levelsio-by.html
Created December 6, 2020 07:35 — forked from levelsio/levelsio-by.html
Maker Link (aka the @levelsio by link)
<!-- Maker Link by @levelsio -->
<!-- MIT License -->
<style>
body {
background:#333;
}
.levelsio-by {
font-family:"Helvetica Neue",sans-serif;
right:0;
@jorgeborges
jorgeborges / Makefile
Created June 16, 2020 01:55 — forked from benrowe/Makefile
Add a help target to a Makefile that will allow all targets to be self documenting
.PHONY: help
# COLORS
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
RESET := $(shell tput -Txterm sgr0)
TARGET_MAX_CHAR_NUM=20
@jorgeborges
jorgeborges / unistore.js
Created October 5, 2017 08:22 — forked from developit/unistore.js
dead simple centralized state container ("store"), with preact bindings.
import { h, Component } from 'preact';
/** Creates a new store, which is a tiny evented state container.
* @example
* let store = createStore();
* store.subscribe( state => console.log(state) );
* store.setState({ a: 'b' }); // logs { a: 'b' }
* store.setState({ c: 'd' }); // logs { c: 'd' }
*/
### Keybase proof
I hereby claim:
* I am jorgeborges on github.
* I am jorgeborges (https://keybase.io/jorgeborges) on keybase.
* I have a public key ASBpqki1l5k6V5LJE--Bh3vc1rxYx0v8wrY2HuVIJ_Uncwo
To claim this, I am signing this object:
@jorgeborges
jorgeborges / fix-homebrew-npm.md
Last active September 3, 2015 05:52 — forked from DanHerbert/fix-homebrew-npm.md
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

Fixing npm On Mac OS X for Homebrew Users

If you just want to fix the issue quickly, scroll down to the "solution" section below.

Explanation of the issue

If you're a Homebrew user and you installed node via Homebrew, there is a major philosophical issue with the way Homebrew and NPM work together. If you install node with Homebrew and then try to do npm update npm -g, you may see an error like this:

$ npm update npm -g
#!/bin/sh
#Example for unix like systems
# NOTE: Erlang must be already installed
# Download:
wget http://www.rabbitmq.com/releases/rabbitmq-server/v1.7.2/rabbitmq-server-generic-unix-1.7.2.tar.gz
# Untar:
tar -xzvf rabbitmq-server-generic-unix-1.7.2.tar.gz