Skip to content

Instantly share code, notes, and snippets.

Tamio Honma IOIO72

  • Germany
Block or report user

Report or block IOIO72

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@IOIO72
IOIO72 / convertUmlauts.js
Created Jun 13, 2019
Converts str input into string with Umlaut replacements
View convertUmlauts.js
export const convertUmlauts = str => {
const charMap = {
'ä': 'ae',
'ö': 'oe',
'ü': 'ue',
'Ä': 'Ae',
'Ö': 'Oe',
'Ü': 'Ue',
'ß': 'ss'
};
@IOIO72
IOIO72 / isValidDate.js
Created Jun 13, 2019
Returns true or false depending on valid date object.
View isValidDate.js
export const isValidDate = d => d instanceof Date && !isNaN(d);
@IOIO72
IOIO72 / .htaccess
Created May 28, 2019
Configure time-based conditional redirects
View .htaccess
RewriteEngine On
RewriteCond %{TIME} <20190319010000
RewriteRule ^agb\.html$ /legal/beta [R=302,L]
@IOIO72
IOIO72 / .htaccess
Created May 28, 2019
Remove `.html` from request.
View .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} /.*\.html
RewriteRule ^(.*)\.html$ /$1 [R=301,L]
@IOIO72
IOIO72 / removeSymbolPrefix
Created May 10, 2019
Removes everything prefixed until the first alphabetical character
View removeSymbolPrefix
const removeSymbolPrefix = str => /^([^a-z]*)(.*)$/gi.exec(str)[2] || str;
@IOIO72
IOIO72 / normalizeURIComponentName
Created May 10, 2019
As an alternative conversion to encodeURIComponent this function removes every character except the alphabet and `-` and replaces spaces by `-`
View normalizeURIComponentName
const normalizeURIComponentName = str => {
const stripChars = /[^a-z-\s]/gi;
return (
str.toLowerCase().replace(stripChars, '').replace(/\s/gi, '-') || str
);
};
@IOIO72
IOIO72 / getKeyValueSafely
Created May 10, 2019
checks key existance before getting key value
View getKeyValueSafely
const getKeyValueSafely = (obj, key) => (
obj.hasOwnProperty(key) ? obj[key] : undefined
);
@IOIO72
IOIO72 / joinToArrayOrGetString
Created May 10, 2019
Joins two arrays and returns this array or returns a string when the array contains one single value
View joinToArrayOrGetString
const joinToArrayOrGetString = (strOrArray1, strOrArray2) => {
const ret = [...convertToArray(strOrArray1), ...convertToArray(strOrArray2)].filter(item => typeof item === 'string');
return (ret.length === 1) ? ret[0] : ret;
};
@IOIO72
IOIO72 / convertToArray
Created May 10, 2019
Takes any object and returns it as an array or returns the same given array
View convertToArray
const convertToArray = any => (Array.isArray(any)) ? any : [any];
@IOIO72
IOIO72 / fillWithCharBefore
Created May 10, 2019
Returns a string of a given length and fills uo missing characters with a specified character before the string.
View fillWithCharBefore
const fillWithCharBefore = (str, len, chr = '0') => (str.length <= len) ? `${chr.repeat(len - str.length)}${str}` : str;
You can’t perform that action at this time.