Skip to content

Instantly share code, notes, and snippets.

View arthurpalves's full-sized avatar
👨‍💻

Arthur Alves arthurpalves

👨‍💻
View GitHub Profile
extension Data {
init?(hexString: String) {
let count = hexString.count / 2
var data = Data(capacity: count)
var i = hexString.startIndex
for _ in 0 ..< count {
let j = hexString.index(after: i)
if var byte = UInt8(hexString[i ... j], radix: 16) {
data.append(&byte, count: 1)
} else {
@jordansinger
jordansinger / macOS.swift
Last active February 14, 2024 03:41
macOS SwiftUI Playgrounds code
import SwiftUI
import PlaygroundSupport
struct Desktop: View {
var body: some View {
ZStack {
// Image(uiImage: #imageLiteral(resourceName: "IMG_6281.JPG"))
Color(UIColor.systemBlue)
macOS()
}
@Bunn
Bunn / cleanup.sh
Created May 19, 2019 15:21
Cleanup space
#!/bin/bash
echo "Removing unavailable simulators..."
xcrun simctl delete unavailable
echo "Brew cleanup..."
brew cleanup
echo "Removing Xcode Caches..."
rm -rf ~/Library/Caches/com.apple.dt.Xcode
@arthurpalves
arthurpalves / NegaBinary.java
Last active February 5, 2016 16:26
Negate a negative based binary (base -2) using Two's Complement Annotation.
package com.codility.tasks;
/*
Negate a negative based binary (base -2) using Two's Complement Annotation.
Given a base -2 number splitted into a primitive array of ints (int[]), return it's negation.
EXAMPLES:
INPUT: [0,1,0,0,1,1,1] // Decimal 39.
OUTPUT: [1,0,1,1,0,0,1] // Decimal -39.