Skip to content

Instantly share code, notes, and snippets.

View pzp1997's full-sized avatar

Palmer Paul pzp1997

View GitHub Profile
@pzp1997
pzp1997 / nets213-inclass-analysis.ipynb
Last active February 7, 2019 21:52
nets213-inclass-analysis.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
def shared_connected_components(adj_mat_1, adj_mat_2):
'''
invariant: `adj_mat_1` and `adj_mat_2` have the same vertex set
'''
num_vertices = len(adj_mat_1)
cc_id = 0
vertex_to_cc = [None] * num_vertices
cc_to_size = []
num_shared = 0
-- PRIMITIVES
button : List (Attribute msg) -> Element msg
slider : List (Attribute msg) -> Element msg
switch : List (Attribute msg) -> Element msg
label : List (Attribute msg) -> Element msg
image : List (Attribute msg) -> Element msg
-- UIView
{- PATCHES -}
type alias Patches =
List PatchTree
type PatchTree
= Change Patch
| At Int (List PatchTree)
type Patch
public class Main {
public static void main(String[] args) {
PennPerson p = new Professor();
p.sleep(6);
Undergraduate u = new Undergraduate();
// p.teach("CIS 120");
}
}
public interface PennPerson {
{-# LANGUAGE ScopedTypeVariables, TypeApplications, AllowAmbiguousTypes #-}
-- {-# OPTIONS_GHC -fdefer-type-errors #-}
module Queue where
import Data.Maybe (fromJust)
import Test.QuickCheck
class Queue q where
empty :: q a
group :: Eq a => [a] -> [(a, Int)]
group = foldr step []
where step c [] = [(c, 1)]
step c whole@((x, n) : xs)
| c == x = (x, n + 1) : xs
| otherwise = (c, 1) : whole
compress :: String -> String
compress =
concatMap f . group
@pzp1997
pzp1997 / setInterval.swift
Last active January 19, 2021 09:34
Rough implementation of the JavaScript setInterval function in Swift. Good for JavaScriptCore.
var nextTimerId = 0
var timerRegistry = [Int: Timer]()
let setInterval: @convention(block) (JSValue, Double) -> Int = { (function, interval) in
let timer = Timer.scheduledTimer(timeInterval: interval / 1000.0, repeats: true, action: { (timer) in
function.call(withArguments: [])
})
let timerId = nextTimerId
timerRegistry[timerId] = timer
// EXTRA STUFF TO MAKE IT RUN
var __2_TAGGER = 'tagger';
var __2_THUNK = 'thunk';
var __2_LEAF = 'leaf';
var __2_PARENT = 'parent';
function F2(fun) {
function wrapper(a) {
return function(b) {
@pzp1997
pzp1997 / index.html
Created July 10, 2017 19:24
Flexbox redesign of palmerpaul.com homepage. https://jsfiddle.net/pzp1997/unucxb46/1/
<!doctype html>
<html>
<head>
<link href="https://cdnjs.cloudflare.com/ajax/libs/normalize/7.0.0/normalize.min.css">
<link href="https://fonts.googleapis.com/css?family=Lobster|Roboto|Rubik:500" rel="stylesheet">
<link href="site.css" rel="stylesheet">
</head>
<body>