Skip to content

Instantly share code, notes, and snippets.

View sharunkumar's full-sized avatar
💻
Working on new projects

Sharun sharunkumar

💻
Working on new projects
  • Bay Area
  • 04:19 (UTC -07:00)
View GitHub Profile
@sharunkumar
sharunkumar / Keybase.io
Created August 14, 2018 17:53
Keybase Verification
### Keybase proof
I hereby claim:
* I am sharunkumar on github.
* I am sharunkumar (https://keybase.io/sharunkumar) on keybase.
* I have a public key ASBSekqzGALQs8Ki4rIXBoNiu0H5tYINN6wwNX078j-PsAo
To claim this, I am signing this object:
@sharunkumar
sharunkumar / folder-size.cmd
Last active April 6, 2023 16:30
Windows Batch script for getting the size of the folder in bytes. Usage: folder-size "<directory>"
@echo off
setlocal ENABLEDELAYEDEXPANSION
set firstline=.
set secondline=.
@FOR /F "tokens=1 delims=^^" %%G IN ('dir /s /a "%~1"') DO (
set firstline=!secondline!
set secondline=%%G
)
echo !firstline!
@sharunkumar
sharunkumar / adbremote.bat
Last active March 28, 2024 10:06
Windows wrapper batch file for disabling keyboard and setting brightness before using scrcpy to connect. Settings are restores after scrcpy disconnects. Based on script by Volodymyr Shymanskyy. https://gist.github.com/vshymanskyy/a44ff7af2848653e91f269910cb9d50f
@echo off
rem Requires Null Keyboard https://play.google.com/store/apps/details?id=com.wparam.nullkeyboard
rem Author: Sharun Kumar
setlocal ENABLEDELAYEDEXPANSION
for /F %%i in ('adb shell settings get system screen_brightness') do set brightness=%%i
for /F %%i in ('adb shell settings get secure default_input_method') do set ime=%%i
for /F "tokens=1,2,3,4,5,6,7,8" %%G in ('adb shell media volume --get') do (
set vol=%%J
@sharunkumar
sharunkumar / Autohotkey New Windows Terminal.ahk
Last active June 17, 2020 19:33
Autohotkey script for hooking win+` to open and toggle to the new windows terminal. Terminal will be spawned if it isn't opened already.
#SingleInstance, force
global PreviousActiveWindow
; Requires windows terminal preview: https://www.microsoft.com/en-us/p/windows-terminal-preview/9n0dx20hk701
#`::
DetectHiddenWindows, On
if (WinExist("ahk_class CASCADIA_HOSTING_WINDOW_CLASS")) {
if(WinActive("ahk_class CASCADIA_HOSTING_WINDOW_CLASS")) {
@sharunkumar
sharunkumar / adb-dns.bat
Created February 7, 2020 07:08
Enabling / Disabling private DNS in android via ADB
rem to disable private dns
adb shell settings put global private_dns_mode off
rem to enable private dns with hostname (example with dns.adguard.com)
adb shell settings put global private_dns_mode hostname
adb shell settings put global private_dns_specifier dns.adguard.com
@sharunkumar
sharunkumar / adbdns.bat
Created February 7, 2020 07:39
Windows batch file to toggle private dns setting in android via adb
@echo off
setlocal ENABLEDELAYEDEXPANSION
for /F %%i in ('adb shell settings get global private_dns_mode') do set dnsmode=%%i
for /F %%i in ('adb shell settings get global private_dns_specifier') do set dnshost=%%i
echo current dns setting is: !dnsmode!
if "!dnsmode!"=="hostname" (
echo current dns host is: !dnshost!
echo turning off private dns...
adb shell settings put global private_dns_mode off
@sharunkumar
sharunkumar / svg-to-dataurl.js
Last active May 8, 2021 21:02
Dev tools snippet to convert svg element contents to image data url which can then be saved or copied
// Modified version of code from where I got this: https://ourcodeworld.com/articles/read/1072/how-to-convert-a-html-svg-node-to-base64-with-javascript-in-the-browser
// $0 gets the currently selected element in 'inspect element' mode in dev tools. make sure you have selected the SVG tag element
var serializedSVG = new XMLSerializer().serializeToString($0);
var base64Data = window.btoa(serializedSVG);
// printing on to console which would be a clickable link
console.log("data:image/svg+xml;base64," + base64Data);
@sharunkumar
sharunkumar / samsung-autodownload-app-remove
Created May 10, 2021 21:02
List of apps that were automatically downloaded on my old Samsung device which I tried to resurrect
pm uninstall -k --user 0 com.eterno
pm uninstall -k --user 0 com.king.candycrushsaga
pm uninstall -k --user 0 com.opera.max.oem
pm uninstall -k --user 0 com.opera.max.preinstall
pm uninstall -k --user 0 com.snapchat.android
pm uninstall -k --user 0 in.amazon.mShop.android.shopping
pm uninstall -k --user 0 in.mohalla.sharechat
pm uninstall -k --user 0 in.mohalla.video
class UnionFind {
private int[] root;
private int[] rank;
public UnionFind(int n) {
this.root = new int[n];
this.rank = new int[n];
for (int i = 0; i < n; ++i) {
this.root[i] = i;
this.rank[i] = 1;
}
class Solution {
public ListNode deleteMiddle(ListNode head) {
// Edge case: return nullptr if there is only one node.
if (head.next == null)
return null;
// Initialize two pointers, 'slow' and 'fast'.
ListNode slow = head, fast = head.next.next;
// Let 'fast' move forward by 2 nodes, 'slow' move forward by 1 node each step.