This file contains hidden or 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 javax.swing.JFrame | |
| import javax.swing.JPanel | |
| import java.awt.Color | |
| import java.awt.Graphics | |
| import java.awt.Graphics2D | |
| /** | |
| * Created by aman on 1/29/14. | |
| */ |
This file contains hidden or 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 MobileCoreServices; | |
| @import AVFoundation; | |
| @import AssetsLibrary; | |
| // ... | |
| - (void)cropVideoAtURL:(NSURL *)videoURL toSquareWithSide:(CGFloat)sideLength completion:(void(^)(NSURL *resultURL, NSError *error))completionHander { | |
| /* asset */ |
This file contains hidden or 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 java.io.File | |
| import java.time.LocalDate | |
| import java.util.Locale | |
| import java.time.format.DateTimeFormatter | |
| // Get the path from command line argument | |
| val path = args(0) // no check! | |
| // Step 1: Get sprint file names and start date | |
| val sprints = new File(path).listFiles.filter(_.getName.endsWith(".xml")).map{ file => (file.getName.dropRight(4), path+"/"+file.getName ) }.toList |
This file contains hidden or 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
| // This is the protocol, that defines family of weapon | |
| protocol Weapon{ | |
| func fire(); // Weapon can be fire | |
| } | |
| // This is the player definition | |
| class Player{ | |
| // Current weapon i.e. the current strategy/algorithm | |
| var currentWeapon:Weapon?; | |
This file contains hidden or 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 Blade{ | |
| func stab(); | |
| } | |
| struct Knife:Blade{ | |
| func stab(){ | |
| print("Stabing with Knife!") | |
| } | |
| } |
This file contains hidden or 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
| struct BladeAdapterForWeapon:Weapon{ | |
| var blade:Blade | |
| func fire(){ | |
| self.blade.stab() | |
| } | |
| } | |
| struct ExplosiveAdapterForWeapon:Weapon{ | |
| var explosive:Explosive | |
| func fire(){ |
This file contains hidden or 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
| // This is the protocol, that defines family of weapon | |
| protocol Weapon{ | |
| func fire(); // Weapon can be fire | |
| } | |
| // This is the player definition | |
| class Player{ | |
| // Current weapon i.e. the current strategy/algorithm | |
| var currentWeapon:Weapon?; | |
This file contains hidden or 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
| // This is the player definition | |
| class Player{ | |
| // Current weapon i.e. the current strategy/behavior | |
| var currentWeapon:Weapon?; | |
| // Dynamically sets the current weapon | |
| func select(weapon:Weapon){ | |
| self.currentWeapon = weapon; | |
| } | |
This file contains hidden or 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 Player{ | |
| var currentWeapon:Weapon?; | |
| var currentBlade:Blade?; | |
| var currentExplosive:Explosive?; | |
| func select(weapon:Weapon){ | |
| self.currentWeapon = weapon; | |
| } | |
| func select(blade:Blade){ | |
| self.currentBlade = blade; |
This file contains hidden or 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
| // Entity One: Weapon | |
| protocol Weapon{ | |
| func fire(); // Weapon can be fire | |
| } | |
| // The Context: Player, who can fire a weapon | |
| class Player{ | |
| var currentWeapon:Weapon?; | |
| // Fire: call the `fire` method of the weapon |
OlderNewer