Skip to content

Instantly share code, notes, and snippets.

@LeonardoCardoso
LeonardoCardoso / gitzip.sh
Last active October 9, 2023 22:38
Zip folder ignoring files listed on .gitignore
#...
function gitzip() {
git archive -o $@.zip HEAD
}
#... gitzip ZIPPED_FILE_NAME
@LeonardoCardoso
LeonardoCardoso / SyntaxProtocol+Extension.swift
Last active August 19, 2023 16:54
A SyntaxProtocol extension that simplifies the casting of all SyntaxProtocol derived entities.
import SwiftSyntax
// swift-syntax v509.0.0-swift-DEVELOPMENT-SNAPSHOT-2023-08-15-a
extension SyntaxProtocol {
var token: TokenSyntax? { self.as(TokenSyntax.self) }
var accessorBlock: AccessorBlockSyntax? { self.as(AccessorBlockSyntax.self) }
var accessorDeclList: AccessorDeclListSyntax? { self.as(AccessorDeclListSyntax.self) }
var accessorDecl: AccessorDeclSyntax? { self.as(AccessorDeclSyntax.self) }
var accessorEffectSpecifiers: AccessorEffectSpecifiersSyntax? { self.as(AccessorEffectSpecifiersSyntax.self) }
var accessorParameters: AccessorParametersSyntax? { self.as(AccessorParametersSyntax.self) }
@LeonardoCardoso
LeonardoCardoso / GPG-Tower
Last active April 21, 2023 11:53
How to setup Tower to use the GPG Suite
# GPG on Tower
extension String {
var isCPF: Bool {
let cpf = self.stringByReplacingOccurrencesOfString(".", withString: "").stringByReplacingOccurrencesOfString("-", withString: "")
if cpf.characters.count == 11 {
let d1 = Int(cpf.substringWithRange(Range(cpf.startIndex.advancedBy(9) ..< cpf.startIndex.advancedBy(10))))
let d2 = Int(cpf.substringWithRange(Range(cpf.startIndex.advancedBy(10) ..< cpf.startIndex.advancedBy(11))))
@LeonardoCardoso
LeonardoCardoso / ScrollTextView.java
Last active January 21, 2022 07:37
TextView with continuous scroll marquee animation no matter where the Activity focus is.
public class ScrollTextView extends TextView {
public ScrollTextView(Context context) {
super(context);
}
public ScrollTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}

Keybase proof

I hereby claim:

  • I am leonardocardoso on github.
  • I am leocardz (https://keybase.io/leocardz) on keybase.
  • I have a public key ASBs8fvDkGu3xRc1wSo88cqv7PVcNOKQInTQSQrppHJKJQo

To claim this, I am signing this object:

@LeonardoCardoso
LeonardoCardoso / UIViewControllerExtension.swift
Created January 22, 2017 00:54
Topmost View Controller
import UIKit
extension UIViewController {
static var topmostViewController: UIViewController? { return UIApplication.shared.keyWindow?.topmostViewController }
var topmostViewController: UIViewController? { return presentedViewController?.topmostViewController ?? self }
}
@LeonardoCardoso
LeonardoCardoso / feed.xml
Last active January 1, 2020 19:00
Jekyll XML RSS Feed
---
layout: null
permalink: /feed.xml
---
{% assign feed_url = page.url | absolute_url %}<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>{{ site.title }}</title>
<subtitle>By {{ site.author.name }}</subtitle>
<link rel="alternate" type="text/html" href="{{ site.url }}" />
<link rel="self" type="application/atom+xml" href="{{ feed_url }}" />
@LeonardoCardoso
LeonardoCardoso / feed.json
Created December 16, 2019 22:19
Jekyll JSON RSS Feed
---
layout: null
permalink: /feed.json
---
{
"version": "https://jsonfeed.org/version/1",
"title": "{{ site.title }}",
"description": "{{ site.description }}",
"home_page_url": "{{ '/' | absolute_url }}",
"feed_url": "{{ page.url | absolute_url }}",
@LeonardoCardoso
LeonardoCardoso / simulatorFullScreen.sh
Last active November 25, 2019 23:40
iOS Simulator Full screen
defaults write com.apple.iphonesimulator AllowFullscreenMode -bool YES