Skip to content

Instantly share code, notes, and snippets.

View WilsonGramer's full-sized avatar

Wilson Gramer WilsonGramer

View GitHub Profile
@WilsonGramer
WilsonGramer / ExplicitFunction.py
Created December 19, 2017 21:08
ExplicitFunction created by wilsonator5000 - https://repl.it/@wilsonator5000/ExplicitFunction
# a_n = a_1 + (n - 1)d
# this function assumes that there is a constant slope!
# in the function used, the underscore ('_') defines the 'sub' value of a.
def explicitFormula(set, n):
print('The set is ' + str(set) + '.')
if len(set) > 1:
d = set[1] - set[0] # gets the slope.
Empty file
Empty file
@WilsonGramer
WilsonGramer / combine-strings-by-lines.swift
Last active July 10, 2018 16:09
Combines the input (multiline) strings by line, so that the first line of every string in the input is combined into the first line of the output, and so on.
//
// Combine Strings by Lines
// Wilson Gramer
// July 10, 2018
//
import Foundation
/// Combines the input (multiline) strings by line, so that the first line of every
/// string in the input is combined into the first line of the output, and so on.
@WilsonGramer
WilsonGramer / baseconverter.py
Created August 19, 2018 18:49
baseconverter.py
from math import log, ceil, floor
digit_refs = list('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-/:;()$&@".,?!\'[]{}#%^*+=_\\|~<>€£¥•')
# Inverts the index relative to the length (of an array) provided.
# Example: (3, 0) => 2
def rev(len, index):
return len - 1 - index
class Number:
import Foundation
public struct IntermediateStrideThrough<Number: Strideable, Amount: Comparable & SignedNumeric> {
let from: Number
let by: Amount
public init(from: Number, by: Amount) {
self.from = from
self.by = by
}
@WilsonGramer
WilsonGramer / parse.py
Last active May 20, 2020 03:37
Parse parentheses, brackets and braces, ensuring they are balanced and in the right order
LeftParen = '('
RightParen = ')'
LeftBracket = '['
RightBracket = ']'
LeftBrace = '{'
RightBrace = '}'
class Group(object):
def __init__(self):
self.exprs = []
@WilsonGramer
WilsonGramer / install.sh
Last active June 18, 2021 19:44
Cross-compile Swift 5.4 for arm64 on x64 Ubuntu
set -ex
# Add arm64 packages to apt database
# WARNING: This overwrites the sources.list entirely! If you have custom sources,
# add [arch=amd64] to them instead and just add the [arch=arm64] lines yourself
sudo bash -c 'cat <<EOF > /etc/apt/sources.list
deb [arch=amd64] http://us.archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
deb [arch=amd64] http://us.archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
deb [arch=amd64] http://us.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
-- A work-in-progress recreation of Typing the Technical Interview
-- (https://aphyr.com/posts/342-typing-the-technical-interview) in what will
-- eventually be Wipple's type system!
--
-- 'type' creates marker types. For example, you can define 'Phantom' as either:
-- given (some A) in Phantom : type A
-- Phantom : type (some _)
--
-- 'some' creates invariant type parameters
--
show : external "internal" "show" :: Text -> ()