Skip to content

Instantly share code, notes, and snippets.

View tasdemirbahadir's full-sized avatar
🎯
Focusing

Bahadir Tasdemir tasdemirbahadir

🎯
Focusing
View GitHub Profile
@tasdemirbahadir
tasdemirbahadir / cncm-init-config-repo.sh
Created January 14, 2020 12:54
cncm-init-config-repo.sh
$> git init
$> echo 'user.role=Developer' > config-client-development.properties
$> echo 'user.role=User' > config-client-production.properties
$> git add .
$> git commit -m 'Initial config-client properties'
@tasdemirbahadir
tasdemirbahadir / cncm-spring-cloud-config-server-code.xml
Created January 14, 2020 12:52
cncm-spring-cloud-config-server-code.xml
@SpringBootApplication
@EnableConfigServer
public class ConfigServer {
public static void main(String[] arguments) {
SpringApplication.run(ConfigServer.class, arguments);
}
}
@tasdemirbahadir
tasdemirbahadir / cncm-spring-cloud-config-server-client.xml
Last active January 14, 2020 14:47
cncm-spring-cloud-config-server-client.xml
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
<version>2.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.2.2.RELEASE</version>
</dependency>
@tasdemirbahadir
tasdemirbahadir / cncm-spring-cloud-config-server.xml
Last active January 14, 2020 12:46
cncm-spring-cloud-config-server
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
<version>2.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<version>2.2.2.RELEASE</version>
</dependency>
@tasdemirbahadir
tasdemirbahadir / scheduler_service_define_future_task.sql
Created December 2, 2019 16:21
scheduler_service_define_future_task.sql
INSERT INTO future_jobs (ID,task_id,hash_key,start_time,expire_time,name,future_job_status,application,path,method,payload,created_date,last_modified_date,url)
VALUES (nextval('seq_future_jobs'),'sample-future-job','sample-future-job-hash-key',NOW() + INTERVAL '5 minutes',NOW() + INTERVAL '10 minutes','Sample Future Job','WAITING','test-application','/future-job/invoke','GET','',now(),now(),'http://localhost:6060');
@tasdemirbahadir
tasdemirbahadir / scheduler_service_define_job.sql
Created December 2, 2019 16:19
scheduler_service_define_job.sql
INSERT INTO scheduled_jobs (ID,NAME,application,job_type,cron_expression,created_date,last_modified_date,active,url)
VALUES (nextval('seq_scheduled_jobs'),'Sample bean scheduled job','test-application','bean_scheduled_job','0 0/5 * * * ?',now(),now(),TRUE,'http://localhost:6060');
INSERT INTO bean_scheduled_jobs VALUES (currval('seq_scheduled_jobs'),'sampleJobService','invoke');
@tasdemirbahadir
tasdemirbahadir / scheduler_service_init_jobs.java
Created December 2, 2019 16:17
scheduler_service_init_jobs.java
@PostConstruct
public void initialize() {
repository.findAllByActive(true).forEach(eachJob -> {
taskScheduler.schedule(() -> service.execute(eachJob), new CronTrigger(eachJob.getCronExpression()));
});
}
@tasdemirbahadir
tasdemirbahadir / DateTimeZoneConvertionUtils.java
Created April 3, 2019 08:04
Convert java.util.Date time zone between UTC and Turkish time zones.
private static final ZoneId TURKEY_ZONE_ID = ZoneId.of("Turkey");
private static final ZoneId UTC_ZONE_ID = ZoneId.of("UTC");
public static Date convertTurkeyToUTC(Date date) {
return Date.from(date.toInstant().atZone(UTC_ZONE_ID).toLocalDateTime().atZone(TURKEY_ZONE_ID).toInstant());
}
public static Date convertUTCToTurkey(Date date) {
return Date.from(date.toInstant().atZone(TURKEY_ZONE_ID).toLocalDateTime().atZone(UTC_ZONE_ID).toInstant());
}
@tasdemirbahadir
tasdemirbahadir / LyricsFor99BottlesOfBeer.kt
Last active October 9, 2018 13:40
My 99 Bottles of Beer Lyrics in Kotlin PL. Aided with the source: http://bit.ly/2Nvjh9f
fun main(args: Array<String>) {
printSongLyrics(99)
}
fun printSongLyrics(bottlesSize: Int) {
if (bottlesSize < 0) {
println("Do not enter negative values!")
return
}
@tasdemirbahadir
tasdemirbahadir / Java8ListToMapWithDuplicateKeys
Created July 5, 2018 06:18
Java8 -> Convert list to a map where list contains duplicate keys
aList.stream()
.collect(Collectors.groupingBy(AnObject::getKeyField, toDescSortedList()))
.values()
.stream()
.map(list -> list.get(0))
.collect(Collectors.toMap(AnObject::getKeyField, AnObject::getValueField));
private static <AnObject> Collector<AnObject,?,List<AnObject>> toDescSortedList() {
return Collectors.collectingAndThen(
Collectors.toCollection(ArrayList::new), list -> {