Skip to content

Instantly share code, notes, and snippets.

View pepoviola's full-sized avatar
💭
🦀

Javier Viola pepoviola

💭
🦀
View GitHub Profile
@mohanpedala
mohanpedala / bash_strict_mode.md
Last active May 7, 2024 16:31
set -e, -u, -o, -x pipefail explanation
@staltz
staltz / introrx.md
Last active May 7, 2024 09:38
The introduction to Reactive Programming you've been missing
@LozanoMatheus
LozanoMatheus / get_ip.sh
Created November 30, 2020 21:41
Get Linux IP without any tool
#!/usr/bin/env bash
## Get the primary and secundary IPs
awk '/\|--/ && !/\.0$|\.255$/ {print $2}' /proc/net/fib_trie
## Get only the primary IPs
awk '/32 host/ { print i } {i=$2}' /proc/net/fib_trie
@tallclair
tallclair / kubectl-cp.sh
Last active January 18, 2024 22:19
kubectl cp equivalents
# Copy /tmp/foo_dir local directory to /tmp/bar_dir in a remote pod in the default namespace
kubectl cp /tmp/foo_dir <some-pod>:/tmp/foo_dir
tar cf - /tmp/foo_dir | kubectl exec -i <some-pod> -- tar xf -
# Copy /tmp/foo local file to /tmp/bar in a remote pod in a specific container
kubectl cp /tmp/foo <some-pod>:/tmp/foo -c <specific-container>
tar cf - /tmp/foo | kubectl exec -i <some-pod> -c <specific-container> -- tar xf -
# Copy /tmp/foo local file to /tmp/bar in a remote pod in namespace <some-namespace>
kubectl cp /tmp/foo <some-namespace>/<some-pod>:/tmp/foo
@koute
koute / calculate-deps.rb
Last active September 8, 2023 11:59
Calculate total lines of code for a Rust crate, local and external (requires `cargo-tree` and `tokei` to be installed)
#!/usr/bin/ruby
require "shellwords"
require "json"
if ARGV.length == 0
extra_args = ""
elsif ARGV.length == 1
extra_args = "-p #{ARGV[0]}"
else
@LozanoMatheus
LozanoMatheus / 01-bash_http.sh
Last active August 24, 2023 13:24
A simple request - HTTP request with native Bash and without curl/wget/*
#!/usr/bin/env bash +x
## Do you need to test your exposed app but you don't have curl/wget/* installed?
## The ":" is a built-in command and it works similar to true. Let's say, ":" is more portable than "true"
## Simple and easy
:> /dev/tcp/localhost/22
## Why using timeout? If any side has a firewall and it's dropping the packages, the request will take ~80 seconds to get the timeout.
@josepot
josepot / polkadot-extension-backup.ts
Last active July 31, 2023 07:40
create polkadot-js extension backup file
import { fromHex, utf16StrToUtf8Bytes } from "@unstoppablejs/utils";
import { jsonEncrypt } from "@polkadot/util-crypto";
import { createPair, Keyring } from "@polkadot/keyring";
const keyToBytes = (input: string | Uint8Array): Uint8Array =>
typeof input === "string" ? fromHex(input) : input;
export function createBackUpFileContent(
addresses: Array<{
name: string;
@Phaiax
Phaiax / how-does-async-work-in-async-std.md
Last active July 17, 2023 10:56
Blog article: How does async work in async-std?

How does async work in async-std?

(Phaiax - 2019/12/1 - CC_BY_SA 4.0)

Lately I was porting a software from tokio/futures-1.0 to async-await. I somehow thought async-std was the successor of tokio and ported everything to async-std. 80% in, I noticed that my hyper dependency requires tokio and that it's not possible to replace tokio with async-std without also replacing hyper. Also, tokio and async-std try to solve the same problem. So I started a journey into the inners of the rust async story to find out if it is possible to use both tokio and async-std at the same time. (tl;dr: it is). I had heard of reactors and executors before, but there was much new stuff to discover.

@rauchg
rauchg / effective-es6.md
Last active July 11, 2023 09:38
Writing ES6 today, effectively.

Effective transpiling of ES6

After publishing my article on ECMAScript 6, some have reached out to ask how I exactly I make it all work.

I refrained from including these details on the original post because they're subject to immiment obsoletion. These tools are changing and evolving quickly, and some of these instructions are likely to become outdated in the coming months or even weeks.

The main tool

When evaluating the available transpilers, I decided to use 6to5, which has recently been renamed to Babel. I chose it based on:

@jdx
jdx / boot.js
Last active March 16, 2023 18:08
zero-downtime node.js app runner
// This script will boot app.js with the number of workers
// specified in WORKER_COUNT.
//
// The master will respond to SIGHUP, which will trigger
// restarting all the workers and reloading the app.
var cluster = require('cluster');
var workerCount = process.env.WORKER_COUNT || 2;
// Defines what each worker needs to run