Skip to content

Instantly share code, notes, and snippets.

View giordanocardillo's full-sized avatar
😎
Always improving

Giordano Cardillo giordanocardillo

😎
Always improving
View GitHub Profile
@giordanocardillo
giordanocardillo / README.md
Last active March 23, 2022 22:05
Restore Table spt_values

The table sys.spt_values is in the ressources database (mssqlsystemresource). This database is only accessible when the SQL Service is started in single user mode..

To re-create the view to do the following steps:

  1. Stop all MSSSQL Service

  2. Start the SQL Service in single user mode: Open a DOS Command prompt and start the sqlservice with the -m switch

"C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\Binn\sqlservr.exe" -m

@giordanocardillo
giordanocardillo / template.yaml
Created February 9, 2022 10:50
CloudFormation S3 bucket + SSL + CloudfFront distribution + OAI
AWSTemplateFormatVersion: '2010-09-09'
Parameters:
BucketName:
Type: String
AllowedPattern: '^[A-Za-z0-9-]*$'
ConstraintDescription: 'Must be a valid S3 bucket name'
Description: 'Input the bucket name you want to create'
CloudFrontDistributionCNAME:
Type: String
Description: 'Input the CloudFront distribution CNAME'
@giordanocardillo
giordanocardillo / README.md
Last active January 12, 2022 19:36
Codepipeline - Delete EKS pod

Lambda helper function to remove a running POD

Lambda function to remove a running POD from EKS cluster and allow the matching deployment to run it again, updating it.

Thia allows microservice updating after a codepipeline run.

It uses the awscli because the get-token command is not available in boto3 library.

Requirements

@giordanocardillo
giordanocardillo / spinner.sh
Last active November 26, 2020 10:14
Bash Spinner
#/bin/sh
spinner=(" " "1 " "10 " "101 " " 010" " 01" " 0")
spinner_length=${#spinner[0]}
function spin() {
tput cuf "$spinner_length"
while [ 1 ]; do
for i in "${spinner[@]}"; do
tput cub "$spinner_length"
@giordanocardillo
giordanocardillo / README.md
Last active August 12, 2020 09:47
Focus Trapper - How to trap focus inside an element

FocusTrapper

A simple method to "trap" tabbing inside an element

Usage

const trapper = new FocusTrapper(element)
trapper.trap() // To trap focus
trapper.untrap() // To release
@giordanocardillo
giordanocardillo / README.md
Last active May 27, 2020 07:36
Installing Provisioning Profiles

Installing provisioning profiles

  1. Download your provisioning profile from the apple developer portal
  2. Extract provisioning profile UUID
    uuid=`grep UUID -A1 -a profile.mobileprovision | grep -io "[-A-F0-9]\{36\}"
  3. Rename the provisioning profile file as <uuid>.mobileprovision
    mv profile.mobileprovision $uuid.mobileprovision
@giordanocardillo
giordanocardillo / nsw.sh
Created March 26, 2020 20:13
Node switch
function nsw() {
if [[ -z $1 ]]; then
echo "Usage nsw [<node version>|ls] [-q]"
return;
fi
if [[ $1 == "ls" ]]; then
ls /d/Spindox/nodejs | sed s/nodejs-//
return
fi
@giordanocardillo
giordanocardillo / README.md
Last active April 30, 2020 07:29
Installing OpenSTF

Installation

  1. Download current gist as zip file and unzip it in any folder
  2. Connect MAC to GIALLO or to internet using something else, GIALLO is fine
  3. Start file install.sh
  4. Disconnect from internet, to allow nexus usage and run install-offline.sh
  5. Done!

Start/stop

@giordanocardillo
giordanocardillo / README.md
Last active March 25, 2020 11:38
Installing node-gyp in locale without internet
@giordanocardillo
giordanocardillo / ps1_branch.sh
Created March 16, 2020 09:57
Adding SVN/GIT branch to Git Bash (Windows)
#!/bin/bash
function svn_branch {
svn_info="$(svn info | egrep '^URL: ' 2> /dev/null)"
branch_pattern="^URL: .*/(branches|tags)/([^/]+)"
trunk_pattern="^URL: .*/trunk(/.*)?$"
if [[ ${svn_info} =~ $branch_pattern ]]; then
branch=${BASH_REMATCH[2]}
elif [[ ${svn_info} =~ $trunk_pattern ]]; then
branch='trunk'