Skip to content

Instantly share code, notes, and snippets.

@StuffbyYuki
StuffbyYuki / SQL:MySQL - Create a new user and grand all the privileges
Created June 4, 2020 02:16
SQL:MySQL - Create a new user and grand all the privileges
--Create a new user
CREATE USER 'usrname'@'localhost' IDENTIFIED BY 'password';
--Make sure your user is on here
select user from MySQl.user;
--Grand privillages
GRANT ALL PRIVILEGES ON * . * TO 'usrname'@'localhost';
@StuffbyYuki
StuffbyYuki / Some Linux Commends
Last active November 12, 2020 01:42
List of some linux commends
# move to a different directory
cd <yourDirectory>
# show what's in the current directory
ls
# show what's in the current directory with more details
ls -l
# show what's in the current directory with more details - pretty much the same as above but show hidden files
ls -al
# make a new directory
mkdir <newDirectoryName>
@StuffbyYuki
StuffbyYuki / Process Elapsed Time Linux
Last active November 14, 2020 04:40
Linux: Process Elapsed Time
ps -o etime= -p "your_pid"
@StuffbyYuki
StuffbyYuki / Linux: Prevent your laptop from sleeping
Created November 13, 2020 20:13
Linux: Prevent your laptop from sleeping
# Waits for the process with the specified pid to exit. Once the the process exits, the assertion is also released.
# man caffeinate
caffeinate -w your_pid &
@StuffbyYuki
StuffbyYuki / Vim: delete line(s)
Created November 13, 2020 20:15
Vim: delete line(s)
# do this when you're normal mode.
# dd -> delete 1 current line
# 10dd -> delete 10 from the current line
@StuffbyYuki
StuffbyYuki / Vim Basic Commands
Last active December 9, 2020 06:43
Vim Basic Commands
:w # save
:wq # save and exit
:q! # exit
:u # undo
:noh # delete highlights
:10,50s/^/# # comment out 10 - 50 lines
:10,50s/^# # uncomment 10 - 50 lines
:n or :next # go to next file that's open
:prev or :N # go to the previous file
:wn or :wnext # save the current go to next
@StuffbyYuki
StuffbyYuki / Git: when .gitignore not working
Created November 14, 2020 04:39
Git: when .gitignore not working
git rm -rf --cached .
git add .
@StuffbyYuki
StuffbyYuki / Vim: Python indetation settings
Created November 14, 2020 23:02
Vim: Python indetation settings
" vi ~/.vimrc
filetype plugin indent on
" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
" On pressing tab, insert 4 spaces
set expandtab
@StuffbyYuki
StuffbyYuki / Python: My Codebase for String Manipulations
Last active November 26, 2020 17:38
Python: My Codebase for String Manipulations
def clean_astring(self, string):
"""return a lower-cased string without any space"""
return string.strip().replace(' ', '').lower()
@StuffbyYuki
StuffbyYuki / Python: Add comma at the end of your list or dict
Last active November 26, 2020 17:38
Python: Add comma at the end of your list or dict
# Python accepts a comma at the end of your list/dict
# This is helpful when you define a list/dict vertically, helps you not forget to add a comma when adding a value
arr =[1,
2,
3,]
d = {1: 'a',
2: 'b',
3: 'c',}