a
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Script to generate S3 signed URLs for image files in JSONL format | |
| # Usage: ./generateS3SignedUrls.sh <s3-path> [output-file] [expiration-seconds] [parallel-jobs] | |
| # Or with curl: | |
| # curl -fsSL https://gist.github.com/tonylampada/20b7bc984a455f53e2d07f88b33bf43c/raw/generateS3SignedUrls.sh | bash -s -- s3://bucket/path output.jsonl | |
| set -e | |
| # Check if S3 path is provided |
As I gained experience in building software, I realized a fundamental distinction between two types of code, which in my mind, I refer to as:
- "plumbing" code, vs
- "intelligence" code.
I want to explain this duality because I believe it assists in cultivating a programming mindset that tends to produce quality software (*).
À medida que eu fui ganhando experiência construindo software, percebi uma distinção fundamental entre dois tipos código, que, na minha cabeça, eu chamo de:
- código de "encanamento", vs
- código de "inteligência".
Vou explicar essa dualidade porque eu acredito que ela ajuda ter um mindset de programação que tende a gerar software de qualidade (*).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ////////////////////////////////////////////////////////////////////// | |
| // surface: handling http requests for login | |
| // "app" is an express application | |
| // "authenticationService" is a service that knows how to authenticate users | |
| app.use(loggingMiddleware); | |
| app.use(handleUnknownErrorsMiddleware); | |
| app.post('/api/login', reqLogin); | |
| function loggingMiddleware(req, res, next) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // web framework | |
| function webapp() { | |
| return { | |
| handlers: {}, | |
| addRoute(route, fn){ | |
| this.handlers[route] = fn; | |
| }, | |
| exec(route, params){ | |
| const handler = this.handlers[route]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // web framework | |
| function webapp() { | |
| return { | |
| handlers: {}, | |
| addRoute(route, fn){ | |
| this.handlers[route] = fn; | |
| }, | |
| async exec(route, params){ | |
| const handler = this.handlers[route]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const express = require("express"); | |
| const request = require("supertest"); | |
| async function sleep(ms) { | |
| return new Promise((r) => setTimeout(r, ms)); | |
| } | |
| function _500errosync(req, res) { | |
| throw new Error("Test error"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //real api | |
| var api = { | |
| list_cameras: list_cameras, | |
| //other methods… | |
| }; | |
| function list_cameras(filters){ | |
| return AppAjax.get(‘/api/list_cameras’, {filters: angular.toJson(filters)}); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //mock api | |
| var api = { | |
| list_cameras: _mockpromise(list_cameras), | |
| //other methods… | |
| }; | |
| function list_cameras(filters){ | |
| return [ | |
| {name: ‘Camera do BBB’}, | |
| {name: ‘Camera 17’} | |
| ]; |
NewerOlder