Skip to content

Instantly share code, notes, and snippets.

View mohnish's full-sized avatar
🤗
❤️

~/mohnish mohnish

🤗
❤️
View GitHub Profile
@mohnish
mohnish / levenshtein.js
Last active March 11, 2024 05:57
Calculating Edit Distance between 2 strings using Levenshtein's algorithm
function editDistance(word1, word2) {
return levenshteinDistance(word1, word2, 0, 0);
}
function levenshteinDistance(word1, word2, i, j) {
if (i == word1.length) {
return word2.length - j;
} else if (j == word2.length) {
return word1.length - i;
} else {
@mohnish
mohnish / binarySearch.js
Last active October 1, 2022 04:24
Binary Search in JavaScript
function binarySearch(list, key) {
let low = 0;
let high = list.length - 1;
while (low <= high) {
let mid = low + Math.floor((high - low) / 2);
if (key < list[mid]) {
high = mid - 1;
} else if (key > list[mid]) {
@mohnish
mohnish / readline_bundle_image_not_found.md
Created February 14, 2020 00:22 — forked from zulhfreelancer/readline_bundle_image_not_found.md
How to fix 'readline.bundle image not found' problem?

If you get error like this:

Running via Spring preloader in process 7662
/Users/zulh/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require': dlopen(/Users/zulh/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle, 9): Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib (LoadError)
  Referenced from: /Users/zulh/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle
  Reason: image not found - /Users/zulh/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle
	from /Users/zulh/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `block in require'
	from /Users/zulh/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
	from /Users/zulh/.rvm/gems/ruby-2.3.1@useradmin/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'

Fixing macOS Mojave

Dark main menu without the rest of dark mode

  1. Set Light mode
  2. defaults write -g NSRequiresAquaSystemAppearance -bool Yes
  3. Log out and log back in
  4. Set Dark mode
@mohnish
mohnish / keybindings.js
Created August 6, 2019 17:07
keybindings.json
// Place your key bindings in this file to override the defaultsauto[]
[
{
"key": "cmd+k up",
"command": "workbench.action.newGroupAbove"
},
{
"key": "cmd+k down",
"command": "workbench.action.newGroupBelow"
},
@mohnish
mohnish / settings.js
Created August 6, 2019 17:05
settings.json
{
editor.cursorBlinking: "smooth",
editor.fontFamily: "SF Mono",
editor.fontSize: 13,
editor.fontLigatures: true,
editor.minimap.enabled: false,
editor.rulers: [
60,
80
],
@mohnish
mohnish / nginxproxy.md
Created March 12, 2018 08:00 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@mohnish
mohnish / Mintty.md
Last active February 23, 2024 17:03 — forked from appikonda/Mintty.md
Mintty Themes for Windows

Create .mintty folder with subfolder themes in c:\Users\< >

 Example:
 C:\Users\sandeep\.mintty\themes

Download '.minttyrc' files from https://github.com/iamthad/base16-mintty and add them to themes folder.

/**
* Setup.
*/
const items = document.querySelectorAll('.Page')
const links = document.querySelectorAll('.Menu a')
/**
* Check if `el` is out out of view.
*/
@mohnish
mohnish / update.js
Created April 9, 2017 19:34 — forked from tj/update.js
shouldComponentUpdate utility
let rows = {}
export default function(props = [], state = []) {
return function(target) {
const proto = Object.create(target.prototype)
proto.shouldComponentUpdate = function(newProps, newState) {
let id = (this._update_id = this._update_id || Math.random())