Skip to content

Instantly share code, notes, and snippets.

View celiomarcos's full-sized avatar
:shipit:

Celio Marcos celiomarcos

:shipit:
View GitHub Profile
@ErickWendel
ErickWendel / concat-streams.mjs
Last active May 19, 2023 18:04
Example of how to consume multiple Web APIs in parallel via Node.js Streams
// npm i axios stream-concat
import { pipeline } from 'stream/promises'
import StreamConcat from 'stream-concat'
import axios from 'axios'
const API_01 = 'http://localhost:3000'
const API_02 = 'http://localhost:4000'
const streams = (await Promise.all([
axios({
@corentinbettiol
corentinbettiol / README.md
Last active January 12, 2024 15:47
Tiny js code that will simulate a 3D view of your elements, like firefox used to do.
@rochacbruno
rochacbruno / app.py
Created November 13, 2019 20:03
Read fixed width text file in Python
import struct
from operator import itemgetter
from pathlib import Path
def get_struct_unpacker(fieldspecs, istart, iwidth):
"""
Build the format string for struct.unpack to use, based on the fieldspecs.
fieldspecs is a list of [name, start, width] arrays.
Returns a string like "6s2s3s7x7s4x9s".
@AliMirlou
AliMirlou / download.py
Last active October 7, 2020 11:26 — forked from idolpx/download.py
Python HTTP download with resume and optional MD5 hash checking
#!/usr/bin/env python
import logging
logger = logging.getLogger(__name__)
import argparse
import os.path
import requests
import shutil
@posemon
posemon / postman_install.sh
Created May 23, 2018 07:58
Postman install Ubuntu 18.04
#!/bin/bash
# Get postman app
wget https://dl.pstmn.io/download/latest/linux64 -O postman.tar.gz
sudo tar -xzf postman.tar.gz -C /opt
sudo ln -s /opt/Postman/Postman /usr/bin/postman
#Create a Desktop Entry
cat > ~/.local/share/applications/postman.desktop <<EOL
[Desktop Entry]
Encoding=UTF-8
@takwas
takwas / demo.py
Created August 14, 2017 18:23
Exception message printing demo
###########
# Python 2:
###########
try:
raise Exception
except Exception as e:
s,r = getattr(e, 'message') or str(e), getattr(e, 'message') or repr(e)
print 's:', s, 'len(s):', len(s)
print 'r:', r, 'len(r):', len(r)
@dennislwy
dennislwy / aes.py
Last active June 13, 2023 05:15
Python helper class to perform AES encryption, decryption with CBC Mode & PKCS7 Padding
# AES helper class for pycrypto
# Copyright (c) Dennis Lee
# Date 22 Mar 2017
# Description:
# Python helper class to perform AES encryption, decryption with CBC Mode & PKCS7 Padding
# References:
# https://www.dlitz.net/software/pycrypto/api/2.6/
# http://japrogbits.blogspot.my/2011/02/using-encrypted-data-between-python-and.html
@corbanb
corbanb / pre-request-jwt.js
Last active February 21, 2024 14:47
JWT tokenize - Postman Pre-Request Script
function base64url(source) {
// Encode in classical base64
encodedSource = CryptoJS.enc.Base64.stringify(source);
// Remove padding equal characters
encodedSource = encodedSource.replace(/=+$/, '');
// Replace characters according to base64url specifications
encodedSource = encodedSource.replace(/\+/g, '-');
encodedSource = encodedSource.replace(/\//g, '_');

AES encryption with PKCS5 padding

NOTE: Possible use the Cryptography package instead.

Install Python pycrypto package.

@jgrodziski
jgrodziski / docker-aliases.sh
Last active April 30, 2024 17:46
Useful Docker Aliases
############################################################################
# #
# ------- Useful Docker Aliases -------- #
# #
# # Installation : #
# copy/paste these lines into your .bashrc or .zshrc file or just #
# type the following in your current shell to try it out: #
# wget -O - https://gist.githubusercontent.com/jgrodziski/9ed4a17709baad10dbcd4530b60dfcbb/raw/d84ef1741c59e7ab07fb055a70df1830584c6c18/docker-aliases.sh | bash
# #
# # Usage: #