Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@j0nathanB
j0nathanB / exifRotate.js
Created November 4, 2019 06:58
// gets a stream of images, reads the exif data, and adjusts orientation appropriately
// gets a stream of images, reads the exif data, and adjusts orientation appropriately
// piexif: https://github.com/hMatoba/piexifjs
var imgs = document.querySelectorAll("img")
// main part
imgs.forEach( img => {
toDataURL(img.src)
.then( xhr => resToBlob(xhr.response) )
.then( blob => {
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('Update Jobs')
.addItem('Get New Jobs','getNewestJobs')
.addToUi();
}
function fetchModeData() {
var options = {
headers: {
@j0nathanB
j0nathanB / trimBST.js
Created December 12, 2017 16:15
Trim BST
var trimBST = function(root, L, R) {
if (root === null) {
return null;
}
root.left = trimBST(root.left, L, R);
root.right = trimBST(root.right, L, R);
if (root.val < L) {
return root.right;
@j0nathanB
j0nathanB / mergeTrees.js
Created December 6, 2017 22:04
Merge Trees
var mergeTrees = function(t1, t2) {
let sum;
let leftNode1 = null;
let leftNode2 = null;
let rightNode1 = null;
let rightNode2 = null;
if (t1 === null && t2 === null) {
return null;
} else if (t1 === null) {
@j0nathanB
j0nathanB / gist:babba47f19fd0161e5fb9ad8b3afc967
Last active October 16, 2017 04:10
Updating git remotes
git remote rm heroku
heroku git:remote -a newname
https://devcenter.heroku.com/articles/renaming-apps#updating-git-remotes
@j0nathanB
j0nathanB / Reverse Number
Created October 6, 2017 16:12
Can be used to reverse strings
var reverse = function(x) {
let num = x > 0 ? x : -x;
let reversedNum = Number(num.toString().split('').reverse().join(''));
//for overflow
if ( (reversedNum >> 0) !== reversedNum ) {
return 0;
}
return x > 0 ? reversedNum : -reversedNum;
let fs = require ('fs');
let dir = '/root/devops';
fs.readdir(dir, 'utf8', (err, data) => {
if (err) {
console.log("ERROR! ", err);
return;
} else {
//console.log("SUCCESS! ", data);
readFiles(data);
@j0nathanB
j0nathanB / gist:1b674eea86c71928efa472266dbe06c9
Created September 6, 2017 09:43
Latin American keyboard layout
https://github.com/neosergio/Latam-Keyboard
Things like snippets tend to gravitate towards the bottom.
To bump them to the top, despite their length, add this to your VSCode settings:
"editor.snippetSuggestions": "top"
"Print to console": {
"prefix": "cons",
"body": [
"console.log('$1');",
],
"description": "Log output to console"