Skip to content

Instantly share code, notes, and snippets.

@phptuts
phptuts / App.jsx
Last active December 26, 2023 04:24
Starting Point Tic Tac Toe
function App() {
return (
<>
<h1>Tic Tac Toe</h1>
<div className="board">
<div className="row">
<div className="square">X</div> <div className="square">X</div>
<div className="square">X</div>
</div>
@phptuts
phptuts / reduce.js
Created September 27, 2023 04:38
reduce function example day 21
const numbers = [4,5,9,10];
function reducerSum(acc, next) {
return acc + next;
}
function reducerDouble(acc, next) {
acc.push(next * 2);
return acc;
}
let colors = [];
colors.push('red');
colors.push('green');
colors.push('blue');
colors.unshift('yellow');
console.log(colors, 'colors');
@phptuts
phptuts / 1-example.js
Last active December 3, 2023 09:00
Day 3
console.log("Hello World");
console.log("Hello World");
console.log("Hello World");
console.log("Hello World");
console.log("Hello World");
@phptuts
phptuts / fastled arduino.ino
Created October 14, 2022 06:54
prototype for creating code the gist
#include <FastLED.h>
#define NUM_LEDS 250
#define DATA_PIN A0
#define DIRECTION right
CRGB leds[NUM_LEDS];
void shiftRight(byte reds[], byte greens[], byte blues[]) {
int tempRed = reds[NUM_LEDS - 1];
int tempGreen = greens[NUM_LEDS - 1];
@phptuts
phptuts / App.js
Last active May 11, 2022 06:23
React JS Crash Course
import Header from './components/Header';
import Footer from './components/Footer';
import About from './components/About';
import { BrowserRouter as Router, Route, Routes } from 'react-router-dom';
import { useState, useEffect } from 'react';
import Home from './components/Home';
function App() {
const [tasks, setTasks] = useState([]);
import UIKit
// You can create our own initializer with structs
struct Dog {
var name: String
var age = 0
init(name: String) {
import UIKit
// Structs
struct Music {
var song: String
let time: Int
}
var goodMusic = Music(song: "Blues", time: 33)
import UIKit
// You can pass a closure that requires a parameter
func todo(items: [String], process: (String) -> Void) {
for item in items {
process(item)
}
}
import UIKit
// Closures
// You can assign functions to a variable in swift
let work = {
print("Working")
}
work()