Skip to content

Instantly share code, notes, and snippets.

Batuhan Bayrakci baybatu

View GitHub Profile
@baybatu
baybatu / maven-war-exclude-directory.md
Last active Jun 30, 2020
Excluding Directory From War Package In maven-war-plugin
View maven-war-exclude-directory.md

packagingExcludes configuration tag can be used to exclude certain files or directories from the war file. It is important to put '/' character at the end of the directory to be excluded. If there is no such '/' character, then the entry is interpreted as a regular file.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.3</version>
    <configuration>
@baybatu
baybatu / limit-number.py
Created Jun 26, 2016
Limiting input number between minimum and maximum values range in Python
View limit-number.py
def limit(num, minimum=1, maximum=255):
"""Limits input 'num' between minimum and maximum values.
Default minimum value is 1 and maximum value is 255."""
return max(min(num, maximum), minimum)
@baybatu
baybatu / attach-listener-to-push-method.js
Last active Jun 12, 2020
Attach event listener to Array push method call
View attach-listener-to-push-method.js
var eventify = function(arr, callback) {
arr.push = function(e) {
Array.prototype.push.call(arr, e);
callback(arr);
};
};
var array = [1,2,3];
eventify(array, function(newArray) {
@baybatu
baybatu / next-execution-date-for-spring-cron-expressions.md
Last active Jun 10, 2020
Get next execution date for Spring cron expressions
View next-execution-date-for-spring-cron-expressions.md

I usually use Groovy Console to run code below to get next execution date for Spring cron expressions.

new org.springframework.scheduling.support.CronSequenceGenerator("0 0/5 * * * *").next(new Date())
@baybatu
baybatu / rabbitmq-delay-message-consume.md
Last active Jun 9, 2020
RabbitMQ: mesajı geciktirerek tüketmek
View rabbitmq-delay-message-consume.md

RabbitMQ: Mesajı Geciktirerek Tüketmek

  • delay-exchange: Geciktirilecek mesajın bırakıldığı exchange.
  • delay-queue: delay-exchange'e bağlı. Herhangi bir tüketicisi olmamalı.
  • ana-exchange: Geciktirilmeden tüketilmek istenen mesajların bırakılabileceği exchange.
  • ana-queue: ana-exchange'e bağlı kuyruk. Tüketicisi var.

delay-queue şu parametrelerle oluşturulur:

  • x-dead-letter-exchange: -- boş
  • x-message-ttl: 3000 -- mesajın bekletileceği milisaniye
@baybatu
baybatu / get-domain-mapping-in-grails.groovy
Last active May 24, 2020
Getting mapping from domain class in Grails
View get-domain-mapping-in-grails.groovy
class Person {
Long id
String name
static mapping = {
table name: 'PERSON'
id column: 'PRS_ID'
name column: 'PRS_NAME'
}
}
@baybatu
baybatu / prevent-form-submit-clarity.md
Created Apr 10, 2020
Prevent clicking button automatically when press 'Enter' in Clarity
View prevent-form-submit-clarity.md
@baybatu
baybatu / README.md
Created Mar 5, 2020 — forked from Bonno/README.md
Opening multiple SSH sessions with iTerm automatically. To be used in an Automator flow.
View README.md

Create a new Automater flow

Add 'Service'. Service receives 'no input' in 'iTerm'. Add 'Run AppleScript'.

@baybatu
baybatu / spark-session-for-local-with-hive.java
Created Feb 25, 2020
Create spark session using hive metastore on local
View spark-session-for-local-with-hive.java
SparkSession spark = SparkSession
.builder()
.appName("com.baybatu.sparkApp")
.master("local[*]")
.enableHiveSupport()
.config("dfs.nameservices", "nameService01")
.config("hive.metastore.uris", "thrift://10.20.30.40:8093")
.getOrCreate();
@baybatu
baybatu / string-to-number.js
Last active Feb 20, 2020
Converting string to number in Javascript (ES5)
View string-to-number.js
function toNumber(value) {
var convertedNumber = +value;
if (convertedNumber) {
return convertedNumber;
}
throw Error("Conversion error for value:" + value);
}
You can’t perform that action at this time.