Skip to content

Instantly share code, notes, and snippets.

@neelabhg
neelabhg / Hyper-V.md
Last active November 13, 2022 00:13
An Overview of Hyper-V (2015-09-15)

Hyper-V

Microsoft's Hyper-V is a native (bare-metal) [hypervisor][2] available on Windows Server 2008 and later, and select editions of Windows 8 and later. (From [Wikipedia][1])

From [Hyper-V overview][3]:

The Hyper-V technology virtualizes hardware to provide an environment in which you can run multiple operating systems at the same time on one physical computer. Hyper-V enables you to create and manage virtual machines and their resources. Each virtual machine is an isolated, virtualized computer system that can run its own operating system. The operating system that runs within a virtual machine is called a guest operating system.

Versions

Microsoft provides Hyper-V through various channels:

@neelabhg
neelabhg / scan_dir_tree.py
Last active February 7, 2022 20:57
Python script to scan a directory tree and output information for files and directories to a JSON file
#!/usr/bin/env python3
"""
Scan a directory tree and output information for files and directories to a JSON file.
To use:
./scan_dir_tree.py --help
Using pyenv:
PYENV_VERSION=3.10.0 ./scan_dir_tree.py --help
@neelabhg
neelabhg / contravariance_example.ts
Created December 25, 2021 17:00
Type Variance Example
interface Animal {
name: string;
}
interface Cat extends Animal {
meow: () => void;
}
function doMeow(cat: Cat) {
cat.meow();
@neelabhg
neelabhg / vmware_guest_shared_folder_helper.sh
Last active July 1, 2022 13:27
Simple bash script to mount and unmount shared folders inside Linux guests running on VMware Workstation Player
#!/bin/bash
set -euo pipefail
MOUNTPOINT="$HOME/shares"
mount_shared_folders () {
/usr/bin/vmhgfs-fuse .host:/ "$MOUNTPOINT" \
-o subtype=vmhgfs-fuse \
-o uid=1000 \
-o gid=1000 \
@neelabhg
neelabhg / qemu_vm_mount_windows_local_folder.sh
Created March 6, 2017 08:28
Mount a Windows host's folder on a QEMU Linux guest
#! /bin/bash
# The Windows folder needs to be shared appropriately
WINDOWS_DIR_PATH="//10.0.2.2/workdir"
MNTPOINT="/workdir_local"
if [ ! -d "$MNTPOINT" ]; then
mkdir $MNTPOINT
fi
@neelabhg
neelabhg / .bashrc
Created March 6, 2017 08:19
Customizations for my GNU/Linux installations
# Place this in .bashrc or another shell initialization file
# Print the amount of File system usage on terminal start
# Command taken from http://www.cyberciti.biz/tips/shell-script-to-watch-the-disk-space.html
df -H /dev/sda1 | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print "Disk usage: " $5 }'
@neelabhg
neelabhg / xss_attack_insert_iframe_script.js
Created March 6, 2017 08:04
String for testing Cross-site scripting (XSS) injection
<script> ifrm = document.createElement("IFRAME"); ifrm.setAttribute("src", "http://i.imgur.com/2O8vjfv.gif?2"); ifrm.style.width = 500+"px"; ifrm.style.height = 410+"px"; document.body.appendChild(ifrm); </script>
@neelabhg
neelabhg / yumdvd.sh
Created March 6, 2017 07:56
Yum wrapper for using CentOS DVD as repository
#!/bin/bash
#Script to install packages via yum using DVD/CD as Repository
#Works on RedHat Enterprise Linux/CentOS/Scientific Linux versions above 4.0
#Change this to the location of your CD-ROM drive
cdrom=/dev/cdrom
#This location is searched by the DVD repository configuration script
mnt_point=/media/cdrom
#This is the DVD repository for CentOS 6. Change this to "c5-media" for CentOS 5. Please refer to the respective manuals for other OSes.
dvdrepo=c6-media
@neelabhg
neelabhg / list-read-print.rkt
Last active August 29, 2015 14:16
Read and print a list
#lang racket
; Read a list from stdin with each element on a new line
(define (read-list)
(let ((x (read)))
(if (eof-object? x)
'()
(cons x (read-list)))))
; Read n elements (or less, if exhausted) into a list from stdin where each element is on a new line
@neelabhg
neelabhg / dummy_mixpanel.js
Last active August 29, 2015 14:06
An object providing some dummy Mixpanel JavaScript library API functions for simple debugging
// Requires jQuery
window.mixpanel = {
register: function (properties, days) {
console.log('mixpanel register', properties, 'Registered for ' + days + ' days.');
},
track: function (event_name, properties, callback) {
console.log('mixpanel track', event_name, properties);
if (typeof callback === 'function') {
callback();