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
  • 15:12 (UTC +01:00)
View GitHub Profile
@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
@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 / 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 / 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 / .Brewfile
Last active June 16, 2020 23:40
自用的 .Brewfile 备份
tap "homebrew/bundle"
tap "homebrew/core"
@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 / .bashrc
Last active June 13, 2020 22:05
自用的 .bashrc 备份
#
# ~/.bashrc
#
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
@mogeko
mogeko / aria2.conf
Last active February 4, 2023 16:29
Aria2 config file
#=================================================================
# https://gist.github.com/Mogeko/64a20bc441cb43a7b26e416270c10168
# https://github.com/P3TERX/aria2.conf (upstream)
# File name:aria2.conf
# Description: Aria2 config file
# Lisence: MIT
# Author: Mogeko, P3TERX
# Blog: https://p3terx.com for P3TERX
# https://mogeko.me for Mogeko
#=================================================================
tap "homebrew/bundle"
tap "homebrew/core"
# Macro processing language
brew "m4"
# Bourne-Again SHell, a UNIX command interpreter
brew "bash"
# GNU binary tools for native development
brew "binutils"
# GNU File, Shell, and Text utilities
brew "coreutils"
@mogeko
mogeko / blog-hugo.sh
Last active October 31, 2019 13:03
A scripts for managing hugo
#!/bin/bash
BLOGREPO=$BLOGPATH/.repo/Blog
BLOG_POSTS=$BLOGREPO/content/posts
BLOG_IMAGES=$BLOGPATH/.repo/blog-images
NOWPATH=`pwd`
log() {
cd $BLOGREPO