Skip to content

Instantly share code, notes, and snippets.

View NachoSoto's full-sized avatar

NachoSoto NachoSoto

View GitHub Profile
// Compile with `swiftc switch.swift`
enum A {
case A(Int)
case B(Bool)
case C
case D
}
enum B {
enum A {
case A1
}
enum B {
case B1
var a: A {
return .A1
}
}
//select ::[a] ->[(a, [a])]
//select[] = []
//select(x:xs) = (x, xs) : [(y, x:ys) | (y, ys) <-select xs]
func select<T>(input: [T]) -> [(T, [T])] {
if (input.isEmpty) {
return []
} else {
let head = input[0]
let rest = Array(input[1..<input.count])
@NachoSoto
NachoSoto / ExtendedProtocol
Last active August 29, 2015 14:12
Generic parameter ’T’ cannot be bound to non-@objc protocol type ‘Protocol’.
protocol BaseProtocol {}
protocol ExtendedProtocol: BaseProtocol {}
class A<T: BaseProtocol> {
private let t: T
init(a: T) { self.t = a }
}
class B<T: ExtendedProtocol> {
@NachoSoto
NachoSoto / makemake.pl
Last active August 29, 2015 14:11 — forked from roop/makemake.pl
#!/usr/bin/perl -w
use strict;
use Path::Iterator::Rule;
use String::ShellQuote;
# Makefile generator for quick compilation of Swift projects
# By: Roopesh Chander
# Thanks: Andy Matuschak
# Works only for swift-only projects.
@NachoSoto
NachoSoto / makemake.pl
Last active August 29, 2015 14:11 — forked from roop/makemake.pl
#!/usr/bin/perl -w
use strict;
# Makefile generator for quick compilation of Swift projects
# By: Roopesh Chander
# Thanks: Andy Matuschak
# Works only for swift-only projects.
# Usage:
# > perl makemake.pl
# > make
Incident Identifier: 0A56BB09-A7BF-40D4-9318-704746E02D80
CrashReporter Key: 34179ee1342c333e108a7bdd82b07ba9bb595bfc
Hardware Model: iPhone7,2
Process: Spotify [1254]
Path: /private/var/mobile/Containers/Bundle/Application/4841D500-3B9C-4340-960A-52F8D8ADAD2E/Spotify.app/Spotify
Identifier: com.spotify.client
Version: 170100007 (1.7.1)
Code Type: ARM (Native)
Parent Process: launchd [1]
#!/bin/bash
if [[ -n "$1" ]]; then
if [[ $2 == '--good' ]]; then
ffmpeg -i "$1" -r 24 -vcodec png out-static-%05d.png
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > "$1".gif
rm out-static*.png
else
ffmpeg -i "$1" -s 600x400 -pix_fmt rgb24 -r 24 -f gif - | gifsicle --optimize=3 --delay=3 > "$1".gif
fi
//
// MSRegex.cpp
// CoreMS
//
// Created by Nacho Soto on 6/27/14.
// Copyright (c) 2014 MindSnacks. All rights reserved.
//
#include "MSRegex.h"
#!/bin/bash
if [[ -n "$1" ]]; then
if [[ $2 == '--good' ]]; then
ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif
rm out-static*.png
else
ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 24 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif
fi