Skip to content

Instantly share code, notes, and snippets.

View hperantunes's full-sized avatar

Hilton Perantunes hperantunes

  • Montreal, Canada
View GitHub Profile
export const sumObjects = (first, second) => Object.keys(second).reduce((object, key) => ({
...object,
[key]: (first[key] || 0) + (second[key] || 0)
}), {});
export const findInObject = (combinedPath, object, separator = ".") => {
if (combinedPath === undefined) {
return undefined;
}
const path = combinedPath.split(separator);
return path.reduce((accumulator, value) => ((accumulator && accumulator[value] !== undefined) ? accumulator[value] : undefined), object);
};
/**
* 1D noise generator function.
* Inspired by https://codepen.io/Tobsta/post/procedural-generation-part-1-1d-perlin-noise
*
* @param {string} seed Initializes the pseudorandom number generator (default empty)
* @param {number} width Total number of points in the generated noise line (default 1)
* @param {number} amplitude Height of the wave (default 128)
* @param {number} wavelength Distance between the peaks of each wave (default 128)
* @param {number} octaves How many noise lines will be combined together (default 8)
* @param {number} divisor Number by witch each noise line will be divided (default 2)
setInterval(function() {
document.getElementsByClassName('pl-video-edit-remove')[0].click();
}, 2000);
@hperantunes
hperantunes / settings.json
Last active June 14, 2018 06:07
vscode settings.json
// Place your settings in this file to overwrite the default settings
{
"terminal.integrated.shell.windows": "c:\\windows\\system32\\cmd.exe",
"terminal.integrated.shellArgs.windows": [
"/k",
"c:\\program files\\git\\bin\\bash.exe"
],
"editor.minimap.renderCharacters": false,
"extensions.ignoreRecommendations": false,
"git.autofetch": true
@hperantunes
hperantunes / index.js
Created June 16, 2017 21:02
requirebin sketch
// Welcome! require() some modules from npm (like you were using browserify)
// and then hit Run Code to run your code on the right side.
// Modules get downloaded from browserify-cdn and bundled in your browser.
const GitHub = require('github-api');
const gh = new GitHub();
const me = gh.getUser('hperantunes');
me.listStarredRepos((err, repos) => {
@hperantunes
hperantunes / .bashrc
Created March 18, 2017 03:16
meteor -> git bash
alias meteor="cmd //c meteor"
// Newlines, tabs and non-printable unicode characters
private static final String sanitizePattern = "(\\r|\\n|\\t|\\p{C})";
private static final String whitespacePattern = " +";
private static final String replacementString = " ";
private static String sanitize(String text) {
return text.replaceAll(sanitizePattern, replacementString);
}
{
"editor.tabSize": 2,
"editor.renderWhitespace": "none",
"workbench.iconTheme": "vs-seti",
"editor.minimap.enabled": true,
"terminal.integrated.shell.windows": "c:\\windows\\system32\\cmd.exe",
"terminal.integrated.shellArgs.windows": [
"/k",
"c:\\program files\\git\\bin\\bash.exe"
],
@hperantunes
hperantunes / rename.ps1
Created February 22, 2017 15:13
Powershell batch rename files; remove whitespace and parentheses
Dir | Rename-Item –NewName { $_.name.replace(' ','_') -replace '[()]','' }