Skip to content

Instantly share code, notes, and snippets.

View IOIO72's full-sized avatar
🚂

Tamio Honma IOIO72

🚂
View GitHub Profile
@IOIO72
IOIO72 / VirtualBox prendends to be VMware
Created December 19, 2019 10:48
If you run an ISO live system on VirtualBox that checks for VMware, you can change the system information like this. (Replace "VM name" by the name of your virtual machine)
VBoxManage setextradata "VM name" "VBoxInternal/Devices/pcbios/0/Config/DmiSystemVendor" "VMware, Inc."
VBoxManage setextradata "VM name" "VBoxInternal/Devices/pcbios/0/Config/DmiSystemProduct" "VMware Virtual Platform"
@IOIO72
IOIO72 / Group by label property
Last active October 14, 2019 16:19
An array of objects of same structure is given. Each object contains a property `label` besides other properties. Same labels are equal accross the objects. The goal is to group the objects by the labels.
// Get an array of all labels with unique entries.
const uniqueLabels = [...new Set(apps.map(item => item.label))];
// Transform the original array of objects to an array of label groups.
const groupedApps = uniqueLabels.map(label => ({ label, stores: apps.filter(app => app.label.includes(label)) }));
@IOIO72
IOIO72 / rgb2hex.ts
Created August 23, 2019 15:56
Convert decimal RGB values to HTML hex string
// prepend a character to a string for a given result string length
const prependCharToLength = (str: string, char: string = '0', len: number = 2): string => {
let r: string[] = [];
let s: string[] = str.split('');
for (let i: number = len - 1; i >= 0; i--) {
r[i] = (s.length - i > 0) ? s[i] : char;
}
return r.join('');
};
Verifying my Blockstack ID is secured with the address 1Nu8r4xtC7uBYri355emFongdcF96RBiGh https://explorer.blockstack.org/address/1Nu8r4xtC7uBYri355emFongdcF96RBiGh
@IOIO72
IOIO72 / convertUmlauts.js
Created June 13, 2019 16:22
Converts str input into string with Umlaut replacements
export const convertUmlauts = str => {
const charMap = {
'ä': 'ae',
'ö': 'oe',
'ü': 'ue',
'Ä': 'Ae',
'Ö': 'Oe',
'Ü': 'Ue',
'ß': 'ss'
};
@IOIO72
IOIO72 / isValidDate.js
Created June 13, 2019 09:59
Returns true or false depending on valid date object.
export const isValidDate = d => d instanceof Date && !isNaN(d);
@IOIO72
IOIO72 / .htaccess
Created May 28, 2019 07:55
Configure time-based conditional redirects
RewriteEngine On
RewriteCond %{TIME} <20190319010000
RewriteRule ^agb\.html$ /legal/beta [R=302,L]
@IOIO72
IOIO72 / .htaccess
Created May 28, 2019 07:53
Remove `.html` from request.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} /.*\.html
RewriteRule ^(.*)\.html$ /$1 [R=301,L]
@IOIO72
IOIO72 / removeSymbolPrefix
Created May 10, 2019 14:34
Removes everything prefixed until the first alphabetical character
const removeSymbolPrefix = str => /^([^a-z]*)(.*)$/gi.exec(str)[2] || str;
@IOIO72
IOIO72 / normalizeURIComponentName
Created May 10, 2019 14:34
As an alternative conversion to encodeURIComponent this function removes every character except the alphabet and `-` and replaces spaces by `-`
const normalizeURIComponentName = str => {
const stripChars = /[^a-z-\s]/gi;
return (
str.toLowerCase().replace(stripChars, '').replace(/\s/gi, '-') || str
);
};