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
int[] example = new int[] {1, 2, 3}; | |
Arrays.stream(example) | |
.boxed() | |
.collect(Collectors.toList()); |
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
# Edit and add fan threshold | |
sudo vim /etc/udev/rules.d/70-snap.snapd.rules | |
# Update and reload | |
sudo udevadm control --reload-rules && udevadm trigger | |
#Reboot | |
sudo reboot | |
# Install sensors |
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
// You can use an initializer in an anonymous subclass to make the syntax a little bit shorter: | |
Map<String, String> myMap = new HashMap<String, String>() {{ | |
put("a", "b"); | |
put("c", "d"); | |
}}; | |
// In plain java 8 you also have the possibility of using Streams/Collectors to do the job. | |
Map<String, String> myMap = Stream.of( | |
new SimpleEntry<>("key1", "value1"), |
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
# backup linux image | |
# DSK='disk4' # manual set disk | |
OUTDIR=./$1/snapshots/ | |
mkdir -p OUTDIR | |
# Find disk with Linux partition | |
## Note: This also works with Raspbian | |
export DSK=`diskutil list | awk '/Linux/ {print $5}' | cut -c 1-5 | uniq` | |
if [ $DSK ]; then | |
echo $DSK | |
echo $OUTDIR |
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
#!/bin/bash | |
# restore backup | |
DSK='disk3' | |
# Image name (no ext) | |
IMG='latest' | |
# Check for sensible disk | |
export PTYPE=$(diskutil list /dev/$DSK | awk '/GUID_partition_scheme/ {print $2}; /Apple/ {print $2}; /Windows_NTFS/ {print $2}' ) |
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
<<'###BLOCK-COMMENT' | |
line 1 | |
line 2 | |
line 3 | |
line 4 | |
###BLOCK-COMMENT |
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
/** | |
* ShallowCopy | |
*/ | |
int[] a = new int[] {1,2,3}; | |
int[] b = new int[a.length]; | |
b = Arrays.copyOf(a, a.length); | |
/** | |
* DeepCopy | |
*/ |
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
char[] result = {'a','b','c'}; | |
String output = Stream.of(result) | |
.map(String::valueOf) | |
.collect(Collectors.joining()) |
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
30 6 * * * cd ~/devo/message && ./script.sh |
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 Solution { | |
public List<Integer> findAnagrams(String s, String p) { | |
List<Integer> result = new ArrayList<>(); | |
if (s == null || s.length() == 0) { | |
return result; | |
} | |
if (p == null || p.length() > s.length()) { | |
return result; | |
} | |
int[] s_freq = new int[26]; |
OlderNewer