Skip to content

Instantly share code, notes, and snippets.

View claudiohilario's full-sized avatar
🎯
Focusing

Cláudio Hilário claudiohilario

🎯
Focusing
  • Guarda, Portugal
View GitHub Profile
@claudiohilario
claudiohilario / import-BC601.js
Created April 28, 2022 23:30
Convert DATA Tanita BC-601 to JSON (NodeJs)
/**
* Tanita BC-601 (Source of Interpretation: https://github.com/cab938/tanita)
*
* Usage example: import-BC601.js ~/inputFile.csv ~/outputFile.json
*/
const fs = require("fs");
const [inputFile, outputFile] = process.argv.slice(2);
const dictionary = {
@claudiohilario
claudiohilario / DbCreator.js
Last active November 1, 2021 18:29
Knex PG Example DbCreator class
const knex = require("knex");
class DbCreator {
/**
*
* Usage example:
* const DbCreator = require('./DbCreator)
* const dbConfigs = {
* host: "127.0.0.1",
* user: "postgres",
@claudiohilario
claudiohilario / fnExtractQueryParams.php
Last active October 11, 2020 01:40
Function to extract query params of the uri
<?php
/**
* Extract query params of the uri.
*
* @param $uri - The uri.
* E.g.: http://localhost:8080/users?limit=10&offset=10
*
* @return array - Returns an array with query params and values.
* E.g.: [
* 'limit' => '10',
const moveArrayIndex = (arr, fromIndex, toIndex) => {
const elementFrom = arr[fromIndex];
arr.splice(fromIndex, 1);
arr.splice(toIndex, 0, elementFrom);
return [...arr];
};
@claudiohilario
claudiohilario / compareVersions.js
Last active May 17, 2020 22:30
Compare versions x.x.x
/**
* This function allows you to compare two versions in x.x.x format.
*
* Conditions:
* v1 == v2 = 0
* v1 > v2 = 1
* v1 < v2 = -1
*
* @example
* compareVersions('0.0.0', '0.0.1');
function buildQueryParams(params = {}) {
const arrParams = Object.keys(params);
if(!arrParams.length) {
return '';
}
return `?${arrParams.map(param => `${param}=${params[param]}`).join('&')}`;
}
console.log(buildQueryParams()); // ''
console.log(buildQueryParams({})); // ''
@claudiohilario
claudiohilario / formatUrlParams.js
Last active January 16, 2020 16:52
formatUrlParams -> Formatar parâmetros URL
/**
* @example
*
* const path = '/user/:user_id/test/:test_id';
*
* const params = {
* user_id: 50000,
* test_id: 3,
* }
<div class="swiper-container" style="height: 100%">
<div class="swiper-wrapper" style="height: 100%">
<div id="slide-1" class="swiper-slide" style="height: 100%">
<div class="w-slide1">
<div class="slide-container">
<button id="close-wellcome" class="btn-voltar uppercase">Saltar</button>
<img src='img/wellcome/screen-01.png'>
<div class="wellcome-title">
<div style="font-size: 14px">Bem vindo à App</div>
<div class="uppercase" style="font-size: 18px">Seaside Lovers</div>
@claudiohilario
claudiohilario / evitar_condicoes.js
Created March 8, 2018 17:26
Evitar Condições JS
/**
* Evitar IF's Javascript
*/
getQualquerCoisa(dominioId, permissao){
let querys = {
'getAllDomains': {
'query': `SELECT * FROM qq`,
'params': []
},
<?php
class Date {
protected $CI;
private $db_default_timezone;
public function __construct()
{
$this->CI =& get_instance();
$this->_getDefaultTimestamp();
}