Skip to content

Instantly share code, notes, and snippets.

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

Edy Silva geeksilva97

🏠
Working from home
View GitHub Profile
@geeksilva97
geeksilva97 / enumerable_parser_with_polling.rb
Last active August 16, 2024 13:40
This Gist contains an implementation of a poller inside of the Enumerator block. This program is supposed to poll log messages in CRI pattern and print them agregated
require 'fiber'
require 'time'
class String
# colorization
def colorize(color_code)
"\e[#{color_code}m#{self}\e[0m"
end
def red
@geeksilva97
geeksilva97 / sample.rb
Last active July 21, 2024 16:57
Having fun implementing my own Enumerator in plain Ruby. From scratch.
fib = Traversor.new do |yielder|
a = b = 1
loop do
yielder << a
a, b = b, a + b
end
end
simple_iterator = Traversor.new do |y|
y << 1
@geeksilva97
geeksilva97 / interval-bsearch.js
Created February 22, 2024 12:23
Busca binaria intervalo
function rightMostBSearch(arr, target) {
let left = 0;
let right = arr.length - 1;
let result = -1; // Initialize result to -1 for the case when the target is not present
while (left <= right) {
const mid = Math.floor(left + (right - left) / 2);
if (arr[mid] === target) {
// middlekey is equal to the target - update the left pointer so it continue to find the right most key
@geeksilva97
geeksilva97 / interval-bsearch.js
Created January 28, 2024 14:16
Experimenting bsearch to get an interval of array
function rightMostBSearch(arr, target) {
let left = 0;
let right = arr.length - 1;
let result = -1; // Initialize result to -1 for the case when the target is not present
while (left <= right) {
const mid = Math.floor(left + (right - left) / 2);
if (arr[mid] === target) {
// middlekey is equal to the target - update the left pointer so it continue to find the right most key

Schemas

Schema do usuário

documentid: Auth UID

{
  email: string,
  name: string,
  occupation: string | null
}
@geeksilva97
geeksilva97 / second.page.ts
Created October 14, 2021 11:41
Second Page - Simulate Android back button
import { Location } from '@angular/common';
import { Component, OnDestroy, OnInit } from '@angular/core';
import { AlertController, Platform } from '@ionic/angular';
import { Subscription } from 'rxjs';
@Component({
selector: 'app-second',
templateUrl: './second.page.html',
styleUrls: ['./second.page.scss'],
})
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
namespace UploadAPI.Controllers
{
import 'package:dio/dio.dart';
class DioUploadService {
Future<dynamic> uploadPhotos(List<String> paths) async {
List<MultipartFile> files = [];
for(var path in paths) files.add(await MultipartFile.fromFile(path));
var formData = FormData.fromMap({
import 'dart:convert';
import 'package:http/http.dart' as http;
class HttpUploadService {
Future<String> uploadPhotos(List<String> paths) async {
Uri uri = Uri.parse('http://10.0.0.103:5000/profile/upload-mutiple');
http.MultipartRequest request = http.MultipartRequest('POST', uri);
for(String path in paths){