Skip to content

Instantly share code, notes, and snippets.

View yusufcakal's full-sized avatar
:octocat:
Leave your code better than you found it

Yusuf Çakal yusufcakal

:octocat:
Leave your code better than you found it
View GitHub Profile
@eroberer
eroberer / dinamikMaske.m
Created November 21, 2017 21:36
Görüntü İşleme - Dinamik Maske ile kontrast azaltma
clear;
im = imread('kim.jpg');
ig = rgb2gray(im);
[w, h] = size(ig);
in = ig;
% dinamik gelecek olan maske
mask = [1 1 1 ; 1 2 1 ; 1 1 1];
c = size(mask);
@ufuk
ufuk / postgresql-export-tables-to-s3-as-csv-file.sh
Last active July 10, 2023 04:04
BASH script to export some tables from the PostgreSQL database to S3 as CSV files.
#!/bin/bash
export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...
export AWS_DEFAULT_REGION=...
PG_HOST=...
PG_USER=...
PG_PASS='...'
PG_DB=...
@ufuk
ufuk / bash-echo-time-by-timezone.sh
Created January 31, 2019 13:55
Echo time by timezone in BASH
echo "$(TZ='Europe/Moscow' date +%Y-%m-%d\ %H\:%M)"
# output => 2019-01-31 16:52
@ufuk
ufuk / import-csv-file-from-s3-into-aws-redshift.sql
Created January 31, 2019 14:01
Import CSV file from S3 into AWS Redshift
-- Before importing, you need to create table
CREATE TABLE example_table
(
...
);
-- Importing...
COPY example_table
FROM 's3://<BUCKET_NAME>/.../example_table.csv'
CREDENTIALS 'aws_access_key_id=...;aws_secret_access_key=...'
@EliasRanz
EliasRanz / MongoConfig.java
Last active June 12, 2024 19:48
Mongo Configuration for Amazon DocumentDB utilizing Spring-Boot and spring-data-mongodb
import com.mongodb.MongoClient;
import com.mongodb.MongoClientOptions;
import com.mongodb.MongoCredential;
import com.mongodb.ServerAddress;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.data.mongodb.config.AbstractMongoConfiguration;
@ufuk
ufuk / BaseMockito2JUnit4Test.java
Last active October 24, 2021 17:52
Performs "verify no more interactions" check automatically for all mock objects (works with Mockito version 2 or higher & JUnit version 4 and 5). For detailed description: https://ufukuzun.wordpress.com/2019/04/09/ne-olup-bittiginden-habersiz-testlere-derman-mockscollector/ (Turkish)
import org.apache.commons.lang3.ArrayUtils;
import org.junit.After;
import org.junit.runner.RunWith;
import org.mockito.InOrder;
import org.mockito.junit.MockitoJUnitRunner;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.verifyNoMoreInteractions;
@RunWith(MockitoJUnitRunner.class)
@ufuk
ufuk / HttpServletRequestResponsePrinter.java
Created September 5, 2019 06:54
Utility to generate logging-purpose text for HttpServletRequest/Response
package ...;
import ...JsonUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.springframework.http.HttpHeaders;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.util.ContentCachingRequestWrapper;
import org.springframework.web.util.WebUtils;
@ufuk
ufuk / SpringDataPageUtils.java
Last active February 8, 2021 13:04
SpringDataPageUtils to convert paged entities to paged model objects
import org.springframework.data.domain.Page;
import org.springframework.data.support.PageableExecutionUtils;
import java.util.function.Function;
import java.util.stream.Collectors;
public final class SpringDataPageUtils {
public static <T, C> Page<C> convertPage(Page<T> page, Function<T, C> converter) {
return PageableExecutionUtils.getPage(
@ufuk
ufuk / ExampleConstraint.java
Last active March 20, 2024 13:47
How to initialize an instance of the constraint annotation while writing unit tests for a javax.validation.ConstraintValidator
import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;
@Documented
@Constraint(validatedBy = ExampleConstraintValidator.class)
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface ExampleConstraint {
@ufuk
ufuk / TextUtils.java
Last active April 8, 2021 07:03
Curated text utils for specific use cases
import org.apache.commons.lang3.StringUtils;
import java.text.Normalizer;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;