Skip to content

Instantly share code, notes, and snippets.

@RxDx
RxDx / .bashrc
Created May 6, 2026 23:09
Bash PS1
parse_git_branch() {
git branch 2>/dev/null | sed -n 's/^\* \(.*\)/[\1]/p'
}
# Colors
COLOR_DEF='\[\e[0m\]'
COLOR_USR='\[\e[38;5;243m\]'
COLOR_DIR='\[\e[38;5;39m\]'
COLOR_GIT='\[\e[38;5;197m\]'
@RxDx
RxDx / .zshrc
Created May 6, 2026 22:59
Bash PROMPT
parse_git_branch() {
git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p'
}
COLOR_DEF='%f'
COLOR_USR='%F{243}'
COLOR_DIR='%F{39}'
COLOR_GIT='%F{197}'
# About the prefixed `$`: https://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_03.html#:~:text=Words%20in%20the%20form%20%22%24',by%20the%20ANSI%2DC%20standard.
NEWLINE=$'\n'
# Set zsh option for prompt substitution
@RxDx
RxDx / SWAP.sh
Created August 6, 2024 17:10
VPS Set Up SWAP Partition
# Check Existing SWAP
swapon --show
# Set Up SWAP
fallocate -l 2G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
# Make SWAP Persistant Across Reboots
@RxDx
RxDx / playground.swift
Created October 10, 2019 23:51
SwiftUI @ Playground
import SwiftUI
import PlaygroundSupport
struct ContentView: View {
var body: some View {
Text("Hello World")
}
}
let host = UIHostingController(rootView: ContentView())
//
// RestAPI.swift
// RestAPI
//
// Created by Rodrigo Dumont on 25/04/18.
//
open class RestAPI<T: Codable> {
public typealias Then = (T?, Error?) -> ()
@RxDx
RxDx / Theme.swift
Created December 19, 2017 10:04
iOS Theme
import UIKit
enum Theme {
case light
case dark
}
extension Theme {
var defaultTextColor: UIColor {
switch self {
@RxDx
RxDx / MacOSLogoutHook.txt
Last active July 18, 2024 02:23
MacOS: Run script before shutdown
Create a file:
$ pico /Users/Shared/logoutHook.sh
File content:
#!/bin/bash
say 'Hasta la vista baby!'
Set exuction permission:
$ sudo chmod +x /Users/Shared/logoutHook.sh
// MARK: - String mask
class Mask {
class func maskCep(CepString: String?) -> String {
guard let CepString = CepString else {
return ""
}
var text = CepString.replacingOccurrences(of: "-", with: "")
@RxDx
RxDx / BaseRepository.swift
Last active July 18, 2024 02:25
BaseRepository Swift
//
// BaseRepository.swift
//
// Created by Rodrigo Dumont on 7/4/16.
// Copyright © 2016 Rodrigo Dumont. All rights reserved.
//
import Alamofire
import SwiftyJSON