Skip to content

Instantly share code, notes, and snippets.

View harshithjv's full-sized avatar

Harshith J. V. harshithjv

  • Mangalore
  • 08:35 (UTC +05:30)
View GitHub Profile
@harshithjv
harshithjv / all_inserts.sql
Created April 29, 2020 05:58
SQL (SQLite) queries to show all benefactors and their donation amounts.
INSERT INTO benefactors(id, name) VALUES(1, 'Phil');
INSERT INTO benefactors(id, name) VALUES(2, 'Nicholas');
INSERT INTO benefactors(id, name) VALUES(3, 'William');
INSERT INTO donations(id, amount, year, benefactorId) VALUES(1, 2000, 2014, 1);
INSERT INTO donations(id, amount, year, benefactorId) VALUES(2, 2800, 2015, 1);
INSERT INTO donations(id, amount, year, benefactorId) VALUES(3, 900, 2015, 1);
INSERT INTO donations(id, amount, year, benefactorId) VALUES(4, 1200, 2015, 2);
INSERT INTO donations(id, amount, year, benefactorId) VALUES(5, 3200, 2015, null);
INSERT INTO donations(id, amount, year, benefactorId) VALUES(6, 4000, 2015, null);
@harshithjv
harshithjv / MinimumAbsoluteDifference.md
Last active April 29, 2020 08:50
Find minimum absolute difference between the left sum and the right sum of each element in an unsorted array.

Given an unsorted array, find the minimum absolute difference between the left sum and the right sum of each element.

Example: Arr = [3,1,2,4,3]

1st diff = |3 - 10| = 7 => leftSum = 3, rightSum = 10 2nd diff = |4 - 9| = 5 => leftSum = 4, rightSum = 9 3rd diff = |6 - 7| = 1 => leftSum = 6, rightSum = 7 4th diff = |10 - 3| = 7 => leftSum = 10, rightSum = 3

Minimum Difference = 1

@harshithjv
harshithjv / upgrade_pip3.bat
Last active June 3, 2020 07:54
Upgrading pip3 on windows
REM where is windows alternative to which in Nix platforms
where pip3
REM Output : %APPDATA%\Local\Programs\Python\Python3\Scripts\pip3.exe
REM %APPDATA% is an environment variable and won't show like that. Will show actual full path like: C:\Users\Foo\AppData\Local\Programs\Python\Python38\Scripts\pip3.exe
where easy_intall
REM Output will show multiple paths if multiple versions of Pythons are installed. Choose the one in same directory where pip3 installed like above.
"<Drive Letter>:\path\to\easy_install.exe" -U pip
REM E.g.: "C:\Users\Foo\AppData\Local\Programs\Python\Python38\Scripts\easy_install.exe" -U pip
@harshithjv
harshithjv / Find_LAN_IPs_on_Nix_bash.md
Last active September 1, 2022 09:08
Find all IP address on LAN through windows or *nix command

Run ifconfig and find machine IP. Determine subnet of that IP:

$ ifconfig

If "inet" section says 10.0.0.12 then 'broadcast' section on same line will be '10.0.0.255.' Therefore we need to loop from 10.0.0.1 to 10.0.0.255.

ifconfig command not found

In linux you can run ip command if ifconfig not found:

What is UAC prompt?

Some programs require elevated permission to run on Windows. As an example you get below dialog that asks for your approval to allow or deny 'regedit' to run:

UAC Prompt for Regedit

(Image source: Refer link at Reference section)

Enviroment variable to bypass UAC

Type is cat of CMD

type \Path\To\File

E.g.:

C:\> type .\a_file.txt

This is the file content...

@harshithjv
harshithjv / Compress_to_H265_format.md
Last active June 27, 2020 17:28
Compress to H265 standard via ffmpeg command on Windows

Compress video to H265 format at 3500kbits/sec in 2 passes

MKDIR out

SET VIDEO_BITRATE=3500

SET AUDIO_BITRATE=128

FOR %i IN (*.MP4) DO ffmpeg -y -i %i -c:v libx265 -b:v %VIDEO_BITRATE%k -x265-params pass=1 -an -f mp4 NUL && ffmpeg -i %i -c:v libx265 -b:v %VIDEO_BITRATE%k -x265-params pass=2 -c:a aac -b:a %AUDIO_BITRATE%k out\%i

FOR %i IN (*.CR2) DO "C:\Program Files\7-Zip\7z.exe" a -mx9 "%~ni.CR2.7z" "%i"