Skip to content

Instantly share code, notes, and snippets.

View k-zehnder's full-sized avatar
😀

Kevin Zehnder k-zehnder

😀
View GitHub Profile
@ro6ley
ro6ley / simple_calculator.py
Last active July 6, 2022 13:44
Unit Testing in Python using UnitTest Framework
#!/usr/bin/env python3
class SimpleCalculator:
def sum(self, a, b):
""" Function to add two integers """
if isinstance(a, int) and isinstance(b, int):
return a + b
else:
return "ERROR"
@ricky-lim
ricky-lim / grade.py
Created March 25, 2020 12:45
Composing classes with dataclass, instead of deep-nested dictionary
# From the book, effective python 2nd edition item 37
from collections import defaultdict
from dataclasses import dataclass, field
from typing import List, Dict
@dataclass
class Grade:
weight: int
@peterVG
peterVG / ipfs-on-raspberry-pi.md
Last active October 31, 2024 11:41
Put IPFS decentralized storage on your Raspberry Pi with USB storage

I put IPFS on a Raspberry Pi and so should you!

Total cost of joining the decentralized storage revolution with your own lo-fi node: $124 USD

raspberry-ipfs

@abdorah
abdorah / HttpCrudRequests.js
Last active September 25, 2022 18:07
async fetch class that make it easy to perform http crud request in vanilla js.
class HttpCrudRequests {
async get(url) {
const res = await fetch(url)
const data = await res.json()
return data
}
async post(url, post) {
const res = await fetch(url, {
@Babatunde13
Babatunde13 / app.py
Last active March 31, 2024 08:41
The first part of my Flask and SQLAlchemy series.
from flask import Flask, jsonify, request
from flask_sqlalchemy import SQLAlchemy
import uuid
app = Flask(__name__)
db = SQLAlchemy(app)
app.config['SECRET_KEY']='secret'
app.config['SQLALCHEMY_DATABASE_URI']='sqlite:///app.db'
@bradtraversy
bradtraversy / typescript-crash.ts
Last active February 23, 2025 18:41
Basic intro to TypeScript (From YouTube Crash Course)
// Basic Types
let id: number = 5
let company: string = 'Traversy Media'
let isPublished: boolean = true
let x: any = 'Hello'
let ids: number[] = [1, 2, 3, 4, 5]
let arr: any[] = [1, true, 'Hello']
// Tuple
@nhall97
nhall97 / app.js
Created November 18, 2021 16:05
Login Auth with React Apps - react-router-dom
//https://www.digitalocean.com/community/tutorials/how-to-add-login-authentication-to-react-applications
//By default, react-router-dom is now ^6.0.2.
//Below are the significant changes for the tutorial to use the new version of react-router-dom
//Line 14 -> Switch has been replaced with Routes
//Line 29/34 -> Switch has been replaced with Routes (2)
import React, { useState }from "react";
import "./App.css";
@jerry-git
jerry-git / vax_app.py
Last active September 19, 2024 12:20
Simple modern Python web app
import datetime as dt
import os
import motor
from beanie import Document, Indexed, PydanticObjectId, init_beanie, operators
from fastapi import FastAPI, Response, status
from pydantic import BaseModel
app = FastAPI()
@dnnysng
dnnysng / contact.html
Created March 8, 2022 03:24
Hidden form so Netlify can detect in React
<form name="contact" netlify netlify-honeypot="bot-field" hidden>
<input type="text" name="name" />
<input type="email" name="email" />
<textarea name="message"></textarea>
</form>