Skip to content

Instantly share code, notes, and snippets.

View LucasAlfare's full-sized avatar
💭
Attempting "masterize" JetPack Compose

Francisco Lucas LucasAlfare

💭
Attempting "masterize" JetPack Compose
View GitHub Profile
@LucasAlfare
LucasAlfare / midi_helper.py
Created September 1, 2022 20:00
Parse midi file notes to an simplified format of data with python using miditoolkit library.
def parse_midi_file_to_simplified_notes(midi_file_path):
class SimplifiedNote:
def __init__(self, pitch, duration=-1):
notes_names = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']
self.pitch = pitch
self.duration = duration
self.name = notes_names[pitch % 12]
self.depth = pitch // 12
@LucasAlfare
LucasAlfare / Sudoku.kt
Last active July 13, 2022 23:28
Standard Sudoku solver written in Kotlin. This code solves the sudoku using the backtracing approach and also includes a function to generate random sudoku boards.
package lucasalfare.sudoku
enum class State {
Hidden, Empty, PreSolved, Filled
}
data class Cell(
var number: Int, var state: State = State.Empty
)
@LucasAlfare
LucasAlfare / Tokenizer.kt
Last active May 20, 2022 17:39
My simplest attempt of a math expression tokenizer, written in Kotlin.
enum class TokenType {
UNR,
OPR,
NUM,
PAR
}
class Token(val type: TokenType, val value: String) {
override fun toString() = "{ type=$type, value=$value }"
}
from tkinter import *
import random
class Repeater:
def __init__(self):
self.isRunning = True
self.callback = None
import threading
@LucasAlfare
LucasAlfare / draft.py
Last active April 8, 2022 01:21
Attempt of building a console timer in python, current unfinished and untested
import time
import keyboard
ONE_MILLISECOND = 1 / 1000
def currentTime():
return round(time.time() * 1000)
# This .gitignore file should be placed at the root of your Unity project directory
#
# Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore
#
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/[Ll]ogs/
@LucasAlfare
LucasAlfare / build.gradle.kts
Created November 12, 2021 02:57
Proper way to set jar build task in gradle with Kotlin DSL. Note to the "duplicatesStrategy" at beggining.
tasks.withType<Jar> {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
manifest {
attributes["Main-Class"] = "hehe.MainKt"
}
from(sourceSets.main.get().output)
dependsOn(configurations.runtimeClasspath)
@LucasAlfare
LucasAlfare / App.js
Last active July 11, 2021 23:52
React component to acts as a Chronometer/Timer. It already has a H1 to display time running but can easly receive other designed components through props. Also this is built in a better architecture (event driven pattern) in order to offer a better performance and good practices approach.
import { useEffect, useState } from "react";
import ComponentManager from "./ComponentManager.js";
//this instance can "emit" events for any observable/listenable
const manager = new ComponentManager();
//The react component
function Timer() {
const [time, setTime] = useState("ready");
@LucasAlfare
LucasAlfare / Timer.js
Last active July 11, 2021 23:28
React component to acts as a Chronometer/Timer. It already has a H1 to display time running but can easly receive other designed components through props.
import { useEffect, useState, useRef } from "react";
/** Basic function to add trailing characters in front a other value in a specified count. */
function padStart(value, count, character) {
let str = `${value}`;
if (str.length < count) {
for (let i = 0; i < count - str.length + 1; i++) {
str = `${character}${str}`;
}
}
@LucasAlfare
LucasAlfare / index.html
Created February 16, 2021 23:54
Passando o tempo no computador da farmácia...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Contagem regressiva para o plantão acabar</title>
<div class="panel">
<h1 id="display" class='display'>carregando...</h1>