View readonly_postgres.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP ROLE IF EXISTS readaccess; | |
CREATE ROLE readaccess; | |
GRANT USAGE ON SCHEMA public TO readaccess; | |
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess; | |
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess; | |
DROP USER IF EXISTS readonly; |
View index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import products from './products' | |
let productName = "tote bag"; | |
let shipping: number; | |
let taxPercent: number; | |
let taxTotal: number; | |
let total: number; | |
const shippingAddress = 'SHCES 505 bloco A'; | |
const product = products.find((product) => product.name === productName) |
View index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import restaurants from './restaurants'; | |
const dollarSigns = '$$'; | |
const deliveryTimeMax = 90; | |
const maxDistance = 10; | |
let result: string; | |
let hour = new Date().getHours() | |
const priceBracket: number = dollarSigns.length; |
View index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Calculate = { | |
factorial: (inputValue) => { | |
if (inputValue === 0) {return 1} | |
else if (inputValue > 0) { | |
let result = 1 | |
for(let i = 1; i <= inputValue; i++) { | |
result *= i | |
} | |
return result | |
} |
View index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Define a rooster | |
Rooster = {}; | |
// Return a morning rooster call | |
Rooster.announceDawn = () => { | |
return 'cock-a-doodle-doo!'; | |
} | |
// Return hour as string | |
// Throws Error if hour is not between 0 and 23 inclusive |
View testes.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {assert} = require('chai'); | |
const {jsdom} = require('jsdom'); | |
const parseTextFromHTML = (htmlAsString, selector) => { | |
const selectedElement = jsdom(htmlAsString).querySelector(selector); | |
if (selectedElement !== null) { | |
return selectedElement.textContent; | |
} else { | |
throw new Error(`No element with selector ${selector} found in HTML string`); | |
} |
View sql.sqlite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * FROM trips; | |
SELECT * FROM riders; | |
SELECT * FROM cars; | |
select * from riders cross join cars; | |
select * from trips left join riders on trips.rider_id = riders.id; |
View sql.sqlite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT title, score | |
FROM hacker_news | |
ORDER BY score DESC | |
LIMIT 5; | |
SELECT SUM(score) FROM hacker_news; | |
SELECT user, SUM(score) FROM hacker_news GROUP BY user HAVING SUM(score) > 200 ORDER BY 2 DESC; | |
SELECT (517 + 309 + 304 + 282) / 6366.0; |
View sql.sqlite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * FROM startups; | |
SELECT COUNT(*) FROM startups; | |
SELECT SUM(valuation) FROM startups; | |
SELECT MAX(raised) FROM startups; | |
SELECT MAX(raised) FROM startups WHERE stage = 'Seed'; |
View sql.sqlite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * FROM nomnom; | |
SELECT DISTINCT neighborhood FROM nomnom; | |
SELECT DISTINCT cuisine FROM nomnom; | |
SELECT * FROM nomnom WHERE cuisine = 'Chinese'; | |
SELECT * FROM nomnom WHERE review >= 4; |
NewerOlder