Skip to content

Instantly share code, notes, and snippets.

View kezzico's full-sized avatar

Lee Irvine kezzico

View GitHub Profile
@kezzico
kezzico / swift-cache.swift
Last active December 11, 2023 19:45
Code Sample: Cache in Swift
/*
You are building a small part of this iOS application that needs to implement a simple key-value type of cache. In Swift, you will need to implement a cache class with the functions add, get, and size.
The add function takes two parameters, a key and value and adds the pair to the local cache. When an item is added to the cache, this function should return the string "added" and if the item already existed in the cache, this function should return the string "overwritten"
The get function attempts to retrieve an item from the cache based on the key parameter passed in. If the item exists in the cache, return the value, otherwise return the string "miss"
The size function simply returns the number of items in the cache.
Your goal is to implement the cache class so the function calls in the main method work properly. The output of your program should be a final string with the function outputs separated by a space.
@kezzico
kezzico / react-weather-dashboard.js
Created December 11, 2023 19:42
React Weather Dashboard
/*
Front-end Challenge
We provided some simple React template code. Your goal is to build a weather dashboard application that lets users search for current weather conditions in different cities.
When the app loads, it should display a search bar where users can type in a city's name. Once the city name is entered (case-sensitive) and the user hits the "Search" button, the app should fetch and display the current temperature, humidity, and wind speed for the chosen city. For simplicity, you don't have to make actual API calls; instead, use the predefined data to mimic the weather data for a few cities.
Additionally, all previously searched cities should be listed below the search bar as buttons. When a user clicks on a previously searched city, its weather data should be displayed again.
Ensure the application handles scenarios where the city is not in your mock data by displaying a message: "City not found." You are free to add classes and styles, but make sure you leave the component ID's and classes pr
@kezzico
kezzico / kotlin.md
Last active December 5, 2023 18:08

KOTLIN CRASH COURSE

Variables

There are 2 types of variables in Kotlin. Variables declared with val are immutable. Whereas variables declared with var are mutable.

Kotlin can infer a Variable's type at compile time. Variables that cannot be inferred can be explicitly typed.

val x:Int = 2
@kezzico
kezzico / cwd.md
Last active November 9, 2023 19:41

Current Working Directory

In a shell environment, the current working directory is the directory 'you' are currently in. Unless specified by an absolute path all file references are made relevant to the current working directory. In short, the current working directory is the first place programs will look.

Directory map with you are here pin

Examples Using Current Working Directory

Here are some examples.

Central Processor Unit (CPU)

A CPU, is made of billions of transistors. Little tiny switches that turn on and off. This clever device can be given instructions in the form of binary code. The CPU is the command center. It sets the bits. But if you know its language, you can become the CPUs master.

Master of the CPU universe

Each switch is called a bit. The on represents a 1, and the off represents 0. By combining these 1's and 0's together we can create numbers, or bytes. 8 bits to a byte. 256 different combinations from 00000000 to 11111111.

A 64 bit CPU can read 64 of them all at one time. 100111010101110110011001100110010101111110000000011100110110110.

BINARIES

A binary is another term for a process. So, on POSIX systems, the term is used as a directory name. This naming convention lets others know that this is where to find the executable binary code.

Binary Code

Shebang

Not all binaries are actually binary. Some of them are scripts. Written in Python, Bash, or JavaScript. They are not yet compiled into the raw binary instructions fed into the CPU. These programs rely on an 'interpreter'. The interpreter makes the conversion at runtime. As the process runs the script is parsed and converted into binary code.

@kezzico
kezzico / shell.md
Last active November 10, 2023 21:16

What is a Shell?

Sometimes called a command prompt or terminal.app, the shell is an interface to the kernel. A shell can be a GUI (Graphical User Interface), but for the purposes of this guide the shell will only refer to a command line shell. I use a standard POSIX shell.

A seashell

Windows users, checkout WSL. Also, Visual Studio Code is a great tool for Windows, Mac, and Linux users. Just hit Ctrl+` to open a shell.

Common Shell Programs & Params

@kezzico
kezzico / python-packages.md
Last active October 29, 2023 21:10
Python: All About Packages

Python: All About Packages

Packages are a neat way for coders to quickly extend their project's capabilities. At its core, Python is a programming langauge like any other. It does not have an HTTP server, AI training modules, or even the data analysis tools that Python is known for. These all come from packages.

Python packages are hosted on PyPi.org. PyPI is an open source project developed under the umbrella of the Python Packaging Authority (PyPA) and supported by the Python Packaging Working Group.

Popular Packages

Here are just a few packages that you can download into your Python Environment.

@kezzico
kezzico / python-howto-start-app.md
Created October 20, 2023 18:32
Python: How to start the application

HOW TO START THE PYTHON APPLICATION

First Python must be installed in your path.

To confirm, enter which python or which python3 into the shell.

To start the application

The application is called script.py. Enter either python or python3 followed by the filename of the main script.

@kezzico
kezzico / flasp-app-template.md
Last active October 20, 2023 18:35
PYTHON: Flask Application Template