This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
if (location.href.indexOf("credits") !== -1) { | |
if (location.hash.length) { | |
var hash = location.hash; | |
var book = hash.split("-"); | |
var hashFinalDone = false; | |
if (book[0]) { | |
book = book[0].split("#book")[1]; | |
book = parseInt(book[0]); | |
if (isNaN(book)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! | |
Math.uuid.js (v1.4) | |
http://www.broofa.com | |
mailto:robert@broofa.com | |
Copyright (c) 2010 Robert Kieffer | |
Dual licensed under the MIT and GPL licenses. | |
*/ | |
/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
codes coordinates TZ comments | |
AD +4230+00131 Europe/Andorra | |
AE,OM +2518+05518 Asia/Dubai | |
AF +3431+06912 Asia/Kabul | |
AL +4120+01950 Europe/Tirane | |
AM +4011+04430 Asia/Yerevan | |
AQ -6617+11031 Antarctica/Casey Casey | |
AQ -6835+07758 Antarctica/Davis Davis | |
AQ -6640+14001 Antarctica/DumontDUrville Dumont-d'Urville | |
AQ -6736+06253 Antarctica/Mawson Mawson |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* usage | |
* | |
* const MyComp = (props) => { | |
useTraceUpdate(props) | |
return <span />; | |
}; | |
*/ | |
import { useRef, useEffect } from "react"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# to restart touchbar, when it is not responding or not working as expected | |
sudo pkill TouchBarServer | |
sudo killall “ControlStrip” | |
# 7zip handling in mac | |
brew install p7zip | |
p7zip x a.7z #extract module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#will list the calendar in the linux | |
cal | |
#Generate a sha256 sum of text | |
# for mac | |
echo -n <text> | shasum -a 256 | |
# for linux | |
echo -n <text> | sha256sum | |
# sort and list the directories by size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# delete local branches that no longer have remote reference | |
git fetch -p && for branch in $(git for-each-ref --format '%(refname) %(upstream:track)' refs/heads | awk '$2 == "[gone]" {sub("refs/heads/", "", $1); print $1}'); do git branch -D $branch; done | |
# delete files that are being ignored by git(.gitignore) under a directory | |
git clean -xdn # dry run all the files that will list all the gitignore files under the directory | |
git clean -xdf # to clean the files that are ignored | |
# to delete all the files in the git repo, execute the command in the root directory | |
# clone all repos of an org (requires ruby1.9+) | |
curl -s https://api.github.com/orgs/[ORGANIZATION]/repos | ruby -rjson -e 'JSON.load(STDIN.read).each {|repo| %x[git clone #{repo["ssh_url"]} ]}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// IIFE - to print the trace where alert raised from | |
// Doesn't impact the alert behavior or any other behavior of your front end | |
// Add this code in your javascript or run it in console of your browser | |
// After adding, console will have stack trace of the alert printed | |
(function(proxied) { | |
window.alert = function() { | |
console.trace(); | |
return proxied.apply(this, arguments); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//2d peak | |
// algo 1, a combination of binary search along columns with brute force to find global maximum | |
#include<bits/stdc++.h> | |
using namespace std; | |
int m,n; | |
// to find global maximum in a given column | |
// helper function | |
int peakone(int **arr,int j,int n){ | |
int max = 0; | |
for(int i=1;i<n;i++){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1d peak finding problem in lecture 1 | |
// peak referred to local maximum | |
// there will be multiple local maximum, we need to find atleast one | |
#include<bits/stdc++.h> | |
using namespace std; | |
int peak(int arr[],int start,int end,int n){ | |
int mid = start + (end-start)/2; | |
//checking mid index elemenet as peak by comparing with neighbours if the neighbours exist |