Skip to content

Instantly share code, notes, and snippets.

View alexwal's full-sized avatar
❤️
🧡💛💚💙💜🖤

Alexander Walczak alexwal

❤️
🧡💛💚💙💜🖤
  • New York, NY
View GitHub Profile
COMBO: Transport/Refusal/Canceled/Unfounded/Gone (94/93/87/90/96)
Transport: What pt told you (subjective)
Unit 93K1 dispatched to a X.
Unit responded non?emergent and arrived on scene WOI.
Upon arrival, unit found X yo fe/male, conscious, alert, breathing?, standing/semi-Fowler’s in bed/sitting in chair, in no obvious distress?
Pt reports chief complaint starting X days ago (SAMPLE/OPQRST). Pain X out of 10. “Pt quote.”
Pt denies consumption of alcohol/reports drinking N alcoholic beverages when?
Pt states PMHX of?
Pt reports/denies HNBP, HA, CP, SOB, LOC, head strike, DNV, and blood thinners.
// Safely Modifying The View State (SwiftUI)
// https://swiftui-lab.com
// https://swiftui-lab.com/state-changes
import SwiftUI
struct CustomView: View {
var body: some View {
NavigationView {
@alexwal
alexwal / generateRandomPastelColor.swift
Last active March 5, 2021 21:40 — forked from JohnCoates/generateRandomPastelColor.swift
Randomly generate pastel UIColor in Swift
// Adapted from Stack Overflow answer by David Crow http://stackoverflow.com/a/43235
// Question: Algorithm to randomly generate an aesthetically-pleasing color palette by Brian Gianforcaro
// Method randomly generates a pastel color, and optionally mixes it with another color
import UIKit
func randomPastelColor(mixedWith mixColor: UIColor? = nil) -> UIColor {
// Mix the color
let mixColor: UIColor = mixColor ?? .lightGray
var mixRed: CGFloat = 0, mixGreen: CGFloat = 0, mixBlue: CGFloat = 0;
/// A fun Swift 5 way to concatenate a collection of String? elements, for example a [String?].
extension String.StringInterpolation {
mutating func appendInterpolation(_ array: [String?]) {
appendLiteral(array.compactMap { $0 }.joined(separator: ", "))
}
}
let array: [String?] = [nil, nil, "hello", nil, "world", nil, "abc", nil, nil, nil, nil]
print(array) // prints "[nil, nil, Optional("hello"), nil, Optional("world"), nil, Optional("abc"), nil, nil, nil, nil]"
print("\(array)") // prints "hello, world, abc"
@alexwal
alexwal / share_variables_decorator.py
Created December 27, 2018 22:19 — forked from danijar/share_variables_decorator.py
TensorFlow decorator to share variables between calls. Works for both functions and methods.
import functools
import tensorflow as tf
class share_variables(object):
def __init__(self, callable_):
self._callable = callable_
self._wrappers = {}
@alexwal
alexwal / tensorflow-graph-error-handling.py
Last active December 15, 2020 12:03
Example of how to handle errors in a tf.data.Dataset input pipeline
import tensorflow as tf
def create_bad_dataset(create_batches=True):
dataset = tf.data.Dataset.from_tensor_slices([1., 2., 0., 4., 8., 16.])
# Computing `tf.check_numerics(1. / 0.)` will raise an InvalidArgumentError.
if create_batches:
# Demonstrates that error handling works with map_and_batch
dataset = dataset.apply(tf.contrib.data.map_and_batch(
map_func=lambda x: tf.check_numerics(1. / x, 'error'), batch_size=2))
@alexwal
alexwal / 4Sum.py
Last active September 11, 2018 20:11
Leet Code 4Sum Solution: https://leetcode.com/problems/4sum/
class Solution:
"""
Solution to Leet Code problem 4Sum: https://leetcode.com/problems/4sum/
Runtime: 100 ms beats 93.4% of python3 submissions
"""
def fourSum(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[List[int]]
# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license" file accompanying this file. This file is distributed
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
@alexwal
alexwal / mergesort.py
Last active November 27, 2021 03:46 — forked from jogi/mergesort.py
Recursive Mergesort in Python
# Alex Walczak, 2017
# Simple recursive merge sort implementation.
def merge(left, right):
if not (len(left) and len(right)):
return left or right
result = []
i = j = 0
while len(result) < len(left) + len(right):
if i == len(left) or j == len(right):
@alexwal
alexwal / cluster_barrier_for_tensorflow.py
Last active March 27, 2020 07:13 — forked from yaroslavvb/simple_barrier.py
Example of using shared counters to implement Barrier primitive
'''
Alex Walczak, 2017
Example of barrier implementation using TensorFlow shared variables
across a multi-machine cluster.
All workers synchronize on the barrier, copy global parameters to local versions,
and increment the global parameter variable asynchronously.
On each worker run: