#!/bin/bash
touch temp.text
lsof -n -i4TCP:$1 | awk '{print $2}' > temp.text
pidToStop=`(sed '2q;d' temp.text)`
> temp.text
if [[ -n $pidToStop ]]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Heap: | |
def __init__(self, array, is_min_heap=False): | |
self.comparison_func = MIN_HEAP_FUNC if is_min_heap else MAX_HEAP_FUNC | |
self.heap = self.build_heap(array) | |
self.length = len(self.heap) | |
def __len__(self): | |
return self.length | |
def build_heap(self, array): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Decamelizes a string with/without a custom separator (underscore by default). | |
* | |
* @param str String in camelcase | |
* @param separator Separator for the new decamelized string. | |
*/ | |
function decamelize(str, separator){ | |
separator = typeof separator === 'undefined' ? '_' : separator; | |
return str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Helper.swift | |
// A small collection of quick helpers to avoid repeating the same old code. | |
// | |
// Created by Paul Hudson on 23/06/2019. | |
// Copyright © 2019 Hacking with Swift. All rights reserved. | |
// | |
import UIKit |
After ssh
-ing into our host, do the following:
-
Ensure that you are currently in your home directory by running
cd ~/
. -
Run
vi ~/.bash_profile
. This command translates to "edit this text file in the vim text editor" -
Once you're in the text editor, press
i
to go into insert mode. -
Copy/paste the block of code below into your file:
# reload bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
// NEEDS to be used as an Xcode Snippet. | |
func getInputFromUser(){ | |
let alert = UIAlertController(title: <#Domain-specific title: String>, message: "", preferredStyle: .alert) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
// NOTE: The objects you wish to save to disk must conform to the Codable protocol | |
class Todo: Codable { | |
let name: String | |
private(set) var done: Bool = false | |
init(name: String) { | |
self.name = name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension Array where Element: Numeric { | |
/// Returns a number that is sum of the elements in the sequence. | |
func sum() -> Element { | |
return self.reduce(0) { (res, next) -> Element in | |
res + next | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
precedencegroup ExponentiationPrecedence { | |
associativity: right | |
higherThan: MultiplicationPrecedence | |
} | |
infix operator **: ExponentiationPrecedence | |
func ** (lhs: Int, rhs: Int) -> Int { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Alert.swift | |
// DoTryCatch | |
// | |
// Created by Sean Allen on 8/30/17. (Big ups to Sean Allen) | |
// Copyright © 2017 Sean Allen. All rights reserved. | |
// | |
import Foundation | |
import UIKit |
NewerOlder