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
def printChar(i: Int) = print(i.toChar) | |
def decipherChar(c: Char, n: Int) = c match { | |
case x if x < 97 || x > 122 => printChar(x) | |
case x if x - n < 97 => printChar(122 - (97 - (x -n)) + 1) | |
case _ => printChar(c - n) | |
} | |
def decipher(str: String, n: Int) = str.toLowerCase.toArray.foreach(decipherChar(_, n)) |
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 random | |
import sys | |
if (len(sys.argv) > 1): | |
list = open(sys.argv[1]).readlines() | |
random.shuffle(list) | |
for team in list: | |
print team.strip() | |
else: | |
print("You need to specify the file name.") |
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
function Typedef(bytes) { | |
this.bytes = bytes; | |
}; | |
Typedef.prototype.getData = function(data, start){ | |
var values = data.slice(start, start + this.bytes); | |
var c = 0; | |
for(i = 0; i < values.length; i++) { | |
var offset = this.bytes - (i + 1); | |
c += values[i] * Math.pow(2, offset); |
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
private boolean getLock(String aliasName) | |
{ | |
synchronized (aliasName) | |
{ | |
IndexRequestBuilder indexRequest = elasticClient.prepareIndex(LOCK_DIRECTORY, LOCK_TYPE, aliasName).setSource("{}").setOpType(OpType.CREATE); | |
boolean successful = false; | |
try | |
{ | |
IndexResponse response = indexRequest.get(); |
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
private int findCurrentIndex(String aliasName, int indexCount) | |
{ | |
Map<String, AliasOrIndex> allAliases = elasticClient | |
.admin() | |
.cluster() | |
.state(Requests.clusterStateRequest()) | |
.actionGet() | |
.getState() | |
.getMetaData() | |
.getAliasAndIndexLookup(); |
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
// Delete it, if it already exists | |
if(elasticClient.admin().indices().exists(new IndicesExistsRequest(indexName)).actionGet().isExists()) | |
{ | |
elasticClient.admin().indices().delete(new DeleteIndexRequest(indexName)); | |
} |
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
// Create the index | |
Settings.Builder settingsBuilder = Settings.builder(); | |
for(Map.Entry<String, Integer> setting : config.getIndexSettings().entrySet()) | |
{ | |
settingsBuilder.put(setting.getKey(), setting.getValue()); | |
} | |
elasticClient.admin().indices().create(new CreateIndexRequest(indexName, settingsBuilder.build())); |
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
String mapping = getMapFile(aliasName); | |
if(mapping != null) | |
{ | |
elasticClient.admin().indices().putMapping(new PutMappingRequest(indexName).source(getMapFile(aliasName))); | |
} | |
... | |
private String getMapFile(String aliasName) |
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
// Do the indexing | |
T res = job.rebuildIndex(indexName); | |
.... | |
public interface IndexRebuildJob<T> | |
{ | |
public T rebuildIndex(String indexName); | |
} |
OlderNewer