Skip to content

Instantly share code, notes, and snippets.

View leoniralves's full-sized avatar
:octocat:

Leonir Deolindo leoniralves

:octocat:
View GitHub Profile
@leoniralves
leoniralves / fundamentos_python.md
Created March 13, 2025 14:05
Preparação para a 3ª fase da ONIA - Fundamentos do Python

Preparação para a 3ª fase da ONIA - Fundamentos do Python

1) Manipulação de Listas e Compreensão de Listas**

Qual das seguintes opções gera corretamente uma lista contendo os quadrados dos números pares de 0 a 10?

a)

lista = [x ** 2 for x in range(11) if x % 2 == 0]

Questão: Predição de Preços de Casas com Scikit-learn

Um cientista de dados deseja criar um modelo de regressão linear para prever o preço de uma casa com base em seu tamanho (em metros quadrados). Ele coletou os seguintes dados:

Tamanho (m²) Preço (mil reais)
50 200
80 320
100 400
150 600
@leoniralves
leoniralves / markdown_examples.md
Created February 26, 2024 14:46 — forked from cseeman/markdown_examples.md
Markdown for info panel/warning box

Examples for how to create your own info panel, warning box and other decent looking notification in GitHub markdown.

All the boxes are single/two cell tables or two row tables.

Warning box

❗ You have to read about this
@leoniralves
leoniralves / Data+PrettyPrint.swift
Created November 14, 2022 19:31 — forked from cprovatas/Data+PrettyPrint.swift
Pretty print JSON string from Data in Swift 4.1 (especially useful printing to Xcode console)
import Foundation
extension Data {
var prettyPrintedJSONString: NSString? { /// NSString gives us a nice sanitized debugDescription
guard let object = try? JSONSerialization.jsonObject(with: self, options: []),
let data = try? JSONSerialization.data(withJSONObject: object, options: [.prettyPrinted]),
let prettyPrintedString = NSString(data: data, encoding: String.Encoding.utf8.rawValue) else { return nil }
return prettyPrintedString
}
@leoniralves
leoniralves / DiskStatus.swift
Created October 17, 2022 13:06
iOS Disk Status (Storage)
class DiskStatus {
// MARK: Get String Value
class var totalDiskSpace: String {
get {
return ByteCountFormatter.string(fromByteCount: totalDiskSpaceInBytes, countStyle: ByteCountFormatter.CountStyle.file)
}
}
class var freeDiskSpace: String {
@leoniralves
leoniralves / MemoryUsage.swift
Created October 14, 2022 20:34 — forked from pejalo/MemoryUsage.swift
Swift 4 iOS app memory usage
/// If an error occurs while getting the amount of memory used, the first returned value in the tuple will be 0.
func getMemoryUsedAndDeviceTotalInMegabytes() -> (Float, Float) {
// https://stackoverflow.com/questions/5887248/ios-app-maximum-memory-budget/19692719#19692719
// https://stackoverflow.com/questions/27556807/swift-pointer-problems-with-mach-task-basic-info/27559770#27559770
var used_megabytes: Float = 0
let total_bytes = Float(ProcessInfo.processInfo.physicalMemory)
//
// ExtensionURLRequest.swift
//
// Created by Abhishek Maurya on 16/07/20.
// Copyright © 2020. All rights reserved.
//
import Foundation
extension URLRequest {
@leoniralves
leoniralves / SimulateGestureOnView.swift
Created April 19, 2021 20:33
Simulate Gesture on Views in Swift (draft)
class ViewController: UIViewController {
private(set) var tap: UITapGestureRecognizer
init(tap: UITapGestureRecognizer) {
self.tap = tap
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) {
@leoniralves
leoniralves / SwizzleWithCustomObjects.swift
Created April 19, 2021 11:58
Swizzle methods between two custom objects
class MyObject: NSObject {
@objc dynamic func getName(_ name: String) -> String {
return name
}
}
class FakeMyObject: NSObject {
@objc dynamic func getName(_ name: String) -> String {
return name + " concat"
}
@leoniralves
leoniralves / AsyncDispatcher.swift
Last active March 29, 2021 22:15
To inject, mock, spy and stub DispatchQueue (sync/async).
import Foundation
protocol AsyncDispatcher {
func async(
group: DispatchGroup?,
qos: DispatchQoS,
flags: DispatchWorkItemFlags,
execute work: @escaping @convention(block) () -> Void
)
func async(execute work: @escaping @convention(block) () -> Void)