Skip to content

Instantly share code, notes, and snippets.

View lucianoschillagi's full-sized avatar

Luciano Schillagi lucianoschillagi

View GitHub Profile
@lucianoschillagi
lucianoschillagi / handling-events.jsx
Created September 27, 2019 16:31
Handling events in ReactJS
import React, { Component } from 'react';
import './App.css';
// topics touched: component, state, conditional rendering, event handler, prevent defalut.
class Toogle extends Component {
constructor(props) {
super(props);
// the initial state of 'isToogleOn' is 'true'
this.state = {
@lucianoschillagi
lucianoschillagi / interpolacion-de-strings.swift
Last active July 30, 2020 19:10
Interpolación de strings
/* Interpolación de strings en Swift */
// Interpolando una constante
let miNombre = "Luciano"
let stringInterpolado = "Mi nombre es \(miNombre)"
print(stringInterpolado)
// Imprime: "Mi nombre es Luciano"
// Interpolando una expresión
let suma = 2 + 2
@lucianoschillagi
lucianoschillagi / .swift
Last active November 9, 2023 20:21
Opposite Color with Color Picker
import SwiftUI
struct ColorPickerView: View {
@State private var selectedColor = Color.blue
var body: some View {
VStack {
ColorPicker("", selection: $selectedColor).padding(.bottom)
ColorRectangle(selectedColor: $selectedColor)
ColorRectangle(selectedColor: $selectedColor).colorInvert()
}.padding()
@lucianoschillagi
lucianoschillagi / .swift
Last active November 11, 2023 19:52
Apple Fonts Slider Catalogue
import SwiftUI
struct FontSliderCatalogue: View {
@State private var selectedFontIndex: Int = 0
private var allFontNames: [String] {
return UIFont.familyNames.flatMap { UIFont.fontNames(forFamilyName: $0) }
}
var body: some View {
@lucianoschillagi
lucianoschillagi / .swift
Last active November 11, 2023 12:50
Escucha lo que escribiste mediante AVSpeechSynthesizer
import SwiftUI
import AVFoundation
struct SpeechText: View {
@State private var text = ""
var body: some View {
ZStack {
Color.pink.opacity(0.5).ignoresSafeArea()
@lucianoschillagi
lucianoschillagi / .swift
Created November 11, 2023 16:40
Listen your message before to send it
import SwiftUI
import AVFoundation
struct SpeechText: View {
@State private var text = ""
var body: some View {
ZStack {
@lucianoschillagi
lucianoschillagi / .swift
Last active November 14, 2023 17:00
Identifying parts of speech
import SwiftUI
import NaturalLanguage
struct TaggedTextView: View {
let text = "This is your life. Do what you love and do it often."
let text2 = "― Holstee Manifesto, The Wedding Day (extract)"
let textButton = "Tag the text"
@lucianoschillagi
lucianoschillagi / .swift
Created November 14, 2023 20:10
Recognizing the language in a text
import SwiftUI
import NaturalLanguage
struct LangRecognizerView: View {
@State private var text = ""
@State private var currentLangLegend = ""
@State private var currentLang = ""
var body: some View {
@lucianoschillagi
lucianoschillagi / .swift
Created November 16, 2023 22:56
How many years are you lived?
import SwiftUI
struct DaysLived: View {
@State private var userBirthday = ""
@State private var userDaysLived: Int?
@State private var birthdate: Date?
@State private var wrongDateFormat = false
let alertMessage = """
Out of range or
@lucianoschillagi
lucianoschillagi / .swift
Last active November 28, 2023 15:47
Asynchronous Tests
import XCTest
final class AsyncTests: XCTestCase {
func testDownloadWebDataWithConcurrency() async {
// Create a URL for a webpage to download.
let url = URL(string: "https://apple.com")! // test passed! :)
// let url = URL(string: "https://applexfsda.com")! // test don't passed :(
// Use an asynchronous function to download the webpage.