Skip to content

Instantly share code, notes, and snippets.

View rpivo's full-sized avatar

Ryan Pivovar rpivo

  • New York City, NY
View GitHub Profile
@rpivo
rpivo / index.md
Last active August 2, 2021 22:29
Common Mathematical Symbols Used in Michael Sipser’s *Introduction to the Theory of Computation*

Common Mathematical Symbols Used in Michael Sipser’s Introduction to the Theory of Computation

This is a short list of logical symbols that appear in Michael Sipser's book Introduction to the Theory of Computation.

Name Symbol Description
Alphabetical Set Σ or Γ Often used to designate a set containing an alphabet.
Boolean Conjunction If both values surrounding ∧ are true, then the result is true (AND).
Boolean Disjunction If both values surrounding ∨ are opposites, then the result is true (OR).
Boolean Equality If both values surrounding ⇔ have the same value, then the result is true.
@rpivo
rpivo / index.md
Last active June 30, 2021 12:25
Using Left Join/Right Join to Join Two Tables on a Common Column, and to Default to Null For Missing Values in MySQL

Using Left Join/Right Join to Join Two Tables on a Common Column, and to Default to Null For Missing Values in MySQL

The following SQL schema will produce the two tables.

Create table If Not Exists Employees (id int, name varchar(20));
Create table If Not Exists EmployeeUNI (id int, unique_id int);
Truncate table Employees;
insert into Employees (id, name) values ('1', 'Alice');
insert into Employees (id, name) values ('7', 'Bob');
@rpivo
rpivo / index.md
Last active June 27, 2021 12:57
# Using Math Operations in MySQL Queries

Using Math Operations in MySQL Queries

The following SQL schema will produce the table below.

CREATE TABLE IF NOT EXISTS Employees(
  emp_id INT,
  event_day DATE,
  in_time INT,
 out_time INT
@rpivo
rpivo / index.md
Last active June 23, 2021 11:57
Aliasing in MySQL

Aliasing in MySQL

The following SQL schema will populate the table below.

CREATE TABLE IF NOT EXISTS DailySales(
  date_id date,
  make_name varchar(20),
  lead_id int,
  partner_id int
@rpivo
rpivo / index.md
Last active June 24, 2021 12:19
Using the Count Function in MySQL

Using the Count Function in MySQL

The following SQL schema will populate the table below.

CREATE TABLE IF NOT EXISTS DailySales(
  date_id date,
  make_name varchar(20),
  lead_id int,
@rpivo
rpivo / index.md
Last active June 22, 2021 12:15
Using DISTINCT in MySQL

Using DISTINCT in MySQL

The following SQL schema will populate the table below.

CREATE TABLE IF NOT EXISTS DailySales(
  date_id date,
  make_name varchar(20),
  lead_id int,
  partner_id int
@rpivo
rpivo / index.md
Last active June 21, 2021 00:52
OpenGL ES Storage Qualifiers

OpenGL ES Storage Qualifiers

Name Type Keyword Description
@rpivo
rpivo / index.md
Last active June 20, 2021 12:43
Using the Date Type in MySQL

Using the Date Type in MySQL

The DATE type takes in a string value and converts it into a YYYY-MM-DD date format.

Let's say we have a SQL schema that uses the DATE type, and that inserts one row.

CREATE TABLE IF NOT EXISTS DailySales(
  date_id DATE,
  make_name VARCHAR(20),
@rpivo
rpivo / index.md
Last active June 19, 2021 13:33
Checking the Length of a String in a MySQL Where Clause

Checking the Length of a String in a MySQL Where Clause

Let's say we have a SQL schema like this:

Create table If Not Exists Tweets(tweet_id int, content varchar(50));
Truncate table Tweets;
insert into Tweets (tweet_id, content) values ('1', 'Vote for Biden');
insert into Tweets (tweet_id, content) values ('2', 'Let us make America great again!');
@rpivo
rpivo / index.md
Last active June 17, 2021 12:02
Using Order By to Sort MySQL Table Results by Ascending or Descending Order

Using Order By to Sort MySQL Table Results by Ascending or Descending Order

The following statement will create a new table Products and insert values into it.

CREATE TABLE IF NOT EXISTS Products (
  product_id int,
  low_fats ENUM('Y', 'N'),
  recyclable ENUM('Y', 'N')
);