Skip to content

Instantly share code, notes, and snippets.

# Books
class Book:
def __init__(self, title, author, year):
self.title = title
self.author = author
self.year = year
self.is_borrowed = False # tracks availability
def get_description(self):
class Vehicle:
def __init__(self, brand, model):
self.brand = brand
self.model = model
def display_info(self):
print(f"Brand: {self.brand}, Model: {self.model}")
class Car(Vehicle):
class BankAccount:
def __init__(self, owner, balance=0):
self.owner = owner
self.balance = balance
def deposit(self, amount):
if amount <= 0:
raise ValueError("Deposit amount must be positive")
self.balance += amount
print(f"Deposited ${amount:.2f}. New balance: ${self.balance:.2f}")
import math
class Shape:
def area(self):
raise NotImplementedError("Subclasses must implement the area() method")
class Rectangle(Shape):
def __init__(self, width, height):
import 'dart:math';
import 'package:flutter/material.dart';
class Dims {
const Dims._();
static Size designSize = const Size(390, 844);
static late Size deviceSize;
static void setSize(MediaQueryData media) {
@jhaym3s
jhaym3s / random.dart
Last active August 29, 2024 18:05
random stuffs I searched
final bodyHeight =MediaQuery.of(context).size.height - (MediaQuery.of(context).padding.top + kToolbarHeight);
LengthLimitingTextInputFormatter(100)//
WillPopScope(
onWillPop: () async => Navigator.push(
context, MaterialPageRoute(builder: (context) => AppLayout())),
//adding shadow
Container(
height: 70,
decoration: BoxDecoration(
boxShadow: [
@jhaym3s
jhaym3s / dimensions.dart
Created July 16, 2023 11:09
Screen proper dimensions in flutter
// ignore_for_file: use_key_in_widget_constructors
import 'dart:math';
import 'package:flutter/material.dart';
class Dims {
const Dims._();
// the app was designed on an iphone frame with w:h = 390:844
static Size designSize = const Size(393, 845.33);
pragma solidity ^0.8.0;
contract Token {
string public name = "Manuel";
string public symbol = "MKPA";
uint256 public totalSupply = 1000000;
uint256 public decimals = 18;
mapping(address => uint256) balances;
constructor() {
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
_fe_analyzer_shared:
dependency: transitive
description:
name: _fe_analyzer_shared
url: "https://pub.dartlang.org"
source: hosted
version: "47.0.0"
pragma solidity ^0.8.13;
contract StableCoin {
// Properties
string public name;
string public symbol;
uint256 public totalSupply;
// Mapping of addresses to their token balances
mapping(address => uint256) public balances;