Skip to content

Instantly share code, notes, and snippets.

View cassdeckard's full-sized avatar
🇵🇸
Free Palestine

Cass D cassdeckard

🇵🇸
Free Palestine
View GitHub Profile
@cassdeckard
cassdeckard / gist:c18b1f24c7efb23735f2
Created May 11, 2015 21:00
Swift can't decide if [String] is Equatable?
import XCTest
class GenericThing<T: Equatable> {
func foo(t: T) {
NSLog("foo \(t)")
}
}
func genericFunc<T: Equatable>(left: T, right: T) {
NSLog("\(left) == \(right) ?: \(left == right)")
@cassdeckard
cassdeckard / test.html
Created March 25, 2016 11:36
IE Compatibility Mode test page
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>IE Compatibility Test</title>
</head>
<body>
<h1 id="test-h1"></h1>
@cassdeckard
cassdeckard / lldb_crash.swift
Created August 10, 2016 19:55
lldb crashes when I try to make Dictionary parameter in a closure a "var"
//: Playground - noun: a place where people can play
import Foundation
// OK:
var test: ([Int : Int], Int) -> [Int : Int] = { (x, y) in x }
// CRASH:
//var test2: ([Int : Int], Int) -> [Int : Int] = { (var x, y) in x }
@cassdeckard
cassdeckard / BaseClass.swift
Last active February 20, 2017 19:10
Potential bug in Swift compiler?
import Foundation
public class BaseClass<H> {
public init?() {
}
}
@cassdeckard
cassdeckard / asciiplay
Last active March 27, 2017 18:29
Tools to help with playing back asciinema recordings in terminal
#!/bin/bash
termsize() {
echo -ne "\033[8;${1};${2}t"
}
asciicast=$1
orig_height=0
orig_width=0
// Setup
var tracklistObj = {},
currentPlaylist,
checkIntervalTime = 100,
lastTime;
// Process the visible tracks
function getVisibleTracks() {
var playlist = document.querySelectorAll('.song-table tr.song-row');
for(var i = 0; i < playlist.length ; i++) {
@cassdeckard
cassdeckard / aoc2018-1-2.swift
Last active February 24, 2019 01:05
AOC 2018 solutions
import Foundation
let data = """
-1
1
"""
var visitedFrequencies = Set<Int>()
let parsedData = data.components(separatedBy: "\n").map{ Int($0)! }
#!/bin/sh
# Shamelessly stolen from https://github.com/neonichu/Core-Audio-Samples/blob/master/Samples/extract-sf2.sh
#
## Convert a SoundFont + MIDI file to a CAF audio file.
##
## needs:
## fluidsynth, sox (installable via brew)
## afconvert (part of OS X)
decode_pinyin = function(pinyin) {
const core = ["a", "e", "i", "o", "u", "ü"]
let arr = pinyin.replace(/<b>|<\/b>|<div>|<\/div>/g, "").split("")
is_core = function(c, c_previous_two = "", c_next = "") {
//pre conditions
if(c == "r" && (c_next == " " || c_next == "") && (c_previous_two != " " && c_previous_two != "")) {
return [true, true]
}