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
/** | |
* A Simple EventBus Plugin for Vue | |
*/ | |
export default { | |
$eventBus: null, | |
install (Vue) { | |
this.$eventBus = new Vue() | |
}, |
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
# Assuming you did not commit the file, or add it to the index, then: | |
git checkout -- filename | |
# Assuming you added it to the index, but did not commit it, then: | |
git reset HEAD filename | |
git checkout -- filename | |
# Assuming you did commit it, then: | |
git checkout origin/master filename |
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
# if you want to pick some commits from <some-branch> to master for example, | |
# switch to master | |
git checkout master | |
# pick the commits you want to apply to master | |
git cherry-pick a52afa1 | |
git cherry-pick 08f39f7 | |
# if there is a conflict, resolve and commit |
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
/.classpath | |
/.project | |
/.settings/ | |
/target/ |
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
String[] array = new String[] { | |
"apple", "banana", "orange", "avocado", "mango" | |
}; | |
String joined = UtilsForCollections.join(array, ", ", 3); | |
System.out.println(joined); |
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
public static <T> String join(T[] array, String separator) { | |
return UtilsForCollections.join(array, separator, 0); | |
} | |
public static <T> String join(T[] array, String separator, int limit) { | |
if (limit > 0 && array.length > limit) { | |
return Arrays.stream(array) | |
.limit(limit) | |
.map(String::valueOf) | |
.collect(Collectors.joining(separator)) + separator + "..."; | |
} |
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
String[] array = new String[] { | |
"apple", "banana", "orange", "avocado", "mango" | |
}; | |
List<String> filtered = UtilsForCollections.filterArray(array, v -> v.startsWith("a")); | |
filtered.forEach(System.out::println); |
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
public static <T> List<T> filterArray(T[] array, Predicate<? super T> predicate) { | |
return Arrays.stream(array) | |
.filter(predicate) | |
.collect(Collectors.toCollection(ArrayList::new)); | |
} | |
public static <T> List<T> filterCollection( | |
Collection<T> collection, Predicate<? super T> predicate) { | |
return collection.stream() | |
.filter(predicate) |
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
public static <T> List<T> toList(Collection<T> collection) { | |
return collection.stream().collect(Collectors.toList()); | |
} | |
public static <T> Set<T> toSet(Collection<T> collection) { | |
return UtilsForCollections.toSet(collection, false); | |
} | |
public static <T> Set<T> toSet(Collection<T> collection, boolean preserveOrder) { | |
if (preserveOrder) { | |
return collection.stream() | |
.collect(Collectors.toCollection(LinkedHashSet::new)); |
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
public static <T> Set<T> toSet(T[] array) { | |
return UtilsForCollections.toSet(array, false); | |
} | |
public static <T> Set<T> toSet(T[] array, boolean preserveOrder) { | |
if (preserveOrder) { | |
return Arrays.stream(array) | |
.collect(Collectors.toCollection(LinkedHashSet::new)); | |
} | |
return Arrays.stream(array).collect(Collectors.toSet()); | |
} |
NewerOlder