Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View callionica's full-sized avatar
🏠
Working from home

Callionica callionica

🏠
Working from home
View GitHub Profile
"use strict";
ObjC.import('Foundation');
var fm = $.NSFileManager.defaultManager;
var app = Application.currentApplication();
app.includeStandardAdditions = true;
var path = $.NSString.alloc.initWithUTF8String(app.pathTo(this)).stringByDeletingLastPathComponent.js + "/";
var sizes = [
// [ 640, 960, "phone-35"],
[ 640, 1136, "phone-40"],
[ 750, 1334, "phone-47"],
[1242, 2208, "phone-55"],
// [ 768, 1024, "pad-x1"],
[1536, 2048, "pad-x2"],
[2048, 2732, "pad-pro"],
];
// Types work but are not optimal - no error handling
// Demo in response to https://gist.github.com/sketchytech/029c00a74a4217a89797
extension CollectionType {
func reorder<T>(sorter: [(index: Self.Index, element: T)]) -> Array<Self.Generator.Element> {
return sorter.map({self[$0.index]})
}
}
func sortColumns<T0, T1>(_ col0: Array<T0>, _ col1: Array<T1>, _ cmp: (T0,T0)->Bool) -> (Array<T0>, Array<T1>) {
// C# equivalent of buckets.swift
using System;
using System.Collections.Generic;
interface IFeed {
String url { get; }
}
class LocalFeed : IFeed {
public String url { get; set; }
// Protocol
protocol Feed {
var url : String { get }
}
// Concrete classes
class LocalFeed : Feed {
var url : String = "file://Local"
}