Skip to content

Instantly share code, notes, and snippets.

View Jdcorley's full-sized avatar

Jack Corley Jdcorley

  • Connecticut
View GitHub Profile
@Jdcorley
Jdcorley / audit-on-push.yml
Created February 1, 2022 20:17 — forked from LukeMathWalker/audit.yml
GitHub Actions - Rust setup
name: Security audit
on:
push:
paths:
- '**/Cargo.toml'
- '**/Cargo.lock'
jobs:
security_audit:
runs-on: ubuntu-latest
steps:
1. You can use join clauses to bring together two seperate tables and based off of what kind of join clause you use
and any conditionals you could get just data that overlaps or all data for both connected by a primary and foreign key.
2. A cross join is going to take two seperate tables and return every possible combination of the two tables rows combined
so lets say you had a table of 10 items that needed to be ordered for an inventory order and another table of 5 rows of
different vendors and their location and names if you did a cross table you would get all 50 possible cobinations of orders.
An inner join happens when you want to join two tables together returning only what they both have in common based off of
the given condition. One example could be if lets say you had a table of cities and an id for each city and then you had a
table of residents which also contained city id's you could do an inner join to determine what city the resident lived in
if any of the city_id's from the residents
QUESTION 1:
COUNT returns value of number of Values in a given column. EX: SELECT COUNT( DISTINCT, age) FROM background;
Would count the total number of distinct ages in the background table.
SUM returns a sum of numeric values in a given column. EX: SELECT SUM(debits) FROM accountspayable; Would sum the
total of the numeric values in the debits column in the accounts payable table.
AVG returns the average value of a given column. EX: SELECT AVG(age) FROM background; Would return the average of the ages in
the background table.
@Jdcorley
Jdcorley / gist:dfa7701710c04c966854b13d22ed5ecf
Created July 30, 2018 16:04
Operators in Select statements checkpoint
QUESTION 1:
SELECT age
FROM backgroundcheck
WHERE age = 18
QUESTION 2:
Sly cats SELECT columns
FROM fancy tables
Question 1 & 2:
To add data you use the INSERT INTO commands followed by the table name followed by the VALUES command and whatever data
values necessary in accordance with the data types for those particular columns. To update data you use the UPDATE command
followed by the table name and then the SET command and the data types you would like to update by their column name with
an = and then the value. You can additionally have a WHERE clause to set a conditional statement for the the particular data
you are targeting to update. To delete you can use the DELETE FROM commands followed by the table name and WHERE command with
conditionals and also a AND command to add additional conditionals after the where command. You can use the ALTER TABLE
command followed by the table name and ADD COLUMN or DROP COLUMN followed by a text description of why. You can set a default
value for that by using the SET DEFAULT command followed by what you want the default to be.
@Jdcorley
Jdcorley / psql-library-data-query
Created July 28, 2018 01:45
library-data-query
library=# SELECT * FROM books;
id | title | author
------+------------------------------------------+---------------------
1259 | Eloquent Ruby | Russell A. Olson
1593 | JavaScript: The Good Parts | Douglas Crockford
8982 | Designing Object-Oriented Software | Rebecca Wirfs-Brock
7265 | Practical Object-Oriented Design in Ruby | Sandi Metz
(4 rows)
@Jdcorley
Jdcorley / consolelog
Created December 30, 2017 22:14
bloccit-rails-console-assignment
[5] pry(main)> post = Post.first
Post Load (1.0ms) SELECT "posts".* FROM "posts" ORDER BY "posts"."id" ASC LIMIT ? [["LIMIT", 1]]
=> #<Post:0x6615ea0
id: 1,
title: "First Post",
string: nil,
body: "This is the first post in our system",
created_at: Sat, 30 Dec 2017 19:07:44 UTC +00:00,
updated_at: Sat, 30 Dec 2017 19:07:44 UTC +00:00>
@Jdcorley
Jdcorley / index.html
Created December 1, 2017 17:10
JS Bin reduce // source https://jsbin.com/poguyel
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="reduce">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">