Skip to content

Instantly share code, notes, and snippets.

View joaorbrandao's full-sized avatar
🐈

João Brandão joaorbrandao

🐈
View GitHub Profile
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
account_id
6009af9ae75c0b0001d2bcfb
5fae758e50ef720001770c0a
5fae919750ef720001770c0e
6006c642e98b880001ddd209
6009b5b853991800014e4810
600eb04f53991800014e4814
600fdf64e117870001b062d4
61d7eac43d75b0e4d40f3636
600ff1a1321f560001bfe1cc
@joaorbrandao
joaorbrandao / example.csv
Created February 9, 2023 17:23
Example of file for backfill
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
account_id
kjh234kjh23482745tkj2h4g2
45345y3850298452435298452
@joaorbrandao
joaorbrandao / p50.kt
Created December 30, 2022 09:11
Percentil calculations
fun List<Long>.p50(): Long {
val sorted = sorted()
val p50Position = floor(sorted.size * 0.5).toInt()
return sorted[p50Position]
}
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
account_id
613f5695e54fb0e4841cb8d8
6141f834e54fb0e4851cb8d8
6141feafe54fb0e4861cb8d8
61420e0ee54fb0e4871cb8d8
614307ce2df0b0e40068ed06
6143266fe54fb0e4891cb8d8
61433fa0e54fb0e48a1cb8d8
6143512a6650b0e4cf6c48d2
61435db734cdb0e4b8cea03e
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.withContext
suspend fun <A, B> Iterable<A>.pmap(
f: suspend (A) -> B,
): List<B> = withContext(Dispatchers.IO) {
map { async { f(it) } }.awaitAll()
}
@joaorbrandao
joaorbrandao / SelfReferenceTrait.php
Last active October 26, 2023 14:27
Laravel Model Self Reference
<?php
namespace App\Traits;
trait SelfReferenceTrait
{
protected $parentColumn = 'parent_id';
public function parent()
{
@joaorbrandao
joaorbrandao / AlertMessage.php
Last active November 30, 2020 23:47
Laravel Enums
<?php
namespace App\Enums;
use App\Traits\Enum;
final class AlertMessage
{
use Enum;
@joaorbrandao
joaorbrandao / win-http-client.h
Created September 25, 2018 23:04
Function to make a POST request to a server using windows sockets in C.
/**
This function makes a connection to the server,
sends the data and retreive the response.
Don't forget to include:
#include <winsock2.h>
And to add this to your code:
#pragma comment(lib,"ws2_32.lib") //Winsock Library
**/