Skip to content

Instantly share code, notes, and snippets.

View feliperazeek's full-sized avatar
💭
Be there and give a shit

Felipe Oliveira feliperazeek

💭
Be there and give a shit
View GitHub Profile
@feliperazeek
feliperazeek / IcebergTableStatsTest.scala
Created April 8, 2024 16:10
Iceberg Lower/Upper Bounds in Data Files (Parquet vs Avro)
import org.apache.hadoop.conf.Configuration
import org.apache.iceberg.hadoop.HadoopFileIO
import org.apache.iceberg.spark.Spark3Util
import org.apache.iceberg.{DataFile, Snapshot, TableProperties, Table => IcebergTable}
import org.apache.spark.SparkConf
import org.apache.spark.sql.functions._
import org.apache.spark.sql.types.{StringType, StructField, StructType, TimestampType}
import org.apache.spark.sql.{DataFrame, Row, SparkSession}
import org.junit.runner.RunWith
import org.scalatest.BeforeAndAfterAll
@feliperazeek
feliperazeek / IcebergResidual2Test.scala
Created March 14, 2024 19:26
Iceberg Residual Test
import org.apache.hadoop.conf.Configuration
import org.apache.iceberg.hadoop.HadoopFileIO
import org.apache.iceberg.spark.Spark3Util
import org.apache.iceberg.{DataFile, PartitionSpec, Schema, Snapshot, TableMetadata, TableMetadataParser, Table => IcebergTable}
import org.apache.spark.SparkConf
import org.apache.spark.sql.functions._
import org.apache.spark.sql.types.{StringType, StructField, StructType, TimestampType}
import org.apache.spark.sql.{DataFrame, Row, SparkSession}
import org.junit.runner.RunWith
import org.scalatest.BeforeAndAfterAll
@feliperazeek
feliperazeek / ty-turtle-jump.py
Created May 24, 2022 20:04
Ty's Python Turtle Game
import turtle
import random
t = turtle.Turtle()
scorey = turtle.Turtle()
score = 0
t.goto(0,0)
scorey.penup()
scorey.goto(200,200)
t.setheading(90)
c = turtle.Turtle()
{
"type" : "record",
"name" : "twitter_schema",
"namespace" : "foo.bar",
"fields" : [ {
"name" : "username",
"type" : "string",
"doc" : "Name of the user account on Twitter.com"
}, {
"name" : "tweet",
import java.util.BitSet
object Solution {
def solution(A: Array[Int]): Int = {
val bitz = new BitSet(A.size + 1)
val good = A.foldLeft(true)((current, i) =>
if (current) {
(i, bitz.get(i)) match {
case (x, _) if x > A.size =>
object Solution {
def solution(A: Array[Int]): Int = {
val positive = new java.util.BitSet()
val negative = new java.util.BitSet()
A.foldLeft(0) { (current, i) =>
val duplicate = if (i < 0) (negative get i * -1)
else (positive get i)
duplicate match {
object Solution {
def solution(A: Array[Int]): Int = {
val (results, _) = A.sorted.foldLeft((0, 0)) { (t, item) =>
val (current, last) = t
val next = last + 1
item match {
case x if x < 0 => (current, last)
case `last` => (item, item)
object Solution {
def solution(A: Array[Int]): Int = {
(A.foldLeft[(Int, Option[Double], Int)]((0, None, -1)) { (t, item) =>
val (index, min, results) = t
val checkPair = index <= A.size - 2
val checkTrio = index <= A.size - 3
import scala.math.{min, abs}
object Solution {
def solution(A: Array[Int]): Int = {
if (A.size < 2 || A.size > 100000) sys.error(s"Invalid input - array size: ${A.size}")
val total = A.map(_.toLong).sum
(A.foldLeft[(Int, Long, Long)](-1, -1, 0l) { (t, i) =>
if (i < -1000 || i > 1000) sys.error(s"Invalid array element: $i")
@feliperazeek
feliperazeek / CodilityMissingInteger.scala
Created September 17, 2015 06:30
Codility Missing Integer in Scala
object Solution {
def solution(A: Array[Int]): Int = {
val bitz = new java.util.BitSet(A.size)
val n = A.foldLeft(0) { (total, i) =>
if (i > 0 && i <= A.size && !bitz.get(i)) {
bitz.set(i)
total + 1
} else total