Skip to content

Instantly share code, notes, and snippets.

View navtej's full-sized avatar

Navtej Singh navtej

  • Patiala, Panjab, India
  • 17:08 (UTC +05:30)
View GitHub Profile
@navtej
navtej / google_pdf_to_doc.js
Created October 21, 2023 15:52
Gist to bulk convert PDF files to editable google documents using Google AppScript
// pieced together from various online sources. Meat of the logic in fn convertFile came from SO answer.
// the script moves the original pdf to trash after conversion. You might want to change that.
function getFilesList(folder, filetype) {
var allfiles = new Array();
const files = folder.getFilesByType(filetype);
while (files.hasNext()) {
var file = files.next();
allfiles.push(file);
}
@navtej
navtej / fix_virtualenv
Created July 22, 2019 20:06 — forked from tevino/fix_virtualenv
Fix python virtualenv after python update
#!/usr/bin/env bash
ENV_PATH="$(dirname "$(dirname "$(which pip)")")"
SYSTEM_VIRTUALENV="$(which -a virtualenv|tail -1)"
BAD_ENV_PATHS="/usr/local"
echo "Ensure the root of the broken virtualenv:"
echo " $ENV_PATH"

Keybase proof

I hereby claim:

  • I am navtej on github.
  • I am nsbuttar (https://keybase.io/nsbuttar) on keybase.
  • I have a public key ASDzGy9U324k2ryf5KqeY5n6gIIrX7SNPMDPbDqsWeYKyQo

To claim this, I am signing this object:

@navtej
navtej / latency.md
Created September 4, 2017 17:52 — forked from marianposaceanu/latency.md
Latency numbers every programmer should know

CPU

  • L1 cache reference 0.5 ns
  • Branch mispredict 5 ns (on a bad CPU architecture you're pretty much screwed)
  • L2 cache reference 7 ns
  • Mutex lock/unlock 25 ns
  • Main memory reference 100 ns
  • Compress 1K bytes with Zippy 3,000 ns
  • Send 2K bytes over 1 Gbps network 20,000 ns
  • Read 1 MB sequentially from memory 250,000 ns
@navtej
navtej / browser_console.js
Created August 6, 2016 11:36
Some Functions TO work With Tabs Using MozRepl/Browser Console
/* From some a gist by someone */
function next_tab_by_title(title_re) {
var tabContainer = window.getBrowser().tabContainer;
var tabs = tabContainer.childNodes;
var numTabs = tabs.length;
var startIndex = tabContainer.selectedIndex;
var testIndex;
for (i = 0; i < numTabs - 1; i++) {
testIndex = (startIndex + i + 1) % numTabs;
@navtej
navtej / container.xml
Created October 28, 2015 15:22 — forked from anqxyr/archived
Create EPUB files with Python
<?xml version='1.0' encoding='UTF-8'?>
<container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" version="1.0">
<rootfiles>
<rootfile media-type="application/oebps-package+xml" full-path="content.opf"/>
</rootfiles>
</container>
@navtej
navtej / Invoke and track memory usage of one process in linux
Created April 11, 2015 06:42
Invoke and track memory usage of one process in linux
#source : http://superuser.com/a/620051
#!/usr/bin/env bash
## Print header
echo -e "Size\tResid.\tShared\tData\t%"
while [ 1 ]; do
## Get the PID of the process name given as argument 1
pidno=`pgrep $1`
## If the process is running, print the memory usage
if [ -e /proc/$pidno/statm ]; then