Skip to content

Instantly share code, notes, and snippets.

View pepoviola's full-sized avatar
💭
🦀

Javier Viola pepoviola

💭
🦀
View GitHub Profile
@pepoviola
pepoviola / bash_strict_mode.md
Created October 16, 2023 19:13 — forked from mohanpedala/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation
@pepoviola
pepoviola / get_ip.sh
Created August 24, 2023 13:24 — forked from LozanoMatheus/get_ip.sh
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
@pepoviola
pepoviola / init.sh
Last active February 19, 2022 12:41
Zombienet example native provider
#!/usr/bin/env bash
set -euxo pipefail
# get zombienet
curl -L -O https://github.com/paritytech/zombienet/releases/download/v1.2.14/zombienet-linux
chmod +x zombienet-linux
# get polkadot
curl -L -O https://github.com/paritytech/polkadot/releases/download/v0.9.15-1/polkadot
@pepoviola
pepoviola / exporter.rs
Created July 15, 2021 13:25 — forked from eduardonunesp/exporter.rs
pdf-exporter
use std::fs::File;
use std::io::{prelude::*, BufReader, Write};
use std::process::Command;
use actix_multipart::Multipart;
use actix_web::{
get, http::StatusCode, post, web, App, Error, HttpResponse, HttpServer, Responder,
};
use futures::{StreamExt, TryStreamExt};
use tempdir::TempDir;
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
use std::time::{Duration, Instant};
struct Inspect<F>(F);
impl<F: Future> Future for Inspect<F> {
type Output = F::Output;
@pepoviola
pepoviola / main.rs
Last active October 22, 2020 18:21
Rust sleep in main...
/// playground link https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=4dc3d523c44e52a90368a3ada41340d5
use std::time::Duration;
use std::thread;
use std::thread::sleep;
use std::sync::{Arc,RwLock};
fn main() {
let story_behind_arc = Arc::new( RwLock::new( String::from("Once upon a time..." )));
let story_ref = story_behind_arc.clone();
@pepoviola
pepoviola / tide_test.rs
Created September 10, 2020 13:31 — forked from BillBarnhill/tide_test.rs
An example Tide unit test in Rust, with a Request and checked Response
#[cfg(test)]
mod tests {
#[async_std::test]
async fn index_page() -> tide::Result<()> {
use tide::http::{Url, Method, Request, Response};
let mut app = tide::new();
app.at("/").get(|_| async { Ok("Hello, world!") });
let url = Url::parse("https://example.com").unwrap();
exports.handler = async (event) => {
console.log( 'process.traceDeprecation', process.traceDeprecation );
Buffer(1);
process.on('warning', (warning) => {
console.log( 'stack of deprecation' );
console.log(warning.stack);
});
};
const chromium = require( 'chrome-aws-lambda' );
const puppeteer = require( 'puppeteer-core' );
const browser = await puppeteer.launch( {
args : chromium.args,
defaultViewport : chromium.defaultViewport,
executablePath : await chromium.executablePath,
headless : chromium.headless,
} );
@pepoviola
pepoviola / add-chrome-aws-lambda.sh
Created October 24, 2019 20:05
Add Google Chrome for AWS Lambda as dependency in your function.
# Add Google Chrome for AWS Lambda as dependency in your function.
# based on https://github.com/alixaxel/chrome-aws-lambda#aws-lambda-layer
nvm use lts/dubnium
mkdir -p node_modules/chrome-aws-lambda/
npm install lambdafs@~1.3.0 puppeteer-core@~1.20.0 --no-bin-links --no-optional --no-package-lock --no-save --no-shrinkwrap
npm pack chrome-aws-lambda
tar --directory node_modules/chrome-aws-lambda/ --extract --file chrome-aws-lambda-*.tgz --strip-components=1
rm chrome-aws-lambda-*.tgz