Skip to content

Instantly share code, notes, and snippets.

View tappoz's full-sized avatar

Alessio Gottardo tappoz

View GitHub Profile
@tappoz
tappoz / update-ads
Created June 24, 2021 07:14 — forked from jaapie/update-ads
A simple bash script for Debian-based systems that downloads the latest version of Azure Data Studio and installs it. Requires the html-xml-utils package to be installed
#!/bin/bash
if [ "$EUID" -ne 0 ]
then echo "error: you must be root to run this script"
exit
fi
FILENAME=/tmp/azuredatastudio-latest.deb
LINK=$(curl -s "https://docs.microsoft.com/en-us/sql/azure-data-studio/download-azure-data-studio?view=sql-server-2017" | hxnormalize -x | hxselect 'table a[data-linktype="external"]' | sed -r 's/(.*)(<a[^>]*>.deb<\/a>)(.*)/\2/' | sed -r 's/(.*)href="([^"]*)"(.*)/\2/')
@tappoz
tappoz / python-parallel-threads.md
Created December 10, 2019 10:59
A python script useful for I/O intensive scenarios

Python parallel threads

This pattern is useful for I/O intensive tasks (e.g. HTTP requests and file system interactions).

import concurrent.futures
import logging
import random
import sys
import time
@tappoz
tappoz / promise-all-javascript.md
Created November 19, 2019 11:55
An example on how to execute parallel Javascript promises with Promise.all

Promise.all example

const sleepPromise = (millis) => {
  console.log(`Sleeping for ${millis} milliseconds`);
  return new Promise((resolve) => {
    setTimeout(() => resolve(), millis);
  });
};

How to normalize nested lists in JSON to a Pandas dataframe

import json
import pandas as pd


my_json_struct = '''
{
	"my_id": 1,
@tappoz
tappoz / openssl_commands.md
Created September 22, 2019 10:06 — forked from p3t3r67x0/openssl_commands.md
Some list of openssl commands for check and verify your keys

openssl

Install

Install the OpenSSL on Debian based systems

sudo apt-get install openssl
@tappoz
tappoz / add-ssh-user-to-existing-linux-vm.md
Created September 10, 2019 17:00
How to add an SSH user to an existing Linux VM

Setup an SSH user on an existing VM

Create the user and setup the SSH key

$ scp ${PATH_TO_SSH_KEYS}id_rsa.pub existing-user@${MACHINE_IP_ADDRESS}:.
$ ssh existing-user@${MACHINE_IP_ADDRESS}
$ sudo su
# useradd -s /bin/bash -m my-new-username
# mkdir /home/my-new-username/.ssh
@tappoz
tappoz / gitlab-ssh-key-setup-go-modules.md
Last active March 29, 2022 17:15
Setup an SSH pub/priv key pair for a website e.g. Github/Gitlab, deal with Go modules and private repositories

Generate an public/private key pair

Check the docs tutorial in here: https://docs.gitlab.com/ee/user/ssh.html

These are the main steps:

# the "-C" parameter is a comment to remind you about this key
ssh-keygen -t ed25519 -C " at gitlab" -f $HOME/.ssh/my_gitlab_eddsa
@tappoz
tappoz / golang-slice-in-place-removal.md
Last active June 3, 2019 15:31
How to remove in-place an element from a Go slice

Run the following code with: go test -v -run TestFooInPlace

package foo

import (
	"fmt"
	"log"
	"math/rand"
	"testing"

Azure CLI 2.0 cheatsheet

A collection of commands useful to do things in the Azure cloud.

Check the status of instances of SQL Server and databases

$ # Check the state of a SQL Server instance
$ # https://docs.microsoft.com/en-us/cli/azure/sql/server?view=azure-cli-latest#az-sql-server-show
$ az sql server show --name ${SQL_SERVER_NAME} --resource-group ${RESOURCE_GROUP_NAME} | jq .state
@tappoz
tappoz / ms-sql-server-and-json-fields.md
Last active April 24, 2018 13:10
MS SQL SERVER - Transact SQL and JSON fields