Skip to content

Instantly share code, notes, and snippets.

Batuhan Bayrakci baybatu

Block or report user

Report or block baybatu

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@baybatu
baybatu / java-ontanimli-kuralla-siralama.md
Created Dec 9, 2019
Java'da öntanımlı bir listeye göre sıralama yapmak
View java-ontanimli-kuralla-siralama.md
List<String> kurallar = Arrays.asList("ahmet", "veli", "mehmet");
List<String> sonuc = Arrays.asList("veli", "mehmet", "ahmet").stream()
  .sorted(Comparator.comparing(isim -> kurallar.indexOf(isim)))
  .collect(Collectors.toList());
assertThat(sonuc).isEqualTo(Arrays.asList("ahmet", "veli", "mehmet"));

Kaynak: https://stackoverflow.com/a/5245214

@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 / twitterserver-admin-port.md
Last active Aug 29, 2019
Specifying admin port on TwitterServer
View twitterserver-admin-port.md

Pass following as program an argument

java -jar app.jar -admin.port=:9999
@baybatu
baybatu / get-domain-mapping-in-grails.groovy
Last active Jul 31, 2019
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 / run-kibana.sh
Last active Jun 12, 2019
Run Kibana for parameterized Elasticsearch. Kudos @mesut
View run-kibana.sh
#!/bin/bash
# USAGE: run-kibana.sh http://localhost:9200
echo "Running kibana for es host:$1"
docker run --name kibana -d -p 5601:5601 \
-e ELASTICSEARCH_HOSTS=$1 \
-e XPACK_GRAPH_ENABLED=false \
-e XPACK_ML_ENABLED=false \
@baybatu
baybatu / create-rabbitmq-exchange-queue-using-rest-api.sh
Created Apr 2, 2019
Create RabbitMQ queue and exchange with binding using REST API
View create-rabbitmq-exchange-queue-using-rest-api.sh
# create exchange
curl -i -u guest:guest -H "content-type:application/json" \
-XPUT -d'{"type":"fanout","durable":true}' \
http://localhost:15672/api/exchanges/%2f/my.exchange.name
# create queue
curl -i -u guest:guest -H "content-type:application/json" \
-XPUT -d'{"durable":true,"arguments":{"x-dead-letter-exchange":"", "x-dead-letter-routing-key": "my.queue.dead-letter"}}' \
http://localhost:15672/api/queues/%2f/my.queue
@baybatu
baybatu / split-into-subarrays.js
Last active Mar 30, 2019
Splitting array into list of subarrays in javascript
View split-into-subarrays.js
/*
* Splits array into subarrays.
* count parameter indicates that how many item per subarray contains.
* Example usage: splitIntoSubArray([1,2,3,4,5], 2) -> [[1, 2], [3, 4], [5]]
*/
function splitIntoSubArray(arr, count) {
var newArray = [];
while (arr.length > 0) {
newArray.push(arr.splice(0, count));
}
@baybatu
baybatu / SpringCouchbaseIdGeneration.java
Created Mar 23, 2019
spring-data-couchbase ile otomatik document ID üretimi
View SpringCouchbaseIdGeneration.java
@Document
public class OrnekDokuman {
@Id
@GeneratedValue(strategy = GenerationStrategy.UNIQUE) // UUID
String id;
}
@baybatu
baybatu / attach-listener-to-push-method.js
Last active Mar 17, 2019
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) {
You can’t perform that action at this time.