Skip to content

Instantly share code, notes, and snippets.

@vkhazin
vkhazin / vs-code-server.sh
Last active July 18, 2025 15:51
vs-code-server setup on Ubuntu 24.04 using cli
#!/bin/bash
# VS Code Server Setup Script for Ubuntu 24.04
# This script installs VS Code CLI and sets up tunneling for remote connections
# Unlike code-server.sh which sets up web-based code-server, this creates a tunnel
# that can be accessed from other VS Code IDE instances remotely
set -e
# Function to print status messages
@vkhazin
vkhazin / code-server-setup.sh
Last active July 10, 2025 23:26
Install code-server to access from a web browser
#!/bin/bash
# Instructions for Ubuntu Server 24.04
# Launch a VM with ports 22, 80, 443 accessible from the internet
# User a dns setting to point to public IP of the VM
# Login to the VM using ssh
# Execute the command below
# bash <(curl -fsSL https://gist.githubusercontent.com/vkhazin/de15691155f54739c572d29bbb47b890/raw)
# Access using a web-browser and the url specified during execution of shell script
@vkhazin
vkhazin / redshift-grant.sql
Created December 7, 2023 18:17
How to grant read-only access to all tables in a AWS Redshift schema
grant select on all tables in schema {schema_name} to {db_user};
grant usage on schema {schema_name} to {db_user};
fields @message
| filter @message like 'Carlsberg'
| parse @message '"material":"*"' as material
| filter not isempty(material)
| display material, @message
# Place the file in the root folder of git repos to sync
# Run the script: python3 ./git-pull-push.py source_remote target_remote branch_name
import os
import sys
errors = []
def main():
source_remote = sys.argv[1]
cast(UNIX_SECONDS(PARSE_TIMESTAMP("%d/%b/%Y:%H:%M:%S %z", time)) as string) as time
@vkhazin
vkhazin / cisco-vpn-dns-metrics.ps1
Created April 15, 2022 01:57
Fix DNS resolution for WSL2 using Cisco Vpn
Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Cisco AnyConnect"} | Set-NetIPInterface -InterfaceMetric 6000
@vkhazin
vkhazin / purge-cdn.ps1
Last active March 26, 2021 12:15
Azure DevOps purge CDN End-Point
# https://docs.microsoft.com/en-us/powershell/azure/authenticate-azureps?view=azps-5.6.0#password-based-authentication
# https://docs.microsoft.com/en-us/azure/cdn/cdn-manage-powershell#purgingpre-loading-cdn-assets
param (
[string]$applicationId,
[string]$tenantId,
[string]$accessKey,
[string]$resourceGroupName,
[string]$profileName,
[string]$endpointName,
echo "$USER ALL=(ALL) NOPASSWD:ALL" | sudo tee --append /etc/sudoers
@vkhazin
vkhazin / gist:c97c1175ddedb58837eca2760f6c63e5
Created April 10, 2020 15:45
PowerShell restore Sql Server database
$AZFileShareURl = "tsqlbackup.file.core.windows.net"
$AZUserName = "Azure\tsqlbackup"
$AZPassword = "7RODyFgfsXx1nML/SfFifKL+ozoCVag89D8B/bCgTbDakqaB7gSVM41BzcF0uvRHugmHRMLYoPyecAzJGPzxrA=="
$BackupFileName = "sqlbackup\DBExport.bak"
$DownloadLocation = "f:\DBExport.bak"
$SQLServer = "VM2016"
$BackupFileLocation = "f:\DBExport.bak"
$DatabaseName = "DBTest"