Skip to content

Instantly share code, notes, and snippets.

View pepoviola's full-sized avatar
💭
🦀

Javier Viola pepoviola

💭
🦀
View GitHub Profile
@max-mapper
max-mapper / index.js
Last active August 29, 2015 14:06
node tcp + http speed test
var net = require('net')
var through = require('through2')
var server = process.argv[2]
var path = process.argv[3]
var host = process.argv[4]
var socket = net.connect(80, server)
var req = ["GET " + path + " HTTP/1.1\r\n",
@paulrouget
paulrouget / .tmux.conf
Created January 27, 2012 17:37
Paul's configurations files
set -g default-terminal "screen-256color"
set -g status-utf8 on
bind M source-file ~/.tmux/mac.session
bind L source-file ~/.tmux/linux.session
# set -g terminal-overrides 'xterm*:smcup@:rmcup@'
# THEME
set -g status-bg black
@BillBarnhill
BillBarnhill / tide_test.rs
Created September 10, 2020 02:23
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();
@BillBarnhill
BillBarnhill / main.rs
Last active March 19, 2021 10:25
Main.rs with problem with signature of on_ws_request
// This version compiles, and works
#[macro_use]
extern crate serde_derive;
use serde_json::{Map, Value};
use tide_websockets::{
WebSocket,
Message
};
use async_std::stream::StreamExt;
@eduardonunesp
eduardonunesp / exporter.rs
Created January 11, 2021 18:31
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;
@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
@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:

@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.

@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;
@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.