Skip to content

Instantly share code, notes, and snippets.

View lfsmoura's full-sized avatar
🏠
Working from home

Leonardo Moura lfsmoura

🏠
Working from home
View GitHub Profile
@lfsmoura
lfsmoura / quicksort.cpp
Created September 15, 2021 16:18
Quicksort in C++ three lines
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
void q(std::vector<int>::iterator b, std::vector<int>::iterator e) {
auto d = std::partition(b, e, [&](int s) { return s <= *b; });
if (b < e) q(b, d - 1), q(d, e);
}
@lfsmoura
lfsmoura / dialog.js
Created July 28, 2018 23:16
File exists, confirm dialog, Electron
function fileExists(path) {
try {
return fs.statSync(path);
} catch (e) {
return false;
}
}
const exist = fileExists(path);
if (exist) {