Skip to content

Instantly share code, notes, and snippets.

View shri3k's full-sized avatar
🤖
automate all things

Yojan Shrestha shri3k

🤖
automate all things
  • Austin
View GitHub Profile
@wijayaerick
wijayaerick / slog_console_handler.go
Last active November 25, 2023 06:40
Example ConsoleHandler for golang.org/x/exp/slog Logger
// ConsoleHandler formats slog.Logger output in console format, a bit similar with Uber's zap ConsoleEncoder
// The log format is designed to be human-readable.
//
// Performance can definitely be improved, however it's not in my priority as
// this should only be used in development environment.
//
// e.g. log output:
// 2022-11-24T11:40:20+08:00 DEBUG ./main.go:162 Debug message {"hello":"world","!BADKEY":"bad kv"}
// 2022-11-24T11:40:20+08:00 INFO ./main.go:167 Info message {"with_key_1":"with_value_1","group_1":{"with_key_2":"with_value_2","hello":"world"}}
// 2022-11-24T11:40:20+08:00 WARN ./main.go:168 Warn message {"with_key_1":"with_value_1","group_1":{"with_key_2":"with_value_2","hello":"world"}}
@lelandbatey
lelandbatey / python_packaging_vs_golang_packaging_2021.md
Last active January 20, 2024 11:27
Python Packaging vs Golang Packaging: Breaking down the differences in terminology and what it means for you

Python Packaging vs Golang Packaging

The original question was:

But I'm not sure that the library name = "cp-compat-logs-logger" defined in pyproject.toml would work. I tried importing that in my httpclient library and it complained. Also, I see in the log_bridge library the logger is imported as from cp_compat_logs_logger.logger import Logger, but cp_compat_logs_logger is not the library name, so how is that working?

I think you've asked a totally valid question about "what's up with the names here?" The short answer is "Python has messy conventions, so the name you use to poetry install is different than the name you use in code when import name." It's conventional to have the poetry install (let's call this the "distribution name") use dashes as a delimiter. However, actual module names in Python cannot have dashes, so the name used in code during import name (let's call this the "module name") will (usually) use underscores in place of dashes.

@patrikbego
patrikbego / native-node-file-upload.js
Last active June 23, 2023 16:38
Native / pure / no-npm file upload REST API
/**
* This is native /pure /no-npm node.js file uploader.
*
* CLIENT FUNCTION: export function uploadFile(file) {
* fetch("http://localhost:8080/sys/upload", {
* method: 'POST',
* headers: { "Content-Type": "multipart/form-data;"},
* body: file }).then(response => response.json()
* ).then(
* success => console.log(success)
@premek
premek / mv.sh
Last active March 5, 2024 17:43
Rename files in linux / bash using mv command without typing the full name two times
# Put this function to your .bashrc file.
# Usage: mv oldfilename
# If you call mv without the second parameter it will prompt you to edit the filename on command line.
# Original mv is called when it's called with more than one argument.
# It's useful when you want to change just a few letters in a long name.
#
# Also see:
# - imv from renameutils
# - Ctrl-W Ctrl-Y Ctrl-Y (cut last word, paste, paste)
@dominictarr
dominictarr / readme.md
Created November 26, 2018 22:39
statement on event-stream compromise

Hey everyone - this is not just a one off thing, there are likely to be many other modules in your dependency trees that are now a burden to their authors. I didn't create this code for altruistic motivations, I created it for fun. I was learning, and learning is fun. I gave it away because it was easy to do so, and because sharing helps learning too. I think most of the small modules on npm were created for reasons like this. However, that was a long time ago. I've since moved on from this module and moved on from that thing too and in the process of moving on from that as well. I've written way better modules than this, the internet just hasn't fully caught up.

@broros

otherwise why would he hand over a popular package to a stranger?

If it's not fun anymore, you get literally nothing from maintaining a popular package.

One time, I was working as a dishwasher in a restu

@fnky
fnky / ANSI.md
Last active May 5, 2024 19:31
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@tiagoengel
tiagoengel / noise-cancellation.sh
Last active May 12, 2023 20:41
Hiss / White / Static noise cancellation on Linux using Pulseaudio and Sox
#!/bin/bash
# You'll need to have sox, pavucontrol and alsa-utils installed, and the snd_aloop kernel module loaded.
# You can configure your system to load it on startup or load it manually with "sudo modprobe snd_aloop"
# Once this is script is running, you need to start recording audio in the application of your
# preference, open pavucontrol, go to the recording tab and change the recording source of that application
# to "Monitor of Loopback ..."
time=5
@yossorion
yossorion / what-i-wish-id-known-about-equity-before-joining-a-unicorn.md
Last active April 7, 2024 22:55
What I Wish I'd Known About Equity Before Joining A Unicorn

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

@MarcoWorms
MarcoWorms / mini-redux.js
Last active August 7, 2023 19:06
Redux in a nutshell
function createStore (reducers) {
var state = reducers()
const store = {
dispatch: (action) => {
state = reducers(state, action)
},
getState: () => {
return state
}
}
@LeCoupa
LeCoupa / redis_cheatsheet.bash
Last active March 18, 2024 09:08
Redis Cheatsheet - Basic Commands You Must Know --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
# Redis Cheatsheet
# All the commands you need to know
redis-server /path/redis.conf # start redis with the related configuration file
redis-cli # opens a redis prompt
# Strings.