Skip to content

Instantly share code, notes, and snippets.

import random
output = dict()
try:
friends_count = int(input("Enter the number of friends joining (including you):"))
if friends_count < 1:
print("No one is joining for the party")
else:
print("Enter the name of every friend (including you), each on a new line:")
for i in range(friends_count):
name = input()
@elyasha
elyasha / shell
Created February 22, 2024 21:42
Install pygraphviz in MacOS
python3 -m pip install \
--config-settings="--global-option=build_ext" \
--config-settings="--global-option=-I$(brew --prefix graphviz)/include/" \
--config-settings="--global-option=-L$(brew --prefix graphviz)/lib/" \
pygraphviz
@elyasha
elyasha / readonly_postgres.sql
Created September 26, 2022 14:19
Read only creation of a user for RDS postgres cluster
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;
@elyasha
elyasha / index.ts
Created May 21, 2022 13:23
LEARN TYPESCRIPT TypeMart
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)
@elyasha
elyasha / index.ts
Created May 21, 2022 12:45
LEARN TYPESCRIPT Restaurant Recommender
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;
@elyasha
elyasha / index.js
Created April 2, 2022 21:24
LEARN JAVASCRIPT UNIT TESTING Factorial Feature
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
}
@elyasha
elyasha / index.js
Created April 2, 2022 14:33
LEARN JAVASCRIPT UNIT TESTING Rooster Regulation
// 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
@elyasha
elyasha / testes.js
Created March 30, 2022 02:36
LEARN JAVASCRIPT UNIT TESTING Cake O'Clock
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`);
}
@elyasha
elyasha / sql.sqlite
Created March 26, 2022 17:39
LEARN SQL Lyft Trip Data
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;
@elyasha
elyasha / sql.sqlite
Created March 26, 2022 15:05
LEARN SQL Analyze Hacker News Trends
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;