Skip to content

Instantly share code, notes, and snippets.

View coolaj86's full-sized avatar
😎
🐹 Go 🦎 Zig 📦 Node 🐧 POSIX 🪟 PowerShell

AJ ONeal coolaj86

😎
🐹 Go 🦎 Zig 📦 Node 🐧 POSIX 🪟 PowerShell
View GitHub Profile
@coolaj86
coolaj86 / zen-of-java.md
Last active November 29, 2022 19:22
The Zen of Java

The Zen of Java

Turgid verbosity is better than brevity.
Multiple lines of code are better than concise simplicity.
Mid-1980’s software techniques are better than modern adaptable technology.
Many legacy libraries are better than clean organization.
Slow, costly development with large overhead is better than agility.
It’s better to type lots of soul-deadening crap having the grace of four-day old road kill than to quickly solve a problem.

~ Zen of Java

Node.js request

Same as

curl -X POST https://api.mercury.com/api/v1/submit-onboarding-data \
    -H 'Content-Type: application/json' \
    -H 'Accept: application/json' \
    -d '@./application.json'
{
"Header": {
"Time": "2022-09-14T12:20:17-07:00",
"ReportName": "ProfitAndLoss",
"ReportBasis": "Accrual",
"StartPeriod": "2022-06-01",
"EndPeriod": "2022-09-30",
"SummarizeColumnsBy": "Total",
"Currency": "USD",
"Customer": "1",
SHOW INDEXES FROM `room`;
--ALTER TABLE `room` DROP INDEX room_code_restriction_idx;
--ALTER TABLE `room` DROP INDEX room_user_restriction_idx;
ALTER TABLE `room` DROP FOREIGN KEY room_code_restriction_foreign;
ALTER TABLE `room` DROP FOREIGN KEY room_user_restriction_foreign;
ALTER TABLE `room` DROP COLUMN `code_restriction`;
ALTER TABLE `room` DROP COLUMN `user_restriction`;

JSDoc tsc Function Workaround

There's no documentation for this, but it just so happens that if you use the @callback alias some extra machinery kicks in and you can type functions as you would have expected.

/**
- * @typedef {Function} PersonGreet
+ * @callback PersonGreet
 * @param {String} name - other's name
 * @returns {String} - the greeting
function escapeHtml(str) {
// TODO more
return str
.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&lt;')
.replace(/'/g, '&#39;')
.replace(/"/g, '&quot;')
;
}
@coolaj86
coolaj86 / 00 - Example Code Samples for Screenshots & Thumbnails.md
Last active October 11, 2023 04:39
AJ's Code Snippets for Thumbnail Backgrounds

BogoSort Wins!

The for loop outperforms the binary search.
(well, the forEach did, until we changed the caching in an unrelated function)

And the optimizations have (almost) nothing to do with the algorithms.
(changing any code can massively change the performance of any benchmark)

See the video: https://www.youtube.com/watch?v=0mmi44ZB2C0

K&R Style

  • Required (but not enforced) for JavaScript
  • Required AND enforced for Go
function kr() {
  // foo
}