Skip to content

Instantly share code, notes, and snippets.

View odrianoaliveira's full-sized avatar

Adriano de Oliveira odrianoaliveira

View GitHub Profile
package org.example
import kotlin.math.max
fun main() {
val string = "abcaabgfhdbchfythgjgtuitijgjghjfhhdnnslphopoootkjjajhaabxvcgftyyihkjonpm"
val result = findLongestSubstring(string)
println("result: $result")
println("asserted: ${(result == 9)}")
package org.example
data class ListNode(var value: Int, var next: ListNode? = null)
// [val, next] -> [val, next] -> null
fun main() {
val head = buildLinkedList()
printListNodes(head)
@odrianoaliveira
odrianoaliveira / TwoSum.kt
Created February 27, 2026 16:32
Two Sum kotlin solution
// input..: [1,6,10]
// target.: 16
// output.: [1,2]
fun main() {
val array = arrayOf(1, 6, 10)
val target = 16
val result = twoInt(array, target)
assert(result == Pair(1,2))
@odrianoaliveira
odrianoaliveira / giscompletion.amazon.com.MD
Last active May 15, 2025 13:50
How-to use the completion.amazon.com API
  • URL: https://completion.amazon.com/api/2017/
  • Resource: suggestions
  • Paramters:
    • session-id: 133-2190809-5709766
    • customer-id: A1CNYR04B8CZOZ
    • request-id: NTH41W0H5GYC8N00NVCS
    • page-type: Gateway
    • lop=en_US
    • site-variant=desktop
  • client-info=amazon-search-ui
version: "2.1"
services:
rabbit1:
image: "rabbitmq:3-management-alpine"
mem_limit: 2g
memswap_limit: 2g
mem_swappiness: 0
restart: unless-stopped
ports:
- "15672:15672"
@odrianoaliveira
odrianoaliveira / application.yml
Created May 30, 2018 14:15
Spring Boot - Configuring sleuth with others binders
# Spring
spring:
cloud:
stream:
default:
contentType: application/json
bindings:
input:
destination: pollerIn-process
group: group
// create the file:
sudo vim /usr/share/applications/intellij.desktop
// add the following entry
[Desktop Entry]
Version=2018.1.1
Type=Application
Terminal=false
Icon[en_US]=/opt/idea/idea-IC-181.4203.550/bin/idea.png
Name[en_US]=IntelliJ
@odrianoaliveira
odrianoaliveira / HA-redis-master-slave-sentinel.yml
Last active April 20, 2018 18:49
High Available Redis master/slave nodes with sentinel
version: '2.1'
services:
master:
image: redis:3.2-alpine
command: ["redis-server","/usr/local/etc/redis/redis.conf"]
sysctls:
net.core.somaxconn: '1024'
mem_limit: 8g
memswap_limit: 8g
@odrianoaliveira
odrianoaliveira / scripted_field.painless
Created April 12, 2018 14:01
kibana scripted field
if (!doc['request.keyword'].empty) {
def m = /\/api\/(.*[-\/]v[0-9])\/.*/.matcher(doc['request.keyword'].value);
if (m.matches()) {
return m.group(1)
}
}
return ""
class Solution {
public int[] twoSum(int[] nums, int target) {
int n = nums.length;
int [][] arr = new int[n][2];
for (int i=0; i < n; i++) {
arr[i][0] = nums[i];
arr[i][1] = i;
}