Skip to content

Instantly share code, notes, and snippets.

View mogeko's full-sized avatar
🇵🇸
FREE PALESTINE !!!

Zheng Junyi mogeko

🇵🇸
FREE PALESTINE !!!
  • Contemporary Amperex Technology Hungary Kft.
  • Debrecen, Hungary
  • 10:46 (UTC +02:00)
View GitHub Profile
@mogeko
mogeko / .bash_aliases
Last active June 13, 2020 22:15
自用的 .bash_aliases 备份
#
# ~/.bash_aliases
#
# User alias
alias cls='clear'
alias now='date +"%T"'
alias nowdate='date +"%d-%m-%Y"'
alias nowtime='now'
alias path='echo -e ${PATH//:/\\n}'
@mogeko
mogeko / .Brewfile
Last active June 16, 2020 23:40
自用的 .Brewfile 备份
tap "homebrew/bundle"
tap "homebrew/core"
@mogeko
mogeko / try_catch.ts
Last active October 31, 2022 14:53
Functional wrapper for try…catch…
/**
* Functional wrapper for try…catch…
*
* @param tryer - The function that may throw.
* @param catcher - The function that will be evaluated if `tryer` throws.
* @typeParam P - The type of the parameter of tryer; if throw, it will be passed to catcher.
* @typeParam T - The return type of tryer.
* @typeParam C - The return type of catcher.
* @returns A new function that will catch exceptions and send them to the catcher.
*
@mogeko
mogeko / is_empty.ts
Created October 31, 2022 00:11
This function checks if the given value is empty.
/**
* This function checks if the given value is empty.
*
* @param input - Any data structure that may be empty
* @returns if the `input` is empty
*
* @example
* ```typescript
* isEmpty(""); // true
* isEmpty([]); // true
@mogeko
mogeko / range.ts
Last active October 31, 2022 01:03
This function returns a sequence of numbers.
/**
* This function returns a sequence of numbers.
*
* @param length - The length of the array to create
* @returns An array of numbers from 0 to `length` - 1
*
* @example
* ```typescript
* range(0); // []
* range(5); // [0, 1, 2, 3, 4]
@mogeko
mogeko / sum.ts
Created October 31, 2022 00:13
This function sums the given numbers.
/**
* This function sums the given numbers.
*
* @param xs - The array to be calculated
* @returns The sum of all elements in the number array
*
* @example
* ```typescript
* sum(); // 0
* sum([1, 2, 3]); // 6