Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am samwarnick on github.
  • I am samwarnick (https://keybase.io/samwarnick) on keybase.
  • I have a public key whose fingerprint is 832B 1123 1466 F2AF 09CC 2BA1 C976 F5BC F57A 5870

To claim this, I am signing this object:

def recurse(r, c, dishes):
dishes[r][c] = " "
# bottom
if r < len(dishes)-1 and dishes[r+1][c] == "#":
recurse(r+1, c, dishes)
# top
if r > 0 and dishes[r-1][c] == "#":
recurse(r-1, c, dishes)
# right
if c < 9 and dishes[r][c+1] == "#":
@samwarnick
samwarnick / fuzzySearch.py
Created March 24, 2016 16:35
a simple fuzzy search algorithm from an interview
fruit = ["watermelon", "apple", "oranges", "bannana"]
def fuzzySearch(words, term):
results = []
if len(term) == 0:
return results
termLength = len(term)
for word in words:
var 😀 = "Hello, World!"
print(😀)
:root {
--lightblue: #65def1;
}
.nav-link {
font-size: 20px;
color: #65def1;
color: var(--lighblue);
}
@samwarnick
samwarnick / UIRoundedButtonWithGradientAndShadow.swift
Last active December 26, 2021 16:45
A rounded button with a gradient and shadow written in swift
class UIRoundedButtonWithGradientAndShadow: UIButton {
let gradientColors : [UIColor]
let startPoint : CGPoint
let endPoint : CGPoint
required init(gradientColors: [UIColor],
startPoint: CGPoint = CGPoint(x: 0, y: 0.5),
endPoint: CGPoint = CGPoint(x: 1, y: 0.5)) {
self.gradientColors = gradientColors
@samwarnick
samwarnick / NoStoryboardAppDelegate.swift
Last active April 19, 2017 16:28
What needs to be added to AppDelegate.swift to be able to not use a storyboard
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
window?.rootViewController = YourFirstViewController()
@samwarnick
samwarnick / ExampleConfigureViewsFunction.swift
Created April 19, 2017 16:32
Example configureViews function of a view controller
func configureViews() {
let authorLabel = UILabel()
authorLabel.defaultStlye()
authorLabel.text = "Created by Sam Warnick"
let websiteButton = UIButton(type: .system)
websiteButton.defaultStlye()
websiteButton.setTitle("samwarnick.com", for: .normal)
websiteButton.addTarget(self, action: #selector(STNCreditsViewController.didPressWebisteButton), for: .touchUpInside)
websiteButton.sizeToFit()
@samwarnick
samwarnick / PageViewControllerGotchas.swift
Created April 19, 2017 16:37
A few lines of code that are necessary to show the page indicator dots
/*
These functions are neccessary for the page indicator dots to show up.
They are optional functions of UIPageViewControllerDataSource, so they do not come up as overrides.
*/
func presentationCount(for pageViewController: UIPageViewController) -> Int {
return orderedViewControllers.count
}
func presentationIndex(for pageViewController: UIPageViewController) -> Int {
return 0
@samwarnick
samwarnick / Segues.swift
Created April 19, 2017 17:32
Programmatic segues
let nextViewController = NextViewController()
nextViewController.modalPresentationStyle = .custom
nextViewController.modalTransitionStyle = .crossDissolve
present(nextViewController, animated: true, completion: nil)