This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const myArr = [[1,2,[3]],4]; | |
const flatten = list => list.reduce( | |
(a, b) => a.concat(Array.isArray(b) ? flatten(b) : b), [] | |
); | |
flatten(myArr); // [1, 2, 3, 4,] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# With some access point my wifi loses connection | |
# The connection is usually restored as long I reconnect to the AP | |
# This script detects ping failure to the Google DNS server | |
# then try to turn off and on wifi network | |
# WARNING: It does not check the default WiFi to reconnect to | |
status="OFF"; | |
while true | |
do | |
if ping -q -c 1 -W 1 8.8.8.8 &>/dev/null;then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ "{% if form_filter is defined %}" }} | |
<div class="accordion" id="record_filter"> | |
<div class="accordion-group"> | |
<div class="accordion-heading"> | |
<a class="accordion-toggle" data-toggle="collapse" data-parent="#record_filter" href="#record_filter_collapse"> | |
<i class="icon-search"></i> Filtra risultati | |
</a> | |
</div> | |
<div id="record_filter_collapse" class="accordion-body collapse{{ "{{ filter is defined and filter ? ' in' : '' }}" }}"> | |
<div class="accordion-inner"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function addXhrProgressEvent($) { | |
var originalXhr = $.ajaxSettings.xhr; | |
$.ajaxSetup({ | |
progress: function() { console.log("standard progress callback"); }, | |
xhr: function() { | |
var req = originalXhr(), that = this; | |
if (req) { | |
if (typeof req.addEventListener == "function") { | |
req.addEventListener("progress", function(evt) { | |
that.progress(evt); |