Skip to content

Instantly share code, notes, and snippets.

View nicStuff's full-sized avatar

Nicola Baisero nicStuff

View GitHub Profile
Math.mult = function(a, b) {
var aSplitted = a.toString().split('.');
var bSplitted = b.toString().split('.');
var aDelta = (aSplitted[1] ? aSplitted[1] : "").length;
var bDelta = (bSplitted[1] ? bSplitted[1] : "").length;
// a * b
return ((a * Math.pow(10, aDelta)) * (b * Math.pow(10, bDelta))) / (Math.pow(10, aDelta) * Math.pow(10, bDelta));
};
@nicStuff
nicStuff / mifcs.rb
Last active March 23, 2020 00:15
Simple ruby script that renames all .jpg/.mov/.nef files in the given folder to a name containing the exif creation timestamp (for jpg/nef) and modification time (for mov). Scales images using imagemagick in a folder
##########################################################################################################
##########################################################################################################
##########################################################################################################
###### Mass Image Filename Corrector and Scaler
##########################################################################################################
################################################ [rename] Renaming
######
###### Renames jpeg/nef/mov/mp4 files from xxxx.jpg, to a timestamp filename, like
###### 2015.05.28_15.33.22.jpg, using the date in exif field Exif.Photo.DateTimeOriginal for
###### images, and using file modification time for .mov/.mp4
@nicStuff
nicStuff / redis-migrate.sh
Last active October 17, 2023 07:30
Comfort tool for migrating redis keys among instances. Supports KEYS syntax matching, authentication and TTL
#!/bin/bash
######
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
# TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
######
// simple benchmark for reversing a string in js - source https://medium.com/quick-code/5-ways-to-reverse-a-string-in-javascript-466f62845827
function reverseFor(str){
let reversed = "";
for (var i = str.length - 1; i >= 0; i--){
reversed += str[i];
}
return reversed;
}
function reverseArray(str){
return str.split("").reverse().join("");