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 org.antlr.v4.runtime.ANTLRInputStream; | |
import org.antlr.v4.runtime.CommonTokenStream; | |
import org.antlr.v4.runtime.ParserRuleContext; | |
import org.antlr.v4.runtime.Token; | |
import org.antlr.v4.runtime.tree.*; | |
import org.antlr.v4.runtime.*; | |
import java.io.FileInputStream; | |
import java.io.InputStream; | |
import org.antlr.v4.runtime.CharStreams; |
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
export CLASSPATH=".:/usr/local/lib/antlr-4.11.1-complete.jar:$CLASSPATH" | |
alias antlr4='java -jar /usr/local/lib/antlr-4.11.1-complete.jar' | |
alias grun='java org.antlr.v4.gui.TestRig' |
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
// Generates listeners | |
antlr4 ArrayInit.g4 | |
// Compiles java listeners | |
javac -cp /usr/local/lib/antlr-4.7.1-complete.jar ArrayInit*.java |
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
extension Date { | |
static let decodeFormats: [String] = ["yyyy-MM-dd'T'HH:mm:ss.SSSZ"] | |
func encodedDateString() -> String { | |
let formatter = DateFormatter() | |
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ" | |
return formatter.string(from: self) | |
} | |
} |
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
# Usage e.g.: python3 unused_assets.py '/Users/DevK/MyProject' '/Users/DevK/MyProject/MyProject/Assets/Assets.xcassets' | |
# It is important to pass project folder path as first argument, assets folder path as second argument | |
# It is assumed that all the images are maintained within Assets.xcassets folder and are used either within swift files or within storyboards | |
""" | |
@author = "Devarshi Kulshreshtha" | |
@copyright = "Copyright 2020, Devarshi Kulshreshtha" | |
@license = "GPL" | |
@version = "1.0.2" | |
@contact = "kulshreshtha.devarshi@gmail.com" |
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
# divide and conquer approach | |
def mergeSort(array): | |
# divides the array into sub-parts | |
length = len(array) | |
if length == 1 or length == 0: | |
# returns leaf node | |
return array | |
# obtain mid index | |
mid = length // 2 | |
# obtain left 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
import Foundation | |
/// Protocol supporting decoding of a plist to associated data model | |
protocol PlistDecoder { | |
associatedtype PlistModel: Decodable | |
func decodedValue() -> PlistModel? | |
} | |
/// Implementation of PlistDecoder with decoding capability |
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 Stack { | |
var lastNode: Node? = nil | |
class Node { | |
var data: Int! | |
var prev: Node? | |
init(data: Int, prev: Node?) { | |
self.data = data | |
self.prev = prev | |
} |
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
protocol StoryboardIdentifiable { | |
static var storyboardIdentifier: String { get } | |
} | |
extension StoryboardIdentifiable where Self: UIViewController { | |
static var storyboardIdentifier: String { | |
return String(describing: self) | |
} | |
} |
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
protocol Reusable: class { | |
static var reuseIdentifier: String { get } | |
} | |
extension Reusable { | |
static var reuseIdentifier: String { | |
// I like to use the class's name as an identifier | |
// so this makes a decent default value. | |
return String(describing: self) | |
} |
NewerOlder