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
case class Event(name: String, start: Int, end: Int) | |
def validateName(name: String): Option[String] = | |
if (name.size > 0) Some(name) else None | |
def validateEnd(end: Int): Option[Int] = | |
if (end < 3000) Some(end) else None | |
def validateStart(start: Int, end: Int): Option[Int] = | |
if (start <= end) Some(start) else None |
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
val raw: List<Char> = "aabcccccaaa".map { it } | |
println(raw.toList().fold(listOf<Char>()) { acc, value -> | |
if (acc.isEmpty()) listOf(value) | |
else {//a2, b | |
if (acc.last() == value) acc | |
else acc + value | |
} | |
}) |
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
helm ls #list releases | |
helm test #run tests | |
#installs a release from a remote repo or local folder, in <namespace> and with extra configuration values values.yaml | |
#helm install <release> <chart_name|local folder> -n <namespace> -f <file_location> | |
helm install elasticsearch elastic/elasticsearch -n elasticsearch-poc -f ./values.yaml | |
helm install nginx nginx # the first nginx is the name of the release, the second one is the name of the folder | |
helm delete <release> #delete a release. | |
helm delete elasticsearch | |
#renders charts templates locally | |
helm template <release> <chart> [flags] |
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
POST /tmdb/_close | |
POST /tmdb/_open | |
PUT /tmdb/_settings | |
{ | |
"analysis": { | |
"filter": { | |
"my_shingle": { | |
"type": "shingle", | |
"min_shingle_size": 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
query = { | |
'query': { | |
'bool': { | |
'should': [ | |
{'match_phrase': { | |
'title_exact_match': { | |
'query': SENTINEL_BEGIN + ' ' + usersSearch + ' ' + SENTINEL_END, | |
'boost': 1000, | |
} | |
}}, |
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
ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); #B MapType mapType = | |
mapper.getTypeFactory().constructMapType(HashMap.class, String.class, Object.class); | |
MapType yamlConfigType = mapper .getTypeFactory() .constructMapType( HashMap.class, mapper.getTypeFactory().constructType(String.class), mapType); | |
Path configFilePath; | |
Map<String, Map<String, Object>> config = mapper.readValue(configFilePath.toFile(), yamlConfigType); | |
AuthStrategy authStrategy = null; | |
Map<String, Object> authConfig = config.get("auth") | |
if (authConfig.get("strategy").equals(USERNAME_PASSWORD_STRATEGY)) { | |
authStrategy = new UsernamePasswordAuthStrategy( (String) authConfig.get("username"), (String) authConfig.get("password")); |
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
function UpdateChatRoom(req: UpdateChatRoomRequest): ChatRoom { | |
if (req.requestId === undefined) { // #A | |
return ChatRoom.update(...); | |
} | |
const hash = crypto.createHash('sha256').update(JSON.stringify(req)).digest('hex'); | |
const cachedResponse = cache.get(req.requestId); | |
if (!cachedResult) { // #B | |
const response = ChatRoom.update(...); | |
cache.set(req.requestId, { response, hash }); // #C | |
return response; |
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
async function getChatRoomWithRetries(id: string, maxDelayMs = 32, maxRetries = 10): Promise<ChatRoom> { | |
return new Promise<ChatRoom>(async (resolve, reject) => { | |
let retryCount = 0; | |
let delayMs = 1000; | |
while (true) { | |
try { | |
return resolve(GetChatRoom({ id })); | |
} catch (e) { | |
if (retryCount++ > maxRetries) return reject(e); | |
await new Promise((resolve) => { |
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
import cdk = require('@aws-cdk/cdk'); | |
import ec2 = require('@aws-cdk/aws-ec2'); | |
import elastic = require('@aws-cdk/aws-elasticache'); | |
import rds = require ('@aws-cdk/aws-rds'); | |
import es = require("@aws-cdk/aws-elasticsearch"); | |
import ecs = require('@aws-cdk/aws-ecs'); | |
import s3 = require("@aws-cdk/aws-s3"); | |
import elbv2 = require('@aws-cdk/aws-elasticloadbalancingv2'); | |
import route53 = require('@aws-cdk/aws-route53'); | |
import certificateManager = require("@aws-cdk/aws-certificatemanager"); |
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
{ | |
"files.exclude": { | |
// Hide the node_modules folder | |
"node_modules/": true, | |
// Hide all files that end in .d.ts | |
"**/*.d.ts": true, | |
// Hide all files that end with .js if they have a .ts file | |
"**/*.js": { | |
"when": "$(basename).ts" | |
}, |
NewerOlder