Skip to content

Instantly share code, notes, and snippets.

View mc-stephen's full-sized avatar
🎯
Focusing

MC-STEPHEN mc-stephen

🎯
Focusing
View GitHub Profile
@mc-stephen
mc-stephen / formatBytes.dart
Created November 18, 2022 17:05 — forked from zzpmaster/formatBytes.dart
convert bytes to kb mb in dart
static String formatBytes(int bytes, int decimals) {
if (bytes <= 0) return "0 B";
const suffixes = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
var i = (log(bytes) / log(1024)).floor();
return ((bytes / pow(1024, i)).toStringAsFixed(decimals)) +
' ' +
suffixes[i];
}

SSH keypair setup for GitHub (or GitHub/GitLab/BitBucket, etc, etc)

Create a repo.

Make sure there is at least one file in it (even just the README.md)

Generate a SSH key pair (private/public):

ssh-keygen -t rsa -C "your_email@example.com"
@mc-stephen
mc-stephen / sortSelectOption.js
Created July 1, 2021 00:43 — forked from cschlyter/sortSelectOption.js
[Javascript] Sort alphabetically the option elements of a select element by text.
function sortSelectOptions(selectElement) {
var options = $(selectElement + " option");
options.sort(function(a,b) {
if (a.text.toUpperCase() > b.text.toUpperCase()) return 1;
else if (a.text.toUpperCase() < b.text.toUpperCase()) return -1;
else return 0;
});
$(selectElement).empty().append( options );