Skip to content

Instantly share code, notes, and snippets.

View bobaikato's full-sized avatar
🕷️
building SpydarAI

Bobai Kato bobaikato

🕷️
building SpydarAI
View GitHub Profile
@bobaikato
bobaikato / ExtractHashtags.java
Created May 11, 2022 17:19
Extract HashTags from Text
public static @NotNull List<String> extractHashtags(final @NotNull String text) {
final var hashTags = new ArrayList<String>();
Arrays.stream(text.split("\\s"))
.filter(word -> word.startsWith(HASH))
.distinct()
.parallel()
.forEachOrdered(
word -> {
if (word.matches("[#A-Za-z0-9]+") && word.length() > 1) {
@bobaikato
bobaikato / PrototypeScope.java
Created April 4, 2022 18:28
Prototype Scope Example
@Bean
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public PrototypeServiceBean prototypeServiceBean(){
return new PrototypeServiceBean();
}
@bobaikato
bobaikato / ConcurrentSetPoc.java
Created December 15, 2021 22:28
Concurrent Set Proof of concept.
public class ConcurrentSetPoc {
private String url;
public static void main(String[] args) throws Exception {
final Set<Object> myConcurrentSet = ConcurrentHashMap.newKeySet();
CompletableFuture.runAsync(
() -> {
@bobaikato
bobaikato / SseEmitterWebConfig.java
Created December 9, 2021 18:37
SsEmitter Connection stay alive config
@Configuration
public class SseEmitterWebConfig implements WebMvcConfigurer {
@Override
public void configureAsyncSupport(AsyncSupportConfigurer configurer) {
// This timeout determines how long the connection is alive for. Use appropriately.
configurer.setDefaultTimeout(Long.MAX_VALUE);
}
}
@bobaikato
bobaikato / emojis.json
Created October 14, 2021 21:19 — forked from oliveratgithub/emojis.json
Emoji-list with emojis, names, shortcodes, unicode and html entities [massive list]
{
"emojis": [
{"emoji": "👩‍👩‍👧‍👧", "name": "family: woman, woman, girl, girl", "shortname": ":woman_woman_girl_girl:", "unicode": "1F469 200D 1F469 200D 1F467 200D 1F467", "html": "&#128105;&zwj;&#128105;&zwj;&#128103;&zwj;&#128103;", "category": "People & Body (family)", "order": ""},
{"emoji": "👩‍👩‍👧‍👦", "name": "family: woman, woman, girl, boy", "shortname": ":woman_woman_girl_boy:", "unicode": "1F469 200D 1F469 200D 1F467 200D 1F466", "html": "&#128105;&zwj;&#128105;&zwj;&#128103;&zwj;&#128102;", "category": "People & Body (family)", "order": ""},
{"emoji": "👩‍👩‍👦‍👦", "name": "family: woman, woman, boy, boy", "shortname": ":woman_woman_boy_boy:", "unicode": "1F469 200D 1F469 200D 1F466 200D 1F466", "html": "&#128105;&zwj;&#128105;&zwj;&#128102;&zwj;&#128102;", "category": "People & Body (family)", "order": ""},
{"emoji": "👨‍👩‍👧‍👧", "name": "family: man, woman, girl, girl", "shortname": ":man_woman_girl_girl:", "unicode": "1F468 200D 1F469 200D 1F467 200D 1F467", "html": "&#128104;&zwj;&#128105;&z
@bobaikato
bobaikato / docker-compose.yml
Last active December 31, 2023 16:06
ArangoDB Cluster — Stateful. One "default" is having 3 servers, each running one agent/coordinator/dbserver each. That's good for many situations. In general however, it's not true that you should have the same amount each. For example, you need an odd number of agents, usually 3. If you have 2n+1 agents, n may fail without interrupting service …
version: "3.7"
services:
#ARANGO Agencies Start
#Arango Agency 1 start
arangodb-agency1:
image: arangodb/arangodb
environment:
- ARANGO_RANDOM_ROOT_PASSWORD=1
@bobaikato
bobaikato / docker-compose.yml
Created August 13, 2021 19:11 — forked from neunhoef/docker-compose.yml
Docker compose file to start a local arangodb cluster
version: '2'
services:
agency:
image: arangodb/arangodb
environment:
- ARANGO_NO_AUTH=1
command: arangod --server.endpoint tcp://0.0.0.0:5001 --server.authentication false --agency.activate true --agency.size 1 --agency.supervision true --database.directory /var/lib/arangodb3/agency1
coordinator:
image: arangodb/arangodb
@bobaikato
bobaikato / gist:90c4c278996f98fdc0618bff1e0a9c89
Created November 30, 2020 12:44 — forked from psayre23/gist:c30a821239f4818b0709
Runtime Complexity of Java Collections
Below are the Big O performance of common functions of different Java Collections.
List | Add | Remove | Get | Contains | Next | Data Structure
---------------------|------|--------|------|----------|------|---------------
ArrayList | O(1) | O(n) | O(1) | O(n) | O(1) | Array
LinkedList | O(1) | O(1) | O(n) | O(n) | O(1) | Linked List
CopyOnWriteArrayList | O(n) | O(n) | O(1) | O(n) | O(1) | Array
@bobaikato
bobaikato / docker-compose.yml
Last active March 9, 2021 16:40
Core service. ELK, Kafka, kafdrop, Redis, Postrgesql, PgAdmin
---
version: '3.8'
services:
elk:
image: sebp/elk
ports:
- "5601:5601" #Kibana web interface
- "9200:9200" #Elasticsearch JSON interface
- "5044:5044" #Logstash Beats interface
@bobaikato
bobaikato / detectLoopInLinkedList.java
Created September 10, 2020 14:14
Detect Loop in LinkedList
boolean detectLoop(final Node head) {
Node slowNode = head;
Node fastNode = head;
while (slowNode != null && slowNode.next != null && fastNode.next.next != null) {
fastNode = fastNode.next.next;
slowNode = slowNode.next;
if (fastNode == head || slowNode == head) {
return true;