Skip to content

Instantly share code, notes, and snippets.

View buscarini's full-sized avatar

José Manuel Sánchez buscarini

View GitHub Profile
@buscarini
buscarini / GlobalHCenteringView.swift
Created February 21, 2022 07:44
A SwiftUI view that centers the content in the screen if it fits
import Foundation
import SwiftUI
public protocol CGSizePreferenceKey: PreferenceKey where Value == CGSize {}
public extension CGSizePreferenceKey {
static func reduce(value _: inout CGSize, nextValue: () -> CGSize) {
_ = nextValue()
}
}
@buscarini
buscarini / Mastermind.hs
Last active September 29, 2016 10:16
Mastermind game in Haskell
module Mastermind
where
import System.Random
import Text.Read
import Data.Maybe
import Data.Char
data Color = Red | Green | Blue | Yellow | Brown | Orange | Black | White deriving (Show, Read, Eq, Ord, Bounded, Enum)
@buscarini
buscarini / remove_sim_dups.py
Created July 15, 2015 07:09
Remove Xcode duplicated simulators
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
from subprocess import Popen, PIPE
from subprocess import call
p = Popen(["xcrun","simctl","list","devices"], stdin=PIPE, stdout=PIPE, stderr=PIPE)
output, err = p.communicate(b"input data that is passed to subprocess' stdin")