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
public class IsAnagram { | |
boolean anagram(String s1, String s2) { | |
if(s1.length() != s2.length()) { | |
return false; | |
} | |
int[] counts = new int[26]; | |
for(int i=0; i<s1.length(); i++) { | |
//'a' - 'a' -> 0, 'b' - 'a' -> 1 .... | |
counts[s1.charAt(i)-'a']++; |
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
# Loop through all EC2 instances and enable termination protection | |
for I in $(aws ec2 describe-instances --query 'Reservations[].Instances[].[InstanceId]' --output text); do aws ec2 modify-instance-attribute --disable-api-termination --instance-id $I; done | |
# Loop through all EC2 instances and disable termination protection | |
for I in $(aws ec2 describe-instances --query 'Reservations[].Instances[].[InstanceId]' --output text); do aws ec2 modify-instance-attribute --no-disable-api-termination --instance-id $I;done |
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 com.hazelcast.config.Config; | |
import com.hazelcast.config.EventJournalConfig; | |
import com.hazelcast.jet.config.JetConfig; | |
import com.hazelcast.jet.pipeline.JournalInitialPosition; | |
import com.hazelcast.jet.pipeline.Pipeline; | |
import com.hazelcast.jet.pipeline.Sinks; | |
import com.hazelcast.jet.pipeline.Sources; | |
import org.junit.After; | |
import org.junit.Assert; | |
import org.junit.Before; |
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
package jet.avro; | |
import com.hazelcast.jet.Traverser; | |
import com.hazelcast.jet.Traversers; | |
import com.hazelcast.jet.core.AbstractProcessor; | |
import com.hazelcast.jet.core.ProcessorMetaSupplier; | |
import com.hazelcast.jet.core.ProcessorSupplier; | |
import com.hazelcast.jet.function.DistributedBiFunction; | |
import com.hazelcast.jet.impl.util.Util; | |
import org.apache.avro.file.DataFileReader; |
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
package jet; | |
import com.hazelcast.ringbuffer.StaleSequenceException; | |
public class RingBuffer<T> { | |
private T[] ringItems; | |
private long tailSequence = -1; |
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
/* | |
* Copyright (c) 2008-2017, Hazelcast, Inc. All Rights Reserved. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
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
/* | |
* Copyright (c) 2008-2017, Hazelcast, Inc. All Rights Reserved. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
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
/* | |
* Copyright (c) 2008-2017, Hazelcast, Inc. All Rights Reserved. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
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
HazelcastInstance instance = Hazelcast.newHazelcastInstance(); | |
IMap<Integer, Integer> map = instance.getMap("map"); | |
IntStream.range(0, 90000).parallel().forEach(i -> map.put(i, i)); | |
PagingPredicate<Integer, Integer> pagingPredicate = new PagingPredicate<>(100); | |
Set<Map.Entry<Integer, Integer>> entrySet = map.entrySet(pagingPredicate); | |
int count = 0; | |
for (Map.Entry<Integer, Integer> entry : entrySet) { | |
assertEquals(count++, entry.getKey()); |
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
/* | |
* Copyright (c) 2008-2016, Hazelcast, Inc. All Rights Reserved. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
NewerOlder