Skip to content

Instantly share code, notes, and snippets.

View ben8p's full-sized avatar

Benjamin Santalucia ben8p

View GitHub Profile
@ben8p
ben8p / cloudSettings
Created December 5, 2019 09:59
Visual Studio Code Settings Sync Gist
{"lastUpload":"2019-12-05T09:59:36.024Z","extensionVersion":"v3.4.3"}
@ben8p
ben8p / drive.js
Created December 6, 2018 14:36
Get GoogleDrive direct download link, even for large files
/*
replace XXX by the id of the file you want to download. You can add as many as you want
to get the ID, first get the share URL :
https://drive.google.com/file/d/1LHsdf3leinq1wCertnwFVGertertHrfB/view?usp=sharing
the id in this example is :
1LHsdf3leinq1wCertnwFVGertertHrfB
*/
const https = require('https');
[
'XXX',
@ben8p
ben8p / readme.md
Last active October 22, 2023 13:02
What to do after installing linux

What to do after installing linux

Prevent freeze at boot

add nouveau.modeset=0 to to GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub
and run
sudo update-grub2

SSD optimizations

No Writes for Read Timestamps

@ben8p
ben8p / git.sh
Last active August 12, 2021 23:04
Git cheatsheet
# Rename local and remote branch
OLD_BRANCH=name_of_old_branch # Replace with the name of your old branch
NEW_BRANCH=name_of_new_branch # Replace with the name of the new branch
git checkout $OLD_BRANCH
git pull
git branch -m $OLD_BRANCH $NEW_BRANCH
git push origin :$OLD_BRANCH --no-verify
git push --set-upstream origin $NEW_BRANCH --no-verify
##################################################################################################################
@ben8p
ben8p / CSVParser.js
Created December 16, 2016 11:59
CSV parser
/**
* CSV Parser. Takes a string as input and returns
* an array of arrays (for each row).
*
* @param input String, CSV input
* @param options.delimiter String, single character used to separate fields.
* Defaults to null, if null, tries to guess it.
* @param doptions.quote String, single character used to quote non-simple fields.
* Defaults to "\"".
*/
@ben8p
ben8p / BinaryTree.js
Created July 4, 2016 07:24
Binary tree in JS (Breadth first search, insort, insert)
/** recursively search in the tree where the current value can be inserted */
function find(value, node) {
if(node.value === undefined || node.value === value) {
return node;
}
if(node.value > value) {
return find(value, node.left);
}
return find(value, node.right);
}
@ben8p
ben8p / The Technical Interview Cheat Sheet.md
Last active July 14, 2016 18:41 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Tech Interview Cheat Sheet

Data Structure Basics

Array

Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples (a finite ordered list of elements) from set theory.
  • They are one of the oldest, most commonly used data structures.
@ben8p
ben8p / flatten.js
Created May 31, 2016 12:57
flatten an array of arbitrarily nested arrays of integers into a flat array of integers
var data = [[1,2,[3,4,[5,6]]],7];
function flatten(array) {
var output = [];
array.forEach(function(value) {
if(value instanceof Array) {
output = output.concat(flatten(value));
} else {
output.push(value)
}