Skip to content

Instantly share code, notes, and snippets.

View chrishna1's full-sized avatar
🎯
Uncovering one layer of abstraction at a time

Bal Krishna Jha chrishna1

🎯
Uncovering one layer of abstraction at a time
View GitHub Profile
@chrishna1
chrishna1 / bash_strict_mode.md
Created July 8, 2025 20:45 — forked from mohanpedala/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation
@chrishna1
chrishna1 / latency.txt
Created March 18, 2022 14:20 — forked from meetchandan/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
['log', 'warn'].forEach(function(method) {
var old = console[method];
console[method] = function() {
var stack = (new Error()).stack.split(/\n/);
// Chrome includes a single "Error" line, FF doesn't.
if (stack[0].indexOf('Error') === 0) {
stack = stack.slice(1);
}
var args = [].slice.apply(arguments).concat([stack[1].trim()]);
return old.apply(console, args);
@chrishna1
chrishna1 / listen.js
Created June 29, 2021 06:48
listen all the events in browser
Object.keys(window).forEach(item=> { item.startsWith("on") && console.log(item); document.addEventListener(item.replace('on', ''), ()=>{console.log(item.replace('on', '') + " event")}) })
@chrishna1
chrishna1 / save.js
Created April 16, 2020 11:10
Save console object into JSON file
// (credits: http://programandconquer.com/save-console-browser-json-file/)
(function(console){
console.save = function(data, filename){
if(!data) {
console.error('Console.save: No data')
return;
}
@chrishna1
chrishna1 / download-script.sh
Created March 15, 2019 10:26 — forked from amit-chahar/download-script.sh
Scirpt to download files from Google drive using curl (Detailed explanation can be read here: https://stackoverflow.com/a/49444877/4043524)
#!/bin/bash
fileid="FILEIDENTIFIER"
filename="FILENAME"
curl -c ./cookie -s -L "https://drive.google.com/uc?export=download&id=${fileid}" > /dev/null
curl -Lb ./cookie "https://drive.google.com/uc?export=download&confirm=`awk '/download/ {print $NF}' ./cookie`&id=${fileid}" -o ${filename}
PATH_TO_CKPT = MODEL
# setup tensorflow graph
self.detection_graph = tf.Graph()
with self.detection_graph.as_default():
od_graph_def = tf.GraphDef()
with tf.gfile.GFile(PATH_TO_CKPT, 'rb') as fid:
serialized_graph = fid.read()
od_graph_def.ParseFromString(serialized_graph)
tf.import_graph_def(od_graph_def, name='')
@chrishna1
chrishna1 / vpn.md
Created June 2, 2018 19:04 — forked from joepie91/vpn.md
Don't use VPN services.

Don't use VPN services.

No, seriously, don't. You're probably reading this because you've asked what VPN service to use, and this is the answer.

Note: The content in this post does not apply to using VPN for their intended purpose; that is, as a virtual private (internal) network. It only applies to using it as a glorified proxy, which is what every third-party "VPN provider" does.

(A Russian translation of this article can be found here, contributed by Timur Demin.)

Why not?

@chrishna1
chrishna1 / Google_Colaboratory_backup.py
Created May 30, 2018 16:03 — forked from rdinse/Google_Colaboratory_backup.py
Simple Google Drive backup script with automatic authentication for Google Colaboratory (Python 3)
# Simple Google Drive backup script with automatic authentication
# for Google Colaboratory (Python 3)
# Instructions:
# 1. Run this cell and authenticate via the link and text box.
# 2. Copy the JSON output below this cell into the `mycreds_file_contents`
# variable. Authentication will occur automatically from now on.
# 3. Create a new folder in Google Drive and copy the ID of this folder
# from the URL bar to the `folder_id` variable.
# 4. Specify the directory to be backed up in `dir_to_backup`.