Skip to content

Instantly share code, notes, and snippets.

View AlbinSoft's full-sized avatar

Albin AlbinSoft

View GitHub Profile
@AlbinSoft
AlbinSoft / strjoin.js
Last active January 17, 2024 16:36
Join array strings in a human readable way
function strjoin(a) {
if(a.length===0) return '';
let r = a.shift();
while(a.length>1) {
r += ', '+a.shift();
}
if(a.length) {
r += ' and '+a.shift();
}
return r;
@AlbinSoft
AlbinSoft / gist:6f64aea9df2d267f25ae84c08a4b874a
Last active November 13, 2023 07:30
PhpSpreadsheet format Euros with decimals
After reading several solutions in forums this is what worked for me
$sheet->setCellValue('A1', number_format(1234.5, 2, '.', ''));
$sheet->getStyle('A1')->getNumberFormat()->setFormatCode('#,##0.00 "€"_-');
Must write: 1,234.50 €
@AlbinSoft
AlbinSoft / htmlelement-css.js
Created September 5, 2023 06:45
JQuery css method equivalent with Vanilla JS
HTMLElement.prototype.css = function (props) {
for(prop in props) this.style.setProperty(prop, props[prop]);
return this;
};
/*
* Online demo: https://codepen.io/albinsoft/pen/OJrRKvm
*/
@AlbinSoft
AlbinSoft / file_upload_max_size.php
Last active August 31, 2023 17:57
PHP - Get the Maximum Upload Size
function file_upload_max_size_int() {
static $max_size = -1;
if($max_size<0) {
$post_max_size = intval(ini_get('post_max_size'));
$upload_max_size = intval(ini_get('upload_max_filesize'));
$max_size = min($post_max_size, $upload_max_size);
}
return $max_size;
}
@AlbinSoft
AlbinSoft / common.css
Last active July 18, 2023 09:39
Initial CSS
/*
Initial CSS
*/
:root {
--font-titles: 'XXXXXX';
--font-text: 'XXXXXX';
--color1: #XXXXXX;
--sprites: url('images/sprites.svg');
}