Skip to content

Instantly share code, notes, and snippets.

@a5ync
a5ync / getFilesManifest.ps
Last active July 6, 2017 00:16
Builds a file manifest of the given directory container
$path = $args[0]
$manifest = $args[1]
(Get-ChildItem -rec $path |where {!$_.PsIsContainer}| %{$_.FullName}) -replace [regex]::Escape($path), "" | Out-File $manifest
@a5ync
a5ync / ContainerManifest.cs
Created May 25, 2017 20:37
Build container manifest
public class ContainerManifest
{
public ContainerManifest(string rootPath)
{
_rootPath = rootPath;
Files = new List<string>();
TraverseDirectory(rootPath);
}
public override string ToString()
public static IEnumerable<string> ListAllFiles(string path)
{
var directories = Directory.GetDirectories(path);
foreach (var directory in directories)
{
foreach (string x in ListAllFiles(directory))
{
yield return x;
}
}
@a5ync
a5ync / ProcessExecutor.cs
Last active June 14, 2017 22:02
Asynchronous awaitable Process.Start()
namespace Helpers
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
public static class ProcessExecutor
{
@a5ync
a5ync / docker-list-env.sh
Created May 2, 2018 17:49
Docker - list env variables
docker inspect -f '{{range $index, $value := .Config.Env}}{{$value}} {{end}}' container_name
@a5ync
a5ync / docker-stats.sh
Created May 2, 2018 21:30
Docker - get stats /top
docker stats --format "table {{.Name}}\t{{.Container}}\t{{.CPUPerc}}\t{{.MemPerc}}\t{{.NetIO}}\t{{.BlockIO}}"
@a5ync
a5ync / prunebackups.sh
Created May 3, 2018 17:18
Prune files based on their date
#!/bin/bash
# This script is for manual cleanup of the hourly sql backups generated by the sqlbackup container.
# It is expected this would be run from the VM that is mounting the sqlbackup volume.
DAYS=$1
if [ -z "$DAYS" ]; then
echo 'USAGE: $ prunebackups.sh <number of days to keep>'
echo 'Number of days must be an integer and includes today.'
echo 'To wipe out every thing except today: "./prunebackups.sh 1"'
@a5ync
a5ync / check-latest.sh
Last active May 7, 2018 06:42
Check the docker latest
docker images|grep latest|awk '{print $3}'|while read line;do docker images|grep utmsp|grep -v latest|grep $line;done
@a5ync
a5ync / gist:255268d4344036033ccd48acfb4da578
Created June 8, 2018 19:18
Reload nginx configuration without restarting docker container
# or docker exec utmsp_gw_1 nginx -s reload
docker kill --signal=HUP utmsp_gw_1
@a5ync
a5ync / copy-docker-logs.sh
Created June 19, 2018 22:21
Copy docker logs
cd /var/lib/docker/containers
find ./ -type f -name *.log|xargs -i cp {} ~/docker-logs/