Skip to content

Instantly share code, notes, and snippets.

@bitifet
bitifet / NextCloud_Hacks.md
Last active July 12, 2018 17:43
NextCloud Hacks

My personal NextCloud hacks

fixletime.sh

Script to 'touch' media (photo / video) files to the time that they have been taken (according available information: exif headers, filename patterns..).

@bitifet
bitifet / nodeEnsaimeitor.js
Created September 12, 2017 15:27
NodeJS Ensaimeitor Draft.
// Node Ensaimeitor Draft.
// Thanks to http://ensaimeitor.apsl.net/
"use strict";
const srvHost = "ensaimeitor.apsl.net";
const srvPort = 80;
const index = {//{{{
fiscal: "NIF's",
cif: "CIF's",
@bitifet
bitifet / arrayFall.js
Last active September 4, 2017 05:41
Sequential waterfall over array of promisorys.
// Performs sequential waterfall over array of promisorys.
// Following two sentences:
// var P = Promise.all(inArr.map(cbk))
// var P = arrayfall(inArr, cbk)
// ...are pretty much the same.
// Both runs all promises sequentially and returns new promise resolving with
// an array with resolved data (if none rejected).
// But in the former all promises are run as fast as input array is scanned.
// Whereas with arrayfall() promises are executed in sequence: each after
// previous one is resolved (or rejected) even being completely asyncronous.
@bitifet
bitifet / cpd.sql
Created July 13, 2017 09:01
PostgreSQL long term IDLE processes disconnection.
-- CPD.sql - Crappy Processes Disconnection
-- ----------------------------------------
--
-- Close PostgresSQL connections left IDLE forever by crappy processes.
--
--
-- Credits: https://stackoverflow.com/questions/12391174/how-to-close-idle-connections-in-postgresql-automatically?answertab=active#tab-top
--
-- Minimum inactivity interval to
@bitifet
bitifet / jsDateTime.js
Last active March 21, 2017 06:24
Miscellaneous JavaScript Date/Time Helpers.
function dateParse(d){// Parse date in "dd/mm/yyyy" format. {{{
d = d.split("/");
return new Date(
parseInt(d[2])
, parseInt(d[1]) - 1
, parseInt(d[0])
);
};//}}}
function dateCmp (d1, d2){// Compare dates (returning -1, 0, 1). {{{
@bitifet
bitifet / pgclone
Last active January 6, 2024 15:49
Instantly clone PostgreSQL databases thought btrfs subvolumes.
#!/usr/bin/env bash
# SETUP EXAMPLE:
# --------------
#
# # Install btrfs-tools:
# sudo apt-get install btrfs-tools
#
# # Create btrfs filesystem across one or more divices:
# # -> Check device names!!
@bitifet
bitifet / jasmine_checkEquals.js
Last active November 12, 2015 05:53
Jasmine templates
// checkEquals (fn, tests) - Helper function to build equality tests with Jasmine.
function checkEquals(fn, tests){
if (fn instanceof Array) { // Allow to specify as ["this", fn] if required.
var target = fn[0]; // this
fn = fn[1];
} else { // fn expected to be a single functin by default.
var target = this; // Or any other arbitrary value.
};
return function(){
tests.map(function(t){
@bitifet
bitifet / inspect_even_circular.js
Last active November 3, 2015 07:35
Circular-references aware inspect() function.
// util.inspect() alternative returning always valid JSON even having circular refernces.
// Only for debugging and inspection purposes.
// Intended to be used in conjunction with underscore. Ex: "underscore print --color"
// Also useful with my lovely javascript inspection vim mappings:
// https://github.com/bitifet/dotfiles/blob/master/.vim/after/syntax/javascript/SyntaxInclude.vim
var inspect = (function(){
var utilInspect = require("util").inspect;
return function inspect (obj) {
var result;
var str = "var Circular = \"(->CIRCULAR<-)\";\n";
@bitifet
bitifet / astack.js
Created October 24, 2015 09:40
Asynchronous stack (LIFO)
"use strict";
var stack = (function(){
function _stack(){
this.stack = [];
this.queue = [];
};
_stack.prototype.push = function stack_push(data){
@bitifet
bitifet / perSchema_plv8_init.js.sql
Last active October 6, 2016 13:11
Allow per-schema plv8_init functions.
/* public.plv8_startup()
*
* Allow to have multiple per-schema plv8_init functions.
*
* USAGE:
*
* 1. Add the following line to the end of your postgresql.conf file:
*
* plv8.start_proc = 'public.plv8_startup'
*