Skip to content

Instantly share code, notes, and snippets.

Nick Vissari nickadam

  • Elkridge, MD
View GitHub Profile
@nickadam
nickadam / ps1_to_cmd.ps1
Created Mar 31, 2020
[ps1_to_cmd] Convert a multiline PS1 script to a single line cmd file #PowerShell
View ps1_to_cmd.ps1
$s = Get-Content script.ps1 | Out-String
$j = [PSCustomObject]@{
"Script" = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($s))
} | ConvertTo-Json -Compress
$oneline = "[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String(('" + $j + "' | ConvertFrom-Json).Script)) | iex"
$c = [convert]::ToBase64String([System.Text.encoding]::Unicode.GetBytes($oneline))
("Powershell -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -Encoded " + $c) | Out-File -Encoding Default script.cmd
@nickadam
nickadam / elasticsearch-kibana.yml
Created Nov 10, 2019
Elasticsearch three node cluster and kibana with security
View elasticsearch-kibana.yml
version: '3.5'
services:
kibana:
image: docker.elastic.co/kibana/kibana:7.4.2
environment:
- ELASTICSEARCH_HOSTS=http://es01:9200
- ELASTICSEARCH_USERNAME=kibana
- ELASTICSEARCH_PASSWORD=agoodpassword
ports:
- target: 5601
@nickadam
nickadam / byers_wall.py
Created Oct 17, 2019
#ws281x #strangerthings
View byers_wall.py
#!/usr/bin/env python3
import time
import random
from rpi_ws281x import PixelStrip, Color
import argparse
# LED strip configuration:
LED_COUNT = 50 # Number of LED pixels.
LED_PIN = 18 # GPIO pin connected to the pixels (18 uses PWM!).
@nickadam
nickadam / kibana-k8s.yml
Created Oct 10, 2019
Kibana on Kubernetes
View kibana-k8s.yml
apiVersion: kibana.k8s.elastic.co/v1alpha1
kind: Kibana
metadata:
name: hcpss
spec:
version: 7.2.0
nodeCount: 1
elasticsearchRef:
name: hcpss
@nickadam
nickadam / elasticsearch-k8s.yml
Last active Oct 10, 2019
Elasticsearch on Kubernetes
View elasticsearch-k8s.yml
apiVersion: elasticsearch.k8s.elastic.co/v1alpha1
kind: Elasticsearch
metadata:
name: hcpss
spec:
version: 7.2.0
nodes:
- nodeCount: 3
config:
node.master: true
View Get-Subordinates.ps1
function Get-Subordinates(){
param(
[Parameter(Mandatory=$True,
HelpMessage='The username of the person at the top of the org')]
[string]$Username,
[Parameter(Mandatory=$False,
HelpMessage='The level to traverse into the org, i.e. 1 = only include direct reports, -1 = all')]
[int]$Depth
)
@nickadam
nickadam / install_docker-ce.sh
Created Jul 31, 2019
Install docker-ce Ubuntu
View install_docker-ce.sh
#!/bin/bash
apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-get update
apt-get install -y docker-ce docker-ce-cli containerd.io
curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
View List-Acls.ps1
function List-Acls {
param (
$Path,
$Depth
)
$Depth = $Depth - 1
Get-ChildItem $Path | ForEach-Object{
$FullName = $_.FullName
$FilePath = $_.FullName -replace "^[^$]+\$\\"
$FileOrFolder = "File"
@nickadam
nickadam / copy_docker_secret.sh
Created Jun 12, 2019
Copy a docker swarm secret between two clusters
View copy_docker_secret.sh
#!/usr/bin/env bash
SRC="$1"
DST="$2"
SECRET="$3"
SLEEP=3
secret=$(ssh $1 "docker service create --restart-condition=none --name copy_secret --secret $3 -d alpine cat /run/secrets/$3 >/dev/null; sleep $SLEEP; docker service logs --raw copy_secret; docker service rm copy_secret>/dev/null")
# https://stackoverflow.com/questions/1251999/how-can-i-replace-a-newline-n-using-sed
secret=$(echo "$secret" | sed ':a;N;$!ba;s/\n/\\n/g' | sed ':a;N;$!ba;s/ /\\ /g')
@nickadam
nickadam / my-minio.yml
Last active Jul 22, 2019
minio cluster
View my-minio.yml
version: '3.5'
services:
minio1:
image: minio/minio:RELEASE.2019-07-17T22-54-12Z
hostname: minio1
volumes:
- minio1-data:/export
ports:
- target: 9000
published: 9009
You can’t perform that action at this time.