Code Snippets
SQL
Basic workflow
Create DATABASE
CREATE DATABASE dashboard_db;
Create table
CREATE TABLE stats (
id INT AUTO_INCREMENT PRIMARY KEY,
VARCHAR(50),
name value INT
);
Put values
INSERT INTO stats (name, value) VALUES
'Users', 120),
('Sales', 75),
('Visitors', 300); (
Look and find data
USE dashboard_db;
TABLES;
SHOW -- Shows stats table summary
DESCRIBE stats; EXIT
Nux
Watch protected system directories
sudo nautilus # or dolphin, thunar
Open in the preferred application for file
xdg-open filename
Current wokring directory
pwd
Rename all files sequentially
The example renames .jpg
files. Modify as per your need.
To start numbering at certain number use the following code
For more on this, look here
Rename file names (“_” to “-”
Modify as per need
Replace space with hyphen
Rename to lowercase
Count files
Replace new line with double new line
Convert all mp4 to mp3
Latex
Long Comment
Restart Page-numbering
Push contents to bottom/right of page
R
Quit R from terminal in one go
or quit(save = "no")
Git
Undoing commit
Undoes the last N commits, but keeps the changes in the staging area.
Undoes the last N commits, and unstages the changes, leaving them in the working directory.
Undoes the last N commits and discards all changes made in those commits from the working directory. Use with caution as this is a destructive operation.
Rename files with git
Pull if remote is ahead
Revert all tracked files in the working directory
To clean untracked files as well:
Repository-specific confiuguration
Global confiuguration
Quarto
Render all qmd
files in the directory
Excel / Google Sheet
Mode for ordinal data
Median for ordinal data
=INDEX({"Strongly Disagree","Disagree","Neither Agree nor Disagree","Agree","Strongly Agree"}, MEDIAN(FILTER(MATCH(I1:I106, {"Strongly Disagree","Disagree","Neither Agree nor Disagree","Agree","Strongly Agree"}, 0), ISNUMBER(MATCH(I1:I106, {"Strongly Disagree","Disagree","Neither Agree nor Disagree","Agree","Strongly Agree"}, 0)))))