Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Serialization;
using System.IO;
namespace ConsoleApp
{
[Serializable]
class MyClass
{
@avitsidis
avitsidis / Microsoft.PowerShell_profile.ps1
Last active March 23, 2017 09:41
Powershell Prompt with git branch
function prompt
{
$username = $env:UserName
$computer = $env:ComputerName
$currentFolder = (Get-Item -Path .).Name
$isGitFolder = (git rev-parse --git-dir 2> $null)
$currentTime = Get-Date -Format HH:mm
Write-Host "$username@$computer"-nonewline -foregroundcolor Green
Write-Host "[$currentTime]" -nonewline -ForegroundColor Gray
Write-Host " $currentFolder"-nonewline -foregroundcolor Cyan
@avitsidis
avitsidis / Disable-VmPxeBoot.ps1
Created February 15, 2017 13:52
Disable Hyper-V VM PXE Boot
param(
[Parameter(Mandatory=$true)][string]$VMName,
[Parameter(Mandatory=$false)][string]$ComputerName = $env:computerName
)
#based on http://serverfault.com/questions/619763/can-pxe-boot-of-hyper-v-vms-be-disabled
$old_boot_order = Get-VMFirmware -VMName $VMName -ComputerName $ComputerName | Select-Object -ExpandProperty BootOrder
$new_boot_order = $old_boot_order | Where-Object { $_.BootType -ne "Network" }
Set-VMFirmware -VMName $VMName -ComputerName $ComputerName -BootOrder $new_boot_order
@avitsidis
avitsidis / script
Created February 10, 2017 15:24
SSH into mobylinux (docker for windows)
#based on po75558Manuel Patrone comment on https://forums.docker.com/t/how-can-i-ssh-into-the-betas-mobylinuxvm/10991/8
#get a privileged container with access to Docker daemon
docker run --privileged -it --rm -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker alpine sh
#run a container with full root access to MobyLinuxVM and no seccomp profile (so you can mount stuff)
docker run --net=host --ipc=host --uts=host --pid=host -it --security-opt=seccomp=unconfined --privileged --rm -v /:/host alpine /bin/sh
#switch to host FS
chroot /host
@avitsidis
avitsidis / gist:2c33371a2ae2d59cd80ac3e5f33c703c
Last active March 14, 2017 10:25 — forked from eduardocardoso/gist:82a629882ddb02ab3677
Script to delete exited containers and untagged/unused images from docker
#!/bin/bash
set -o errexit
echo "Removing exited docker containers..."
docker ps -a -f status=exited -q | xargs -r docker rm -v
echo "Removing dangling images..."
docker images --no-trunc -q -f dangling=true | xargs -r docker rmi