Skip to content

Instantly share code, notes, and snippets.

@yusufsyaifudin
yusufsyaifudin / .gitlab-ci.yml
Last active February 27, 2024 14:01
Docker Compose: Redis, Consul, Mongo, Jaeger with Health check. Sample of gitlab-ci.yml for running Go test (integration test or unit test)
# Inspiration: https://b.agilob.net/test-coverage-in-gitlab-ci-in-a-golang-project
# Navigate to: "Settings" -> "CI/CD" -> "Expand" next to "General pipeline settings"
# 1. Add ^coverage:\s(\d+(?:\.\d+)?%) tas your regex in "Test coverage parsing"
# 2. Go to "Pipeline status" to get the badges code
# This file is a template, and might need editing before it works on your project.
image: golang:1.13.4-alpine
services:
- docker:stable-dind # only docker daemon, so we need to install docker cli and docker compose in separate script
parameter from request = page and limit
so,
offset = (page - 1) * limit
but you need to check if page <= 0 then page = 1
if limit <= 0 then set it to default minimum limit
@yusufsyaifudin
yusufsyaifudin / docker-compose.yml
Created October 15, 2019 04:33 — forked from everpeace/docker-compose.yml
kafka cluster in docker-compose.
# WARNING: This docker-compose.yml is only for testing purpose.
# Parameters:
# - name: CONFLUENT_PLATFORM_VERSION
# default: 3.0.0
# reference: https://hub.docker.com/u/confluentinc/
# Ports:
# - description: Major ports are exposed to host computer
# - zookeeper: 2181
# kafka1: 9091
# kafka2: 9092
@yusufsyaifudin
yusufsyaifudin / cleanup.sh
Last active May 15, 2019 04:32
Cleaning up docker to reclaim disk space
#!/bin/bash
# based on https://lebkowski.name/docker-volumes/
# remove exited containers:
docker ps --filter status=dead --filter status=exited -aq | xargs -r docker rm -v
docker volume ls -qf dangling=true | xargs -r docker volume rm
# remove unused images:
docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs -r docker rmi
@yusufsyaifudin
yusufsyaifudin / kafka_reader.go
Created August 11, 2018 14:30
Kafka reader using Golang to use it as Worker
package main
import (
"context"
"fmt"
"os"
"os/signal"
"strings"
"syscall"
"time"
@yusufsyaifudin
yusufsyaifudin / kafka_writer_config.go
Created August 11, 2018 14:04
Create connection into Kafka using Golang
package kafka
import (
"time"
"github.com/segmentio/kafka-go"
"github.com/segmentio/kafka-go/snappy"
)
var writer *kafka.Writer
@yusufsyaifudin
yusufsyaifudin / docker-compose-wurstmeister-kafka.yml
Created August 11, 2018 12:33
Docker compose file running kafka in cluster mode
# create topic: /opt/kafka/bin/kafka-topics.sh --create --zookeeper zoo1:2181,zoo2:2181 --topic qmessage --partitions 4 --replication-factor 2
# use official zookeeper image since the wurstmeister/zookeeper image does not currently support zookeeper in replicated mode
# (https://github.com/wurstmeister/kafka-docker/issues/372#issuecomment-409166940)
# for the first run, set the KAFKA_CREATE_TOPICS: 'qmessage:4:2' to create new topic or use the command above.
# For every restart, don't set it, since it will recreate the topic, hence your old data will lost and will make your consumer missing some data.
version: '2'
services:
zoo1:
image: zookeeper:3.4.13
container_name: zoo1
package test.tokenizer.tokenizerId;
import java.util.ArrayList;
import yusufs.nlp.tokenizerid.Tokenizer;;
/**
* Hello world!
*
*/
@yusufsyaifudin
yusufsyaifudin / distinct_char
Created May 1, 2015 15:57
Return set of unique character from given string
String s = "hksaksaggah";//sample string
String temp2="";//string with no duplicates
HashMap<Integer, Character> tc = new HashMap<>();//create a hashmap to store the char's
char [] charArray = s.toCharArray();
for (Character c : charArray)//for each char
{
if (!tc.containsValue(c))//if the char is not already in the hashmap
{
temp2=temp2+c.toString();//add the char to the output string
tc.put(c.hashCode(),c);//and add the char to the hashmap
@yusufsyaifudin
yusufsyaifudin / konverter.pas
Last active August 29, 2015 14:10
just example program that convert celcius to farenheit and vice versa
{* Temperature Converter *}
{* Made by Yusuf Syaifudin *}
{* as request from Muhammad Angga Prasetyo - 2 December 2014 *}
program konverter;
{
Formula to convert celsius to farenheit is:
F = ((9/5)* C) +32
}