Skip to content

Instantly share code, notes, and snippets.

View Fabio286's full-sized avatar
๐Ÿฆง

Fabio Di Stasio Fabio286

๐Ÿฆง
View GitHub Profile
@Fabio286
Fabio286 / build.js
Created August 31, 2021 10:19 — forked from si458/build.js
build script for pkg with icon and metainfo
if (process.argv[2] == undefined) process.exit(0);
if (process.argv[2] == "") process.exit(0);
const { pkg_fetch_version, node_version, pkg_cache_path, icon, version, description, company, name, copyright, file } = require(`./${process.argv[2]}.json`);
const ResEdit = require('resedit');
const { DownloaderHelper } = require('node-downloader-helper');
const path = require("path");
const fs = require('fs');
process.env['PKG_CACHE_PATH'] = path.join(__dirname, pkg_cache_path);
const pkg_fetch = path.join(process.env['PKG_CACHE_PATH'], `v${pkg_fetch_version}`);
const fetched = path.join(pkg_fetch, `fetched-v${node_version}-win-x64`);
Vue.js 5 hrs 45 mins โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 44.6%
JavaScript 5 hrs 17 mins โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Œโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 41.0%
Text 1 hr โ–ˆโ–‹โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 7.9%
Apache ... 10 mins โ–Žโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 1.4%
Other 10 mins โ–Žโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 1.4%
@Fabio286
Fabio286 / generateColor.js
Created July 28, 2020 11:38
Generates an HEX color code from a numeric seed.
function genColor (seed) {
let color = Math.floor((Math.abs(Math.sin(seed) * 16777215)) % 16777215);
color = color.toString(16);
while (color.length < 6)
color = '0' + color;
return color;
}
@Fabio286
Fabio286 / hexToBinary.js
Last active July 28, 2020 11:39
Converts hexadecimal string to binary string.
'use strict';
const lookup = {
0: '0000',
1: '0001',
2: '0010',
3: '0011',
4: '0100',
5: '0101',
6: '0110',
@Fabio286
Fabio286 / formatBytes.js
Last active July 28, 2020 11:39
Format bytes in JavaScript.
function formatBytes (bytes, decimals = 2) {
if (bytes === 0) return '0 Bytes';
const k = 1024;
const dm = decimals < 0 ? 0 : decimals;
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
@Fabio286
Fabio286 / build.bat
Created March 9, 2020 08:43
Build .bat for C++ in Visual Studio Code (example)
@echo off
if exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" (
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x86
) else (
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x86
)
set compilerflags=/Od /MD /Zi /EHsc /std:c++latest /nologo /I include /I C:\Boost /I "C:\Program Files (x86)\MySQL\MySQL Connector C++ 8.0\include" /I "C:\Program Files (x86)\Visual Leak Detector\include"
set linkerflags=/OUT:bin\program_name.exe /NOLOGO /DEBUG /LIBPATH:C:\Boost\stage\lib /LIBPATH:"C:\Program Files (x86)\MySQL\MySQL Connector C++ 8.0\lib" /DEFAULTLIB:"C:\Program Files (x86)\MySQL\MySQL Connector C++ 8.0\lib\vs14\mysqlcppconn.lib"
cl.exe %compilerflags% src\*.cpp /link %linkerflags%
del bin\*.ilk *.obj *.pdb