Skip to content

Instantly share code, notes, and snippets.

View leleofg's full-sized avatar
🏠
Working from home

Leonardo Farias leleofg

🏠
Working from home
View GitHub Profile
@leleofg
leleofg / twosum.ts
Last active October 20, 2023 19:29
twosum-leetcode
function twoSum(nums: number[], target: number): number[] {
let map = new Map();
for (let i = 0; i < nums.length; i++) {
let complement = target - nums[i];
if (map.has(complement)) {
return [map.get(complement), i];
} else {
map.set(nums[i], i);
@leleofg
leleofg / client.js
Created September 11, 2020 00:47
Client gRPC
const grpc = require("grpc");
const protoLoader = require("@grpc/proto-loader");
const PROTO_PATH = __dirname + "/proto/user.proto";
const packageDefinition = protoLoader.loadSync(PROTO_PATH, {
keepCase: true,
defaults: true,
oneofs: true,
});
@leleofg
leleofg / user.proto
Created September 10, 2020 23:56
User Protobuf file
syntax = "proto3";
service UserService {
rpc createUser (User) returns (User) {}
rpc getUserById (UserId) returns (User) {}
}
message User {
int32 id = 1;
string email = 2;
@leleofg
leleofg / server.js
Last active September 11, 2020 01:34
A server grpc with node.js
const grpc = require("grpc");
const protoLoader = require("@grpc/proto-loader");
const PROTO_PATH = __dirname + "/proto/user.proto";
const packageDefinition = protoLoader.loadSync(PROTO_PATH, {
keepCase: true,
defaults: true,
oneofs: true
});
import React, { useState } from "react";
import { StyleSheet, TouchableOpacity, Text } from "react-native";
import { RNCamera } from "react-native-camera";
export default Camera = () => {
const [imageUri, setImageUri] = useState(null);
takePicture = async () => {
try {
if (this.camera) {
const options = {
@leleofg
leleofg / preview photo
Last active April 23, 2019 13:25
camera.js
import React, { useState } from "react";
import { StyleSheet, TouchableOpacity, Text, ImageBackground } from "react-native";
import { RNCamera } from "react-native-camera";
export default Camera = () => {
const [imageUri, setImageUri] = useState(null);
takePicture = async () => {
try {
if (this.camera) {
const options = {
--Os seguintes esquemas serão utilizados como base para a resolução desta prova. Chaves primárias estão
--sublinhadas e chaves estrangeiras estão em itálico.
--Customers (CustomerID, CompanyName, ContactName, Address, City, Region, Country, Phone, Fax)
--Employees (EmployeeID, LastName, FirstName, BirthDate, HireDate, Address, City, Region, Country)
--Orders (OrderID, CustomerID, EmployeeID, OrderDate, ShippedDate)
--Order Details (OrderID, ProductID, UnitPrice, Quantity, Discount)
--Products (ProductID, ProductName, SupplierID, CategoryID, UnitPrice, UnitsInStock, ReorderLevel,
--Discontinued)
--Suppliers (SupplierID, CompanyName, ContactName, Address, City, Region, Country, Phone, Fax,
--HomePage)
@leleofg
leleofg / prova_bd2_2013_1gq.sql
Last active September 26, 2018 20:52
Prova BD2 2013 - Prova 1º GQ - UNICAP
--Customers (CustomerID, CompanyName, ContactName, Address, City, Region, Country, Phone, Fax)
--Employees (EmployeeID, LastName, FirstName, BirthDate, HireDate, Address, City, Region, Country)
--Orders (OrderID, CustomerID, EmployeeID, OrderDate, ShippedDate)
--Order Details (OrderID, ProductID, UnitPrice, Quantity, Discount)
--Products (ProductID, ProductName, SupplierID, CategoryID, UnitPrice, UnitsInStock, ReorderLevel,
--Discontinued)
--Suppliers (SupplierID, CompanyName, ContactName, Address, City, Region, Country, Phone, Fax,
--HomePage)
--Categories (CategoryID, CategoryName, Description, Picture)
@leleofg
leleofg / crud_repository.js
Last active October 22, 2019 14:33
Demonstração repositorry crud async/await com node.js para o post no medium https://medium.com/@leoo.farias/crud-com-async-await-no-node-js-4e1032da5a33
exports.get = async() => {
return await User.find({}, 'name email');
}
exports.getById = async(id) => {
return await User.findById(id, 'name email');
}
exports.create = async(data) => {
const user = new User(data);