Skip to content

Instantly share code, notes, and snippets.

Avatar
Programming

Abdulrahman abdulrahmanAlotaibi

Programming
View GitHub Profile
@abdulrahmanAlotaibi
abdulrahmanAlotaibi / cheatsheet.sql
Created Sep 11, 2021
SQL Cheatsheet for MySQL client CLI
View cheatsheet.sql
create table table_name (
id integer primary key
name varchar(255)
);
insert into table_name (column1,c2) values ('','') ;
drop user '<user_name>'@'localhost';
@abdulrahmanAlotaibi
abdulrahmanAlotaibi / load_env.sh
Created Sep 10, 2021
Load your database environment variables in the terminal session
View load_env.sh
#/!bin/bash
# 1) Change the variables to your desired environment
# 2) Use the . ./load_env.sh dev to run the script
# . load_env.sh dev ==> load dev environment variables
# . load_env.sh staging ==> load staging environment variables
# . load_env.sh production ==> load production environment variables
echo "Loading your database environment variables to your shell session..."
if [[ "${1}" == "dev" ]]; then
@abdulrahmanAlotaibi
abdulrahmanAlotaibi / knexjs.js
Last active Sep 10, 2021
Knex.js Query Builder - Queries Cheatsheet
View knexjs.js
/**
* @Desc : All of my data are seeded using this testing database(https://github.com/datacharmer/test_db) just import it to your local database server
*/
const knex = require("knex")
const db = knex(require("./knexfile")["development"])
const { bgCyan, bgRed, redBright, bold, underline } = require("colorette") // To add colors for stdout text
db.from("departments").select("*").first().then(res => {
console.log(bgCyan("Basic select:"))
console.log(res)