Skip to content

Instantly share code, notes, and snippets.

Avatar

Rafael E. Belliard rebelliard

View GitHub Profile
View flatten.js
/**
* Recursively flatten an array.
* @example
* input: [[1,2,[3]],4]
* output: [1,2,3,4]
**/
function flatten(current) {
let accumulator = []
if (Array.isArray(current)) {
// Process the nested array.
@rebelliard
rebelliard / cycle_mouse_on_display.py
Last active Dec 7, 2017
[Ubuntu] Cycle the mouse between displays
View cycle_mouse_on_display.py
#!/usr/bin/python3
'''
[Ubuntu] Cycle the mouse between displays.
Suggestion: setup keyboard shortcuts such as:
- "super + tab" to "cycle_mouse_on_display.py"
- "super + shift + tab" to "cycle_mouse_on_display.py --reverse"
- Tested on Ubuntu 17.04.
@rebelliard
rebelliard / .flowconfig
Created Apr 6, 2017
Generated .flowconfig on react-native 0.43.1 with only an updated flow-bin version at 0.43.1
View .flowconfig
[ignore]
; We fork some components by platform
.*/*[.]android.js
; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.buckd/
; Ignore unexpected extra "@providesModule"
.*/node_modules/.*/node_modules/fbjs/.*
@rebelliard
rebelliard / flatten.js
Created Jul 27, 2016
Flatten array in JavaScript
View flatten.js
// Input:
// [[1,2,[3]],4]
// Output:
// [1,2,3,4]
Array.prototype.flatten = function() {
return this.reduce(function(previousValue, currentValue) {
let value = Array.isArray(currentValue) ? currentValue.flatten() : currentValue;
return previousValue.concat(value);
}, new Array());
}
You can’t perform that action at this time.