Operation | Input | Result | Notes |
---|---|---|---|
map | F[A] , A => B |
F[B] |
Functor |
apply | F[A] , F[A => B] |
F[B] |
Applicative |
(fa, fb, ...).mapN | (F[A], F[B], ...) , (A, B, ...) => C |
F[C] |
Applicative |
(fa, fb, ...).tupled | (F[A], F[B], ...) |
F[(A, B, ...)] |
Applicative |
flatMap | F[A] , A => F[B] |
F[B] |
Monad |
traverse | F[A] , A => G[B] |
G[F[A]] |
Traversable; fa.traverse(f) == fa.map(f).sequence ; "foreach with effects" |
sequence | F[G[A]] |
G[F[A]] |
Same as fga.traverse(identity) |
. | . | . | . |
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
package kata.string; | |
import java.util.Map; | |
import java.util.HashMap; | |
public class Anagram { | |
private static Map<Character, Integer> toMap(String str) { | |
Map<Character, Integer> map = new HashMap<>(); |
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
package kata.linkedlist; | |
public class ReverseKNodeLinkedList { | |
public static Node reverseKNodes(Node node, int k) { | |
if (node == null || node.getNext() == null) { | |
return node; | |
} |
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
package kata; | |
public class LPS { | |
public static int lps(char[] ch, int i, int j) { | |
// Base Case 1: If there is only 1 character | |
if (i == j) { | |
return 1; | |
} |
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
Welcome to the Ammonite Repl 0.8.0 | |
(Scala 2.11.8 Java 1.8.0_91) | |
@ import scala.util.Try | |
import scala.util.Try | |
@ val listOfTries: List[Try[String]] = List(Try("a"), Try("b"), Try("c")) | |
listOfTries: List[Try[String]] = List(Success("a"), Success("b"), Success("c")) | |
// I have a List[Try[String]] but I actually want a Try[List[String]]. |
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
* Install XAMPP on MAC: | |
* `brew cask install xampp` | |
* Stat/Stop Apache: | |
* sudo /Applications/XAMPP/xamppfiles/bin/apachectl start | |
* |
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
* Install XAMPP on MAC: | |
* `brew cask install xampp` | |
* Stat/Stop Apache: | |
* sudo /Applications/XAMPP/xamppfiles/bin/apachectl start | |
* |
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
Query AWS regions for active EC2 instances: | |
aws ec2 describe-instances --region us-east-1 | |
# read from s3 triggered events | |
def s3_file_name(event): | |
records = [x for x in event.get('Records', []) if x.get('eventName') == 'ObjectCreated:Put'] | |
sorted_events = sorted(records, key=lambda e: e.get('eventTime')) | |
latest_event = sorted_events[-1] if sorted_events else {} | |
info = latest_event.get('s3', {}) | |
file_key = info.get('object', {}).get('key') |
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
# There are 3 levels of git config: global, project, and system. | |
# global: Global configs are available for all projects for the current user and stored in ~/.gitconfig. | |
# project: Project configs are only available for the current project and stored in .git/config in the project's directory. | |
# system: System configs are available for all the users/projects and stored in /etc/gitconfig. | |
# Create a global config | |
$ git config --global user.name "John Doe" | |
# Create a project specific config, you have to execute this under the project's directory. |
- Siri, Write the Next Method
- Code Prediction by Feeding Trees to Transformers
- Towards Automating Code Review Activities
- Traceability Transformed: Generating more Accurate Links with Pre-Trained BERT Models
- Studying the Usage of Text-To-Text Transfer Transformer to Support Code-Related Tasks
- A Context-based Automated Approach for Method Name Consistency Checking and Suggestion
- [GUIGAN: Learning to Generate GUI Designs Using Generative Adversarial Networks](https://www.co