Skip to content

Instantly share code, notes, and snippets.

View ntatko's full-sized avatar
🐧

Noah Tatko ntatko

🐧
  • St. Louis, MO, USA
View GitHub Profile
// Reusable fetching hook
const useRequest = (requestFunc) => {
const [data, setData] = useState({})
const [loading, setLoading] = useState(false)
const [error, setError] = useState(null)
const fetch = async () => {
setLoading(true)
try {
const data = await requestFunc()
@ntatko
ntatko / sudoku.js
Created August 17, 2023 21:43
Sample sudoku solver
const floor3 = (n) => {
if (n%3 === 0) {
return n
}
return floor3(n - 1)
}
// Class to help keep track of the proper order of things.
class Sudoku {
constructor (puzzle, annotations) {
void main() {
Message messageNoTitle = Message(message: "stuff");
print("No title: ${messageNoTitle.displayText}");
assert(messageNoTitle.message == messageNoTitle.displayText);
Message messageEmptyTitle = Message(message: "this", title: "");
print("Empty title: ${messageEmptyTitle.displayText}");
assert(messageEmptyTitle.message == messageEmptyTitle.displayText);
Message messageWithTitle =
@ntatko
ntatko / index.js
Created July 20, 2022 16:25
A Tolgee internationalization implementation
import React from "react"
import ReactDOM from "react-dom/client"
import App from "./App"
import { TolgeeProvider } from "@tolgee/react";
import * as localeEn from './assets/i18n/en.json';
import * as localeEs from './assets/i18n/es.json';
const root = ReactDOM.createRoot(document.getElementById("root"))
root.render(
@ntatko
ntatko / main.dart
Created June 27, 2022 20:31
Switch Statements in Dart
/// SWITCH STATEMENTS
void main() {
String food = "Hamburger";
switch (food) {
case "Cheeseburger":
case "Hamburger":
case "Burger":
print("This is a burger");
break;
case "Fries":
@ntatko
ntatko / main.dart
Created June 22, 2022 16:54
Relational operators in dart
/// RELATIONAL OPERATORS
void main() {
// ==
bool fives = 5 == 5; // true
bool mixed = 4 == 5; // false
bool varred = fives == true; // true
bool strings = "This" == "That"; // false
bool sameStrings = "computeringstuff" == "computeringstuff"; // true
@ntatko
ntatko / main.dart
Created June 20, 2022 18:01
Logical Operators in Dart example
/// LOGICAL OPERATORS
void main() {
// &&
bool first = (true) && (true); // true
bool second = (true) && (false); // false
List array = [1, 2, 3];
Map map = {};
bool theyAreBothEmpty = array.isEmpty && map.isEmpty; // false
bool theyAreBothNotEmpty = array.isNotEmpty && map.isNotEmpty; // false
@ntatko
ntatko / main.dart
Created June 17, 2022 17:29
A basic introduction to functions in dart
/// FUNCTIONS
void main() {
int sum = add(1, 3);
print("$sum"); // 4
logger("stuff"); // stuff
int starting = 0;
double ending = toDouble(starting);
print("${ending is double}"); // 0.0
@ntatko
ntatko / main.dart
Created June 17, 2022 06:44
Introduction to types in Dart
/// DART TYPES
void main() {
// numbers
int? integer = null;
double? fraction = 1.0;
// strings
String thisString = "this is a string. 😜";
// booleans
@ntatko
ntatko / App.jsx
Created January 19, 2022 22:06
Map that creates a single point with customizable query-params using ol-kit
import React, { useState, useEffect } from 'react'
import {
Map,
BasemapContainer,
ContextMenu,
Controls,
Popup,
VectorLayer
} from '@bayer/ol-kit'
import { fromLonLat } from 'ol/proj'