Skip to content

Instantly share code, notes, and snippets.

View harshithjv's full-sized avatar

Harshith J. V. harshithjv

  • Mangalore
  • 09:44 (UTC +05:30)
View GitHub Profile
@harshithjv
harshithjv / IntegrateDjangoWithPyTransitionsLib.Readme.md
Last active May 26, 2021 13:48
Integrating django model and transitions library without django-transitions library

By default, state variable is attached to any model object that is passed to Machine object initalisation in transitions library. Passing model_attribute will allow us to define custom state attribute. This wasn't obvious while going through the document. TL;DR 📖🥱😜

https://github.com/pytransitions/transitions

Also django-transitions is like experimental repo and maintained since Jan 2019. So I was looking for the solution without using it. Even if we use it mentioned only about setting custom name in Mixins. Does not make sense to just to use mixins for custom variables. So example I shown in models.py is better way. Next, I need to see how I can inherit this feature into custom ModelField class.

Sample execution:

$ ./manage.py shell
iters = 100000 # limit I reached on firefox: 500000
# limit I reached on chrome : 125838
subsPerfTable = [];
[...Array(iters).keys()].forEach(() => {
a = performance.now();
"2020-08-10".substring(0,10) === "2020-08-10T00:00:55Z".substring(0,10);
b = performance.now();
subsPerfTable.push(b-a);
# Run below commands manually or download this file and run on the terminal. */
gsettings set org.gnome.desktop.wm.keybindings switch-windows "['<Alt>Tab']"
gsettings set org.gnome.desktop.wm.keybindings switch-windows-backward "['<Shift><Alt>Tab']"
gsettings set org.gnome.desktop.wm.keybindings switch-applications "['']"
gsettings set org.gnome.desktop.wm.keybindings switch-applications-backward "['']"
# Thanks to this answer: https://superuser.com/a/1029822
# It frustrating to select window when grouped according to application thereby making it less productive.
gsettings set org.gnome.shell.app-switcher current-workspace-only true
# Reference: https://askubuntu.com/a/759740
# Check this gist on how to use this command and other command for better workspace experience:
# https://gist.github.com/harshithjv/d3f6e954a9f4bac57e0d2f681b6c32b8
@harshithjv
harshithjv / DateLocaleOptions.js
Last active July 17, 2020 05:18
Retrieve Formatted items individual items of Date in JavaScript. (ECMAScript Internationalization API (ECMA-402))
// Reference for Locale String options: https://tc39.es/ecma402/#sec-datetimeformat-abstracts
// MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString,
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat
// ISO or JSON date string conversion
var d = new Date('2020-07-17T05:01:16.759Z')
// partial ISO string also allowed
var d1 = new Date('2020-07-17T05:01')

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

@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

Type is cat of CMD

type \Path\To\File

E.g.:

C:\> type .\a_file.txt

This is the file content...