Skip to content

Instantly share code, notes, and snippets.

View amadeu01's full-sized avatar
:octocat:
Working from Stockholm

Amadeu Cavalcante Filho amadeu01

:octocat:
Working from Stockholm
View GitHub Profile
@amadeu01
amadeu01 / Graph.swift
Created November 11, 2024 16:59
Animated graph for swiftUI
import SwiftUI
import PlaygroundSupport
struct GraphView: View {
@State private var adjacencyMatrix: [[Int]] = [
[0, 1, 0, 0],
[1, 0, 1, 0],
[0, 1, 0, 1],
[0, 0, 1, 0]
//: A UIKit based Playground for presenting user interface
import SwiftUI
import PlaygroundSupport
import SwiftUI
struct GraphView: View {
@State private var adjacencyMatrix: [[Int]] = [
[0, 1, 0, 0],
[1, 0, 1, 0],
@amadeu01
amadeu01 / main.dart
Created June 6, 2024 16:38
Generated code from pixels2flutter.dev
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
import SwiftUI
import UIKit
class CustomLargeTitleNavigationBar: UINavigationBar {
private lazy var view: UIView = {
let view = UIView()
view.backgroundColor = .red
view.translatesAutoresizingMaskIntoConstraints = false
view.widthAnchor.constraint(equalToConstant: 200).isActive = true
@amadeu01
amadeu01 / build.gradle
Created October 4, 2019 01:08
Added custom ruleset
dependencies {
//... Other dependencies
// Ktlint
ktlintRuleset project(":custom-ktlint-rules")
}
@amadeu01
amadeu01 / build.gradle
Created October 4, 2019 01:07
spotless setup
spotless {
kotlin {
ktlint("$ktlint_version")
licenseHeader '/* Licensed under MIT */'
}
}
@amadeu01
amadeu01 / gradle.build
Created October 4, 2019 01:04
stotless setup
plugins {
id "kotlin"
id 'application'
id "com.diffplug.gradle.spotless" version "$spotless_version"
}
@amadeu01
amadeu01 / build.gradle
Created October 4, 2019 01:01
ktlint plug-in
plugins {
id "kotlin"
id 'application'
id "org.jlleitschuh.gradle.ktlint" version "$ktlint_plugin_version"
}
ktlint {
version = "$ktlint_version"
debug = false
verbose = false
@amadeu01
amadeu01 / custom_no_var.kt
Created October 4, 2019 00:58
Custom no var rule
class NoVarRule : Rule("no-var") {
override fun visit(
node: ASTNode,
autoCorrect: Boolean,
emit: (offset: Int, errorMessage: String, canBeAutoCorrected: Boolean) -> Unit
) {
if (node.elementType == VAR_KEYWORD) {
emit(node.startOffset, "😱 Unexpected var, use val instead 🏄‍", false)
}
@amadeu01
amadeu01 / customRule.kt
Created September 14, 2019 16:28
Custom Rule for ktlint
class CustomRuleSetProvider : RuleSetProvider {
override fun get() = RuleSet("rules",
NoInternalImportRule(),
NoVarRule()
)
}
class NoInternalImportRule : Rule("no-internal-import") {
override fun visit(
node: ASTNode, autoCorrect: Boolean,