Skip to content

Instantly share code, notes, and snippets.

@ecerami
ecerami / hello.js
Created December 23, 2024 01:01
Drafts Hello World
draft.append("Hello, World!")
draft.addTag("greeting");
draft.update();
@ecerami
ecerami / weekend.js
Last active December 23, 2024 01:09
Drafts Weekend Action
// Get the Weekend Repeat Draft
let uuid="5B76AC79-9D32-44B8-9EE9-18EF04223225"
let draft = Draft.find(uuid);
// If Weekend Repeat is Found
if (draft) {
// Iterate each line
for (let task of draft.lines) {
if (!task.startsWith("#")) {
// Create new draft
package edu.bhcc;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.sql.*;
/**
* Load Budget from CSV File.
*/
@ecerami
ecerami / ynab.sql
Created April 6, 2023 15:36
Solution to Part 1
create table CATEGORY (
CATEGORY_ID int NOT NULL AUTO_INCREMENT,
CATEGORY_NAME varchar(50),
ALLOCATED FLOAT,
PRIMARY KEY (CATEGORY_ID)
);
create table TRANSACTION (
TRANSACTION_ID int NOT NULL AUTO_INCREMENT,
PAYEE varchar(50),
@ecerami
ecerami / counter.py
Created February 26, 2022 18:23
Counter Example
from collections import Counter
fruits = ["orange", "orange", "apple",
"orange", "apple", "banana", "orange"]
fruit_counts = Counter(fruits)
counts = fruit_counts.most_common(3)
print (counts)
@ecerami
ecerami / amazon.py
Last active February 19, 2022 16:49
Lecture #2 In Class Lab #2
def calculate_total(book_list):
"""Calculate Total of all Books."""
total = 0
for book in book_list:
total += book["price"]
return total
def calculate_shipping(total):
"""Calculate Shipping Cost."""
if total > 100:
import azure.functions as func
from .http_asgi import AsgiMiddleware
import mimesis
import fastapi
import asyncio
app = fastapi.FastAPI()
@app.get("/user/{user_id}")
async def get_user(user_id: int):
# FastAPI + MongoDB
# Option 3: Use the async Motor library.
import motor.motor_asyncio
from fastapi import FastAPI, status
import os
from typing import List
# Sample Movie Database from Atlas MongoDB
DB = "sample_mflix"
MSG_COLLECTION = "movies"
# FastAPI + MongoDB
# Option 2: Use a Single MongoClient.
from pymongo import MongoClient
from fastapi import FastAPI
import os
from typing import List
# Sample Movie Database from Atlas MongoDB
DB = "sample_mflix"
MSG_COLLECTION = "movies"
# FastAPI + MongoDB
# Option 1: Use Context Managers via the with statement.
from pymongo import MongoClient
from fastapi import FastAPI
from typing import List
import os
# Sample Movie Database from Atlas MongoDB
DB = "sample_mflix"
MSG_COLLECTION = "movies"