Skip to content

Instantly share code, notes, and snippets.

View savishy's full-sized avatar

Vish savishy

View GitHub Profile
@savishy
savishy / bash-tips.md
Last active February 14, 2021 04:10
Bash / Shell Tips and Tricks

execute command as another user

sudo -u <user> bash -c "<command to execute>"

list all users in system

@savishy
savishy / useful_knowledge.md
Last active March 30, 2017 10:25
List of useful bits of info -- how to do this, how to troubleshoot that, etc.

Systems Administration

Killing a Dangling SSH Session.

Background: I had previously SSH'd into a server and CD to directory /opt/foo when I got kicked out by network troubles. A colleague was trying to delete that directory and could not delete it.

  • SSH into the server
  • Execute who to get the active sessions.
  • Try to locate the pts/N session from the list.
  • Now execute ps -ef | grep -i sshd and from the list, locate the PID for the SSHD session that has pts/N.
@savishy
savishy / Git Cheatsheet.md
Last active February 19, 2018 06:30
Useful git commands
[testng] org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. (Original error: Command failed: C:\WINDOWS\system32\cmd.exe /s /c "D:\vish\adt-bundle\sdk\platform-tools\adb.exe shell "settings get global airplane_mode_on""
[testng] error: more than one device/emulator
[testng] ) (WARNING: The server did not provide any stacktrace information)
[testng] Command duration or timeout: 43 milliseconds
[testng] Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
[testng] System info: host: 'freeman', ip: '10.0.0.119', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_25'
[testng] Driver info: io.appium.java_client.android.AndroidDriver
[testng] Capabilities [{appPackage=com.icelero.crunch, networkConnectionEnabled=true, warnings={}, databaseEnabled=false, deviceName=MotoE, uuid=ZX1B33GSLN, platform=LINUX, appActivity=app.CrunchSplashActivity, chromedriverExecutable=C:\Users\vish\AppData\Loca
2016-03-10 11:58:34:740 - info: Welcome to Appium v1.4.13 (REV c75d8adcb66a75818a542fe1891a34260c21f76a)
2016-03-10 11:58:34:742 - info: Appium REST http interface listener started on 127.0.0.1:4723
2016-03-10 11:58:34:745 - debug: Non-default server args: {"app":"D:\\vish\\ma-app-verification-android\\appium-projects\\AppiumAndroid\\CrunchAPKs\\Crunch.apk","udid":"ZX1B33GSLN","address":"127.0.0.1","log":"C:\\Users\\vish\\AppData\\Local\\Temp\\appium4723.log","loglevel":"warn:debug","localTimezone":true,"androidPackage":"com.icelero.crunch","androidWaitActivity":"app.CrunchSplashActivity","deviceName":"MotoE","platformName":"Android","platformVersion":"5.1","automationName":"Appium","chromeDriverPort":4725,"chromedriverExecutable":"C:\\Users\\vish\\AppData\\Local\\Temp\\\\chromedriver.exe","defaultCommandTimeout":600}
2016-03-10 11:58:34:745 - info: Console LogLevel: warn
2016-03-10 11:58:34:745 - info: File LogLevel: debug
2016-03-10 11:58:35:620 - info: --> GET /wd/hub/status {}
2016-03-10 11:58:35:622 - de
@savishy
savishy / adb_commands.sh
Created March 10, 2016 08:07
A list of useful adb commands
######################################
# get and set network connection
######################################
# returns 1 if airplane mode is enabled, 0 otherwise.
adb -s $DEVICE_ID shell settings get global airplane_mode_on
# the same for wifi and mobile data.
adb -s $DEVICE_ID shell settings get global wifi_on
adb -s $DEVICE_ID shell settings get global mobile_data
@savishy
savishy / rename.sh
Last active February 22, 2021 16:02
Useful Little Scripts
#!/bin/bash
set -e
echo "==== rename.sh =====
This script recurses through videos in a folder, and
renames them into a format as follows:
test_[w]x[h]_[bitrate]_[duration].[extension]
e.g.
test_640x480_2973Kbps_34s.mov
@savishy
savishy / Docker Cheatsheet.md
Last active June 13, 2017 10:59
docker commands

Docker Images

list all docker dangling images

Dangling images are "no name, no tag" images <none>:<none> created during image building. These images are bad because they consume disk space. Reference.

docker images -f "dangling=true"
@savishy
savishy / calabash_android_cheatsheet.md
Last active July 6, 2016 04:53
List of useful calabash commands

Table of Contents

  1. FAQ
  2. Commands
  3. How Tos

Introduction

This is a list of useful commands in Calabash for Android. The Ruby API is assumed. :exclamation: many of the cheats here are Ruby and not Calabash. This is probably because my Ruby sucks :)

@savishy
savishy / ec2-cli-cleanup-group.sh
Last active August 24, 2016 03:44
Amazon EC2 CLI and API: Tips, Tricks and Scripts
#!/bin/bash
set -e
###########
# AWS CLI Must be installed e.g using sudo apt install awscli.
# This script cleans up your security group to remove old IP addresses from the rules for SSH, and
# adds your current IP address.
# This scenario is especially for cases where your ISP only allows dynamic IP addresses, or you
# access AWS from multiple locations.