This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// CODE EXAMPLE FROM YOUTUBE LIVE: Golang: Modelo de concorrencia goroutine + channels | |
// LINK: https://youtube.com/live/TRx3W4mLFf8 | |
// Lucas_Badico: Dev, mentor e apaixonado por Programacao | |
// SIGA ME EM TODAS AS REDES SOCIAIS | |
package main | |
import ( | |
"time" | |
"fmt" | |
"sync" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Notifier { | |
private subscribers: ((notification: Notification) => void)[] = []; | |
constructor(subscribers: ((notification: Notification) => void)[]) { | |
this.subscribers = subscribers; | |
} | |
public notify(notification: Notification) { | |
this.subscribers.forEach((subscriber) => subscriber(notification)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require("express"); | |
const fs = require("fs"); | |
const path = require("path"); | |
const app = express(); | |
const port = process.env.PORT || 3000; | |
const dataFilePath = path.join(__dirname, "data.json"); | |
// Função para ler os dados do arquivo JSON | |
const readData = () => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const items = [1, 2, 3, 4, 5]; | |
const results = []; | |
for (let i = 0; i < items.lenght; i++){ | |
results[i] = items[i]*2; | |
} | |
console.log(results); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { useState, useEffect } = React; | |
function App() { | |
const [posts, setPosts] = useState([]); | |
useEffect(() => { | |
axios.get('https://jsonplaceholder.typicode.com/posts').then((res) => { | |
setPosts(res.data.slice(0, 10)); | |
console.log(posts); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
tem rodas | |
anda de ponto a ponto b | |
tem peso | |
*/ | |
class Vehicle { | |
// dado | |
constructor({ | |
model, | |
color, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { mysql } from '@common/connectors/mysql'; | |
import { GarageRepo, GarageService } from '../../src'; | |
const connection = mysql()('Garage'); | |
describe('Garage Service test', () => { | |
it('should GarageService be defined', () => { | |
expect(GarageService).toBeDefined(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { mysql } from '@common/connectors/mysql'; | |
import { GarageRepo, GarageService } from '../../src'; | |
const connection = mysql()('Garage'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class GarageRepo { | |
constructor(mysql, redis) { | |
this.mysql = mysql; | |
this.redis = redis; | |
} | |
create(attributes) { | |
return this.mysql.create({ | |
input: attributes, | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class GarageService { | |
constructor(garageRepo) { | |
this.repository = garageRepo; | |
} | |
async create(data) { | |
return this.repository.create({ | |
...data, | |
id: 'mockid' | |
}) | |
} |
NewerOlder