Skip to content

Instantly share code, notes, and snippets.

View rfprod's full-sized avatar
☯️

Vadim rfprod

☯️
View GitHub Profile
@rfprod
rfprod / RangesBasedEncryptorDecryptor.markdown
Last active April 22, 2017 15:42
Ranges-based Encryptor/Decryptor

Ranges-based Encryptor/Decryptor

Function encrypt encrypts arbitrary string with characters.

Function decrypt decrypts previously encrypted string with function encrypt.

Both functions accept two parameters: string and integer.

The latter is a shift index for different rows.

@rfprod
rfprod / Index-DifferenceEncryptorDecryptor.markdown
Last active April 22, 2017 15:42
Index-Difference Encryptor/Decryptor

Index-Difference Encryptor/Decryptor

Function encrypt encrypts string with characters from range ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.,:;-?! \'()$%&".

Function encrypt returns null or empty string if input is empty.

Function encrypt throws Error in characters in input string are out of given range.

Function decrypt decrypts previously encrypted string with function encrypt.

@rfprod
rfprod / URLQueryToObject.markdown
Last active April 22, 2017 15:42
URL Query To Object

URL Query To Object

Function queryToObject converts url query to object.

Query: a.a=1&a.b=2&c=3

Object: ` { a { a: 1,

@rfprod
rfprod / BracesValidator.markdown
Last active April 22, 2017 15:42
Braces Validator

Braces Validator

Accepts nonempty string consisting on of opening and closing braces: '(', ')', '[', ']', '{', '}'. Returns true if sequence is valid, false is sequence is not valid.

A script by V.

License.

@rfprod
rfprod / WordSuggestionService.markdown
Last active April 22, 2017 15:42
Word Suggestion Service

Word Suggestion Service

Utilizes Levenshtein Distance algorythm to suggest a most similar word to the provided term. The service uses a words dictionary provided as a parameter on service instantiation new WordSuggestionService(['javascript', 'java', 'ruby', 'php', 'python', 'coffeescript']). The service's instance method suggest('heaven') returns a suggestion.

A script by V.

License.

@rfprod
rfprod / LevenshteinDistance.markdown
Last active April 22, 2017 15:43
Levenshtein Distance

Levenshtein Distance

Levenshtein distance algorythm realization. Function levenshteinDistance() calculates distance between two arbitrary strings provided as function parameters a and b.

A script by V.

License.

@rfprod
rfprod / StringFormatter.markdown
Last active April 22, 2017 15:43
String Formatter

String Formatter

Function format() formats text string according to provided width argument.

  • Each line contains as many words as possible.
  • Strings do not start or end with spaces.
  • New lines are separated with \n.
  • Last string does not contain \n.

A script by V.

@rfprod
rfprod / HEXColourCodeToRGB.markdown
Last active April 22, 2017 15:43
HEX Colour Code To RGB

HEX Colour Code To RGB

Converts HEX colour code to RGB.

A script by V.

License.

@rfprod
rfprod / ArbitraryBaseConverter.markdown
Last active April 5, 2019 19:11
Arbitrary Base Converter

Arbitrary Base Converter

Converts between arbitrary bases defined as alphabets (should work for any arbitrary alphabet not only for predefined ones):

const Alphabet = {
  BINARY:        '01',
  OCTAL:         '01234567',
  DECIMAL:       '0123456789',
  HEXA_DECIMAL:  '0123456789abcdef',
 ALPHA_LOWER: 'abcdefghijklmnopqrstuvwxyz',
@rfprod
rfprod / SplitStringWithoutCharactersLoss.markdown
Last active April 22, 2017 15:43
Split String Without Characters Loss

Split String Without Characters Loss

Splits string similarly to String.split() but without delimiter loss. Uses | as a delimiter. Character sequence to the left of the delimiter specify the ending sequence of the splitted items. Character sequence to the right of the delimiter specify the starting sequence of the splitted items.

A script by V.

License.