Skip to content

Instantly share code, notes, and snippets.

View jacobkahn's full-sized avatar

Jacob Kahn jacobkahn

View GitHub Profile
@jacobkahn
jacobkahn / checkboxes.js
Created April 8, 2016 01:49
Check all checkboxes on a page with Javascript
(function() {
var aa = document.querySelectorAll("input[type=checkbox]");
for (var i = 0; i < aa.length; i++){
aa[i].checked = true;
}
})()
@jacobkahn
jacobkahn / .flowconfig
Created August 24, 2016 04:30
Flow Config that works with Create React App and Nuclide
[libs]
./node_modules/fbjs/flow/lib
[options]
esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable
module.name_mapper='^\(.*\)\.css$' -> 'react-scripts/config/flow/css'
module.name_mapper='^\(.*\)\.\(jpg\|png\|gif\|eot\|otf\|webp\|svg\|ttf\|woff\|woff2\|mp4\|webm\)$' -> 'react-scripts/config/flow/file'
@jacobkahn
jacobkahn / pageCropper.py
Created March 2, 2017 21:48
Crops a PDF printout with multiple pages and aggregates into a single page.
import copy
from pyPdf import PdfFileWriter, PdfFileReader
input1 = PdfFileReader(file("in.pdf", "rb"))
output = PdfFileWriter()
numPages = input1.getNumPages()
for i in range(numPages):
masterPage = input1.getPage(i)
aggPageCollection = []
### Keybase proof
I hereby claim:
* I am jacobkahn on github.
* I am jacobkahn (https://keybase.io/jacobkahn) on keybase.
* I have a public key ASDukhNuTuFa6zcYoIgKqZOl-Mk9yhwaeV0o1T-qUzkd0Qo
To claim this, I am signing this object:
@jacobkahn
jacobkahn / regexReplace.cpp
Created November 12, 2018 05:28
C++-compatible regex replace with only glibc regex.h
#include <regex.h>
std::string regexReplace(
const std::string& inStr,
const std::string& regexStr,
const std::string& repl) {
int ret = 0;
// Create expr
regex_t regex;
if ((ret = regcomp(&regex, regexStr.c_str(), REG_EXTENDED))) {
@jacobkahn
jacobkahn / unsubscribe.js
Created January 31, 2019 16:23
Unsubscribe from Repositories in an Org
function unwatchOrgRepos(orgName, repoNameFirstFourChars) {
var repoItems = document.querySelectorAll(".repo-list > li")
repoItems.forEach(function (item) {
var repoOrgElement = item.querySelector(".repo-name").previousElementSibling;
var repoElement = item.querySelector(".repo-name");
var repoOrgName = repoOrgElement.innerText;
if (repoOrgName === orgName && repoElement.innerHTML.substring(0, 4) == repoNameFirstFourChars) {
var unwatchButton = item.querySelector(".js-unsubscribe-form > button");
unwatchButton.click();
var itemName = repoOrgElement.parentElement.innerText;
@jacobkahn
jacobkahn / examParsing.py
Created March 5, 2019 22:04
CIS 320 Exam Parser
import uuid
from pyPdf import PdfFileWriter, PdfFileReader
for qq in range(1, 10):
inputpdf = PdfFileReader(open("in" + str(qq) + ".pdf", "rb"))
j = -1
for i in xrange(inputpdf.numPages):
print(i)
if i % 10 == 0:
@jacobkahn
jacobkahn / gist:a92f4425abf831ac0799fabe9079263d
Last active July 23, 2019 22:01
NCCL Tests on 2 node p3dn.24xlarge + EFA - all_reduce_perf -b 8 -e 1G -f 2 -g 1 -c 1 -n 100
#
# out-of-place in-place
# size count type redop time algbw busbw error time algbw busbw error
# (B) (elements) (us) (GB/s) (GB/s) (us) (GB/s) (GB/s)
8 2 float sum 163.4 0.00 0.00 2e-07 164.4 0.00 0.00 1e-07
16 4 float sum 162.9 0.00 0.00 1e-07 162.3 0.00 0.00 1e-07
32 8 float sum 164.1 0.00 0.00 1e-07 164.0 0.00 0.00 1e-07
64 16 float sum 163.6 0.00 0.00 1e-07 163.3 0.00 0.00 1e-07
128 32 float sum 164.1 0.00 0.00 1e-07 161.6 0.00 0.00 1e-07
256 64 float sum 162.5 0.00 0.00 1e-07 163.0 0.00 0.00 1e-07
@jacobkahn
jacobkahn / gist:1fb3977e99056b7935a6c63dda1e145f
Created July 23, 2019 22:02
NCCL Tests on 4 node p3dn.24xlarge + EFA - all_reduce_perf -b 8 -e 1G -f 2 -g 1 -c 1 -n 100
#
# out-of-place in-place
# size count type redop time algbw busbw error time algbw busbw error
# (B) (elements) (us) (GB/s) (GB/s) (us) (GB/s) (GB/s)
8 2 float sum 319.4 0.00 0.00 2e-07 319.2 0.00 0.00 0e+00
16 4 float sum 320.9 0.00 0.00 1e-07 319.0 0.00 0.00 1e-07
32 8 float sum 317.2 0.00 0.00 1e-07 318.1 0.00 0.00 1e-07
64 16 float sum 321.3 0.00 0.00 1e-07 318.4 0.00 0.00 1e-07
128 32 float sum 319.6 0.00 0.00 1e-07 319.4 0.00 0.00 1e-07
256 64 float sum 318.1 0.00 0.00 1e-07 318.9 0.00 0.00 1e-07
@jacobkahn
jacobkahn / gist:3150a1a38abba40f58d8263d9c55969f
Created July 23, 2019 22:03
NCCL Tests on 8 node p3dn.24xlarge + EFA - all_reduce_perf -b 8 -e 1G -f 2 -g 1 -c 1 -n 100
#
# out-of-place in-place
# size count type redop time algbw busbw error time algbw busbw error
# (B) (elements) (us) (GB/s) (GB/s) (us) (GB/s) (GB/s)
8 2 float sum 631.3 0.00 0.00 2e-07 632.3 0.00 0.00 0e+00
16 4 float sum 686.3 0.00 0.00 2e-07 631.1 0.00 0.00 2e-07
32 8 float sum 627.5 0.00 0.00 2e-07 628.7 0.00 0.00 2e-07
64 16 float sum 632.0 0.00 0.00 2e-07 629.6 0.00 0.00 1e-07
128 32 float sum 629.1 0.00 0.00 2e-07 628.8 0.00 0.00 2e-07
256 64 float sum 628.2 0.00 0.00 2e-07 628.3 0.00 0.00 2e-07