Skip to content

Instantly share code, notes, and snippets.

View JosiahSiegel's full-sized avatar
🌌

Josiah Siegel JosiahSiegel

🌌
View GitHub Profile
@JosiahSiegel
JosiahSiegel / azure_created_tags.sh
Last active March 7, 2022 20:51
Create 'created-at' and 'created-by' tags for all resources in an Azure resource group
# sudo apt-get install jq -y
# specifiy resource group name and days offset
resource_group=''
offset_days=90
# prevent override by checking if "created-by" tag exists
tag_search='properties.tags.\"created-by\"'
# fetch resource activites (last 90d)
@JosiahSiegel
JosiahSiegel / github_actions_starting.md
Created February 8, 2022 19:59
GitHub actions - get started

GitHub actions - get started

  • Directory for GitHub objects: .github/workflows or .github/actions

Common workflow triggers

Run workflow on branch push

  1. on any branch push
@JosiahSiegel
JosiahSiegel / wsl_backup_restore.md
Created October 28, 2021 15:43
WSL Distro backup and restore
  1. Get local distro name

    wsl -l -v
     NAME            STATE           VERSION
     * Ubuntu-20.04    Running         2

Keybase proof

I hereby claim:

  • I am josiahsiegel on github.
  • I am josiahsiegel (https://keybase.io/josiahsiegel) on keybase.
  • I have a public key ASAVF-sHPe6ax0B95LQCZnveCJrqlTQdg2usNTPbopJFMAo

To claim this, I am signing this object:

@JosiahSiegel
JosiahSiegel / Dockerfile
Created September 19, 2021 03:43
Dockerfile - Existing Angular.js app
FROM node:latest
RUN apt-get update && apt-get install -y vim
EXPOSE 8000
RUN mkdir /home/node/.npm-global
ENV PATH=/home/node/.npm-global/bin:$PATH
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
RUN npm install -g @angular/cli
@JosiahSiegel
JosiahSiegel / Dockerfile
Created September 19, 2021 03:16
Dockerfile - New Angular.js app
FROM node:latest
RUN apt-get update && apt-get install -y vim
EXPOSE 4200
RUN mkdir /home/node/.npm-global
ENV PATH=/home/node/.npm-global/bin:$PATH
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
RUN npm install -g @angular/cli
<policies>
<inbound>
<base />
<set-backend-service id="apim-generated-policy" backend-id="la" />
<set-variable name="dataset" value="@(context.Request.Url.Query.GetValueOrDefault("dataset"))" />
<choose>
<when condition="@((string)context.Variables["dataset"] == "employees")">
<set-variable name="loopinterval" value="2" />
</when>
<when condition="@((string)context.Variables["dataset"] == "locations")">
@JosiahSiegel
JosiahSiegel / kill_user_spids.sql
Last active June 29, 2021 22:58
#MSSQL Auto KILL SPIDs based upon login
DECLARE @spid INT
DECLARE @kill_spid NVARCHAR(100)
DECLARE running_jobs CURSOR FOR
SELECT
req.[session_id]
FROM sys.dm_exec_requests req
LEFT JOIN sys.dm_exec_sessions ses ON ses.session_id = req.session_id
LEFT JOIN msdb.dbo.sysjobs jobs ON SUBSTRING(ISNULL(ses.[program_name],''),CHARINDEX('0x', ISNULL(ses.[program_name],'')) + 18, 16) = SUBSTRING(REPLACE(ISNULL(jobs.[job_id],''), '-',''),17,16)
@JosiahSiegel
JosiahSiegel / script_mssql_restore.sql
Created April 29, 2021 20:19
#MSSQL Script restore of local backups
--Reference:
--https://www.mssqltips.com/sqlservertip/1584/auto-generate-sql-server-restore-script-from-backup-files-in-a-directory/
USE [master];
GO
SET NOCOUNT ON
-- 1 - Variable declaration
DECLARE @dbName sysname
DECLARE @backupPath NVARCHAR(500)
@JosiahSiegel
JosiahSiegel / azure_sql_db.sql
Created December 16, 2020 19:37
#Azure #MSSQL Create Azure SQL database login
-- ========================================================================================
-- Create User as DBO template for Azure SQL Database and Azure SQL Data Warehouse Database
-- ========================================================================================
-- For login, create a user in the database
CREATE USER [my-login]
FROM EXTERNAL PROVIDER
WITH DEFAULT_SCHEMA = dbo
GO
EXEC sp_addrolemember N'db_owner', N'my-login'