Skip to content

Instantly share code, notes, and snippets.

View sagunms's full-sized avatar

Sagun Man Singh Shrestha sagunms

  • Australia
View GitHub Profile
@sagunms
sagunms / BS
Created November 2, 2017 14:22
Verifying my Blockstack ID is secured with the address 1Hyf8RjucfmE6EFzsiKC5Kvfrw9qxr5t2n https://explorer.blockstack.org/address/1Hyf8RjucfmE6EFzsiKC5Kvfrw9qxr5t2n
@sagunms
sagunms / .bash_profile
Last active November 28, 2016 15:05 — forked from stephenll/.bash_profile
.bash_profile file on Mac OS X
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases.
# Much of this was originally copied from:
# http://natelandau.com/my-mac-osx-bash_profile/
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
@sagunms
sagunms / AutoPowerOnESXi
Created October 8, 2014 04:57
Automatically power on servers if PoweredOff in VMware ESXi 5.0
First time configuration
vi /var/spool/cron/crontabs/root
0 */15 * * * /vmfs/volumes/datastore1/auto-poweron.sh
vi /vmfs/volumes/datastore1/auto-poweron.sh
VMS=$(vim-cmd vmsvc/getallvms | grep -v Vmid | awk '{print $1}')
for VM in $VMS ; do
PWR=$(vim-cmd vmsvc/power.getstate "$VM" | grep "Powered")
if [ "$PWR" == "Powered off" ] ; then
vim-cmd vmsvc/power.on $VM
One of the biggest challenges I run into working with ESXi hosts is the lack of a real usable CLI. The remote CLI provided by VMware is clunky at best and makes administration a bit of a pain. I did some poking around and managed to find some interesting CLI commands that work for ESXi.
Most of these have no manual page but will output a help message if run by themselves. I would recommend using extreme caution and using a test host to determine the usefulness in your environment before using them on an important system. Also keep in mind that the examples that I give are not the "only" way the commands can be used.
To power on a virtual machine from the command line:
- Lists all vm's running on hypervisor and provides vmid
vim-cmd vmsvc/getallvms
@sagunms
sagunms / amr_textbook.php
Last active September 6, 2015 02:19
Download edX Autonomous Mobile Robots (AMRx) Textbook to local.
<?php
// Purpose: The edX AMR course textbook had extra large side buttons and very slow loading time, which was really annoying.
// For personal use only.
// Note: Create a directory ./book before running PHP script.
// Example:
// mkdir ./book # Create directory
// sudo chmod +w./book # Make the book directory writeable
// vim amr_textbook.php # Copy paste the following script, save, exit (:wq)
// php amr_textbook.php # Execute
#!/bin/sh
baseurl=http://mygitlaburl
usermail=adminuser@mymailserver
userpass=adminpassword
repo_access=2 #0=denied 1=read 2=read&write
project_access=2 #0=deined 1=read 2=report 3=admin
# login
curl -s -I -c cookies.txt -d "utf8=✓&user[email]=$usermail&user[password]=$userpass&commit=Sign+in" $baseurl/users/sign_in
# Gitlab 5.1: https://github.com/gitlabhq/gitlabhq/blob/master/doc/install/installation.md
# Set up an AWS EC2 Ubuntu 12.04 LTS Server.
# Use ap-southeast-1b: spot pricing is smoother
# Log in as ubuntu@
sudo apt-get -y update
sudo apt-get -y upgrade
# Install the required packages.
@sagunms
sagunms / ros_listener.cpp
Created July 2, 2013 12:21
Hello World ROS (Robot Operating System) - Talker and Listener
#include "ros/ros.h"
#include "std_msgs/String.h"
void callback(const std_msgs::String &msg) {
ROS_INFO("I heard: [%s]", msg.data.c_str());
}
int main(int argc, char **argv) {
ros::init(argv, argc, "listener");
ros::NodeHandle n;