Skip to content

Instantly share code, notes, and snippets.

View Azoy's full-sized avatar
:shipit:

Alejandro Alonso Azoy

:shipit:
View GitHub Profile
@Azoy
Azoy / default-values-init.md
Last active October 21, 2018 21:02
Synthesize default values in the memberwise initializer
@Azoy
Azoy / nnnn-rng-fill-buffer.md
Created April 25, 2018 01:50
Add `fillBuffer(_:)` to `RandomNumberGenerator` (WIP)

Add fillBuffer(_:) to RandomNumberGenerator

Introduction

This proposal aims to add a new method, fillBuffer(_:), to RandomNumberGenerator, and aims to move an already defaulted method into a requirement.

@Azoy
Azoy / Day1.cpp
Created March 7, 2018 02:16
Advent of Code 2017
#include <iostream>
#include <string>
int solve_capcha(int *ptr, int size) {
int tmp = 0;
for (int i = 0; i < size; i++) {
int index = i - 1;
if (i == 0) {
index = size - 1;
@Azoy
Azoy / potential.swift
Created November 16, 2017 04:14
Randomizable Potential
struct Date : Randomizable, Strideable {
typealias Stride = Int
let timestamp: UInt32
static func random<T: RandomNumberGenerator>(using generator: T) -> Date {
return Date(timestamp: (0 ... UInt32.max).random!)
}
func distance(to other: Date) -> Int {
@Azoy
Azoy / Random.swift
Last active January 22, 2018 02:06
import Darwin
public protocol RandomGenerator {
func next<T : FixedWidthInteger>(_ type: T.Type) -> T
func next<T : FixedWidthInteger>(_ type: T.Type, upperBound: T) -> T
}
public enum Random : RandomGenerator {
case `default`
@Azoy
Azoy / Random.swift
Last active November 13, 2017 11:01
Swift Random Unification Design
public protocol RandomSource {
static var shared: RandomSource { get }
func next<T : FixedWidthInteger>(_ type: T.Type) -> T
func nextUniform<T : BinaryFloatingPoint>(_ type: T.Type) -> T
}
// Utilizes /dev/urandom
public class DevRandom: RandomSource {
public static let shared = DevRandom()
@Azoy
Azoy / install-swift-ubuntu.md
Last active December 9, 2022 03:42
Guide on how to install Swift on Ubuntu

Install Swift on Ubuntu

Requirements

  1. Ubuntu 14.04, 16.04, or 16.10

Step 1 - Dependencies

  1. Open up terminal
  2. Install core deps: sudo apt-get install clang libicu-dev git

Step 1.1 - Ubuntu 14.04 Clang