Skip to content

Instantly share code, notes, and snippets.

/**
* Convert value to the money.
* @param {any} s string with the value
* @param {number} ndd NumberDecimalDigits
* @returns
*/
const toMoney = (s, ndd) => {
let cookieUser = GetLoggedUserInfo();
let cookieCulture;
let culture;
/**
* Generate a random color in HEX format
* @param {number} opacity The opacity value between 0 and 1. If null use 1 as default value
* @param {number} whiteDistance distance from the white color. If null use 600 as default value
* @returns {string} the color in HEX format
* */
const generateRandomHexColor = (opacity, whiteDistance) => {
let r, g, b;
opacity ??= 1;
whiteDistance ??= 600;
@micheletolve
micheletolve / Resource.txt
Last active January 25, 2022 11:42
VSCode Settings
Resource:
- Victor Mono [https://rubjo.github.io/victor-mono/]
- Fira Code [https://github.com/tonsky/FiraCode]
@micheletolve
micheletolve / dotnet.zsh
Last active March 3, 2021 11:29
dotnet CLI alias
# https://github.com/dotnet-outdated/dotnet-outdated
# This is a continuation of the original dotnet-outdated tool created by Jerrie Pelser.
# If you already have the original dotnet-outdated tool installed you need to
# run dotnet tool uninstall --global dotnet-outdated before installing this version.
# View dotnet tool installed
alias tool:l='dotnet tool list --global'
# Install tool by this command and pass a name of tool es. <dotnet-outdated-tool>
# # tool:i <tool-name>
@micheletolve
micheletolve / _spacing_helpers.scss
Last active September 4, 2019 07:33
This generates .m-t-10 or p-t-10 type helper classes.
/*
***UPDATED: modified as bootstrap 4 classes
This .scss loop will create "margin helpers" and "padding helpers" for use in your web projects.
It will generate several classes such as:
.mr-10 which gives margin-right 10 pixels.
.mr-15 gives MARGIN to the RIGHT 15 pixels.
.mt-15 gives MARGIN to the TOP 15 pixels and so on.
.pb-5 gives PADDING to the BOTTOM of 5 pixels
.pl-40 gives PADDING to the LEFT of 40 pixels
The first letter is "m" or "p" for MARGIN or PADDING
@micheletolve
micheletolve / xml2json.cs
Last active August 2, 2022 14:55
How to remove #cdata-section when convert xml to json using Linq
string xml = '<Profile><First_Name><![CDATA[Luke]]</First_Name><Last_Name><![CDATA[Skywalker]]</Last_Name><guid><![CDATA[D521C0A3-B6BB-4EA0-AEC6-07860BFE9313]]></guid></Profile>';
string json = string.Empty;
if (!string.IsNullOrEmpty(response_xml))
{
var doc = XElement.Parse(response_xml);
var node_cdata = doc.DescendantNodes().OfType<XCData>().ToList();
foreach (var node in node_cdata)
{
@micheletolve
micheletolve / Woocommerce_export_orders.sql
Last active March 25, 2019 13:45
Woocommerce export orders sql
SELECT
-- Order Meta
p.ID AS order_id,
p.post_status AS order_status,
p.post_date AS order_date,
max( CASE WHEN pm.meta_key = '_order_total' AND p.ID = pm.post_id THEN pm.meta_value END ) AS order_total,
max( CASE WHEN pm.meta_key = '_order_tax' AND p.ID = pm.post_id THEN pm.meta_value END ) AS order_tax,
-- Payment
@micheletolve
micheletolve / .bash_profile
Created August 2, 2018 09:11
bash_profile backup
#ABILITARE I COLORI
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
#GESTIONE PS1
#export PS1="\[\e[01;31m\]\u\[\e[0m\]\[\e[01;31m\]:\[\e[1;33m\]\W\[\e[m\] \\$ "
export PS1="\[\033[38;5;39m\]\u\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput sgr0)\]\[\033[38;5;1m\]\\$\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput sgr0)\]\[\033[48;5;39m\][\w]\[$(tput sgr0)\]\[\033[48;5;15m\] \[$(tput sgr0)\]\[\033[38;5;39m\] >_: \[$(tput sgr0)\]"
#export PS1="\[\e[01;31m\]\u\[\e[0m\]\[\e[01;31m\]# \[\e[0m\]\[\e[\033[48;5;39m\]\w\[\e[0m\]\[\e[01;33m\]:\[\e[0m\]"
@micheletolve
micheletolve / drop.sql
Last active September 4, 2019 07:36
DROP table from prefix
/**
* Delete table in MySQL from theri prefix.
*/
DECLARE @prefix VARCHAR(255) = 'mytableprefix'
SET GROUP_CONCAT_MAX_LEN=10000;
SET @tbls = (SELECT GROUP_CONCAT(TABLE_NAME)
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = 'my_database'
AND TABLE_NAME LIKE @prefix + '_%');