Skip to content

Instantly share code, notes, and snippets.

@shanenoi
Last active September 14, 2020 03:30
Show Gist options
  • Save shanenoi/383efc3c1f0babddffc6fe109ad095b9 to your computer and use it in GitHub Desktop.
Save shanenoi/383efc3c1f0babddffc6fe109ad095b9 to your computer and use it in GitHub Desktop.
Đây là cái bashrc của mình 😆
# ......... append these lines into your bashrc file ......... #
# run schedule.sh
if [ -f $HOME/schedule.sh ]; then
echo " __________"
echo -e "}~~~~[ SCHEDULE ]"
echo " ▔▔▔▔▔▔▔▔▔▔"
. $HOME/schedule.sh
fi
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define storage ".push-up.kekeke"
#define rule_pushup 3
void write_data(char* file_storage, int rule) {
int score = 0;
FILE* file_pointer;
if((file_pointer= fopen(file_storage, "r"))==NULL) {
system(strcat(strdup("printf '0'>"), file_storage));
} else {
int char_ascii;
while((char_ascii=getc(file_pointer))!=EOF) {
score = score*10 + (char_ascii-'0');
}
fclose(file_pointer);
}
file_pointer = fopen(file_storage, "w");
score += rule;
fprintf(file_pointer, "%d", score);
fclose(file_pointer);
}
int main(int size, char* args[]) {
if (size==0) {return 0;}
char* command = strdup("");
for (int i=1; i<size; i++) {
strcat(strcat(command, args[i]), " ");
}
int code = system(command);
if(code!=0) {
write_data(strcat(strcat(getenv("HOME"), "/"), storage), rule_pushup);
}
return code;
}
# Ubuntu/Debian
# ___________ #
# ===[ VARIABLES ]=== #
# ▔▔▔▔▔▔▔▔▔▔▔ #
OK="(✔)"
ERROR="(✗)"
# ___________ #
# ===[ FUNCTIONS ]=== #
# ▔▔▔▔▔▔▔▔▔▔▔ #
check_status () {
return_code=$?
log=$1
if [[ $return_code -eq 0 ]];
then
echo " $OK $log"
else
echo " $ERROR $log"
fi
}
table_ips () {
printf "| %-15s | %-15s |\n" Interface Published
dash=$(printf -- '-%.0s' {1..17})
printf "+%s+%s+\n" $dash $dash
for interface in $(ifconfig -a | grep -oP "^[^ :]+")
do
printf "| %-15s | %-15s |\n" \
$interface \
$(ifconfig $interface \
| grep -Po "\d+\.\d+\.\d+\.\d+" | head -1)
done
}
# check_package () {
#
# command_name=$1
# package_name=$2
# log_show=$3
#
# local checker=$(whereis $command_name)
#
# if [[ ${#checker} -eq ${#command_name}+1 ]]
# then
# fucking apt install $package_name
# check_status $log_show
# else
# print
# check_status $log_show
# fi
#
# }
# _________________ #
# ===[ CHECK PHANTOMJS ]=== #
# ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ #
# phantomjs="https://cdn.glitch.com/c16f71ef-e58b-4291-89f3-62975c2ebc7f%2Fphantomjs?v=1594230459325"
# phandom_path=$HOME/Driver/phantomjs
# if [ -f $phandom_path ];
# then
# check_status "Download Phantomjs"
# else
# mkdir $(dirname $phandom_path)
# wget $phantomjs -O $phandom_path
# check_status "Download Phantomjs"
# fi
# chmod +x $HOME/Driver/phantomjs
# alias phantomjs="$HOME/Driver/phantomjs"
# _______________________ #
# ===[ FIX CTRL ARROW IN VIM ]=== #
# ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ #
export TERM=xterm
check_status "Ctrl arrow in vim"
# ______________ #
# ===[ Push up man! ]=== #
# ▔▔▔▔▔▔▔▔▔▔▔▔▔▔ #
push_up_exec=$HOME/.push-up
if [ -f $push_up_exec ];
then printf ""
else
gcc extenssion.c -o $push_up_exec
fi
alias python="$push_up_exec python"
alias python3="$push_up_exec python3"
# C/C++ da khó rồi chơi thế ai chơi lại :(
# alias gcc="$push_up_exec gcc"
# alias cpp="$push_up_exec cpp"
# alias cc="$push_up_exec cc"
alias java="$push_up_exec java"
alias javac="$push_up_exec javac"
if [ -f $HOME/.push-up.kekeke ]
then
amount=$(cat $HOME/.push-up.kekeke)
else
amount=0
fi
check_status "You owe me $amount push-ups"
# ______________ #
# ===[SOME SHORTCUT ]=== #
# ▔▔▔▔▔▔▔▔▔▔▔▔▔▔ #
alias rm="gio trash"
alias tree="gio tree"
# Mình từng xài Arch Linux
# alias up="sudo pacman -Suy -y; \
# sudo pacman -Sc"
alias up="sudo apt update -y;\
sudo apt upgrade -y;\
sudo apt autoremove -y;\
sudo apt autoclean -y;\
sudo apt clean -y;"
alias docker="sudo docker"
alias pyser="table_ips && echo;\
python3 -m http.server"
# ___ #
# ===[END]===#
# ▔▔▔ #
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment