Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Okan Menevşeoğlu okanmenevseoglu

🏠
Working from home
View GitHub Profile
@ufuk
ufuk / posgresql-lightspeed-alter-table.sql
Last active Nov 5, 2018
Increase performance of alter tables or any other expensive operations by increasing WORK_MEM parameter for current session in PostgreSQL
View posgresql-lightspeed-alter-table.sql
BEGIN;
LOCK TABLE ... IN SHARE MODE;
SET LOCAL WORK_MEM = '256MB';
ALTER TABLE ...;
COMMIT;
@ufuk
ufuk / TurkishNumberUtils.java
Last active Nov 13, 2020
Util for converting whole numbers to Turkish words
View TurkishNumberUtils.java
public final class TurkishNumberUtils {
private static final String SPACE = " ";
private static final String EMPTY = "";
private static final String[] PERIOD_NAMES = {EMPTY, "bin", "milyon", "milyar", "trilyon", "katrilyon", "kentilyon"};
private static final String[] UNITS_TEXTS = {EMPTY, "bir", "iki", "üç", "dört", "beş", "altı", "yedi", "sekiz", "dokuz"};
@ufuk
ufuk / postgresql-cryptography-functions.sql
Last active Jan 29, 2018
Enable cryptography functions (pgcrypto extension) in PostgreSQL.
View postgresql-cryptography-functions.sql
CREATE EXTENSION pgcrypto;
-- Examples
SELECT ENCODE(DIGEST('password', 'md5'), 'hex');
SELECT ENCODE(DIGEST('password', 'sha1'), 'hex');
SELECT ENCODE(DIGEST('password', 'sha224'), 'hex');
SELECT ENCODE(DIGEST('password', 'sha256'), 'hex');
SELECT ENCODE(DIGEST('password', 'sha384'), 'hex');
SELECT ENCODE(DIGEST('password', 'sha512'), 'base64');
@ufuk
ufuk / postgresql-export-import-schema.sh
Last active Jun 11, 2018
Exporting and then importing full schema for PostgreSQL.
View postgresql-export-import-schema.sh
# export
PGPASSWORD="<PASSWORD>" pg_dump -U <USERNAME> -h <HOST> -d <DB_NAME> -n <SCHEMA_NAME> > export.sql
# import
PGPASSWORD="<PASSWORD>" psql -U <USERNAME> -h <HOST> -d <DB_NAME> -n <SCHEMA_NAME> -f export.sql
@ufuk
ufuk / JpaEntityQueryBuilder.java
Last active Jun 10, 2022
Easy to use query builder for JPA Criteria API
View JpaEntityQueryBuilder.java
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.IteratorUtils;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.query.criteria.internal.path.PluralAttributePath;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.repository.support.PageableExecutionUtils;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
@ufuk
ufuk / find-out-stale-branches.sh
Last active Oct 31, 2017
Lists git branches ordered by last change time to find out which ones are stale branches.
View find-out-stale-branches.sh
#!/bin/bash
# DESCRIPTION
# -----------
#
# Produces CSV output like this:
#
# LAST CHANGE TIME, TIME ELAPSED, AUTHOR, BRANCH
# 2017-01-16 14:56:26 +0000, 3 months ago, john.doe@example.com, origin/bug-fix-1
# 2017-01-23 18:27:53 +0300, 2 months ago, john.doe@example.com, origin/new-feature-1
@ufuk
ufuk / BaseMockitoTest.java
Last active Apr 9, 2019
Performs "verify no more interactions" check automatically for all mock objects (works with Mockito version 2). For detailed description: https://ufukuzun.wordpress.com/2019/04/09/ne-olup-bittiginden-habersiz-testlere-derman-mockscollector/ (Turkish)
View BaseMockitoTest.java
import org.apache.commons.lang3.ArrayUtils;
import org.junit.After;
import org.junit.runner.RunWith;
import org.mockito.InOrder;
import org.mockito.runners.MockitoJUnitRunner;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.verifyNoMoreInteractions;
@RunWith(MockitoJUnitRunner.class)
@kevin-smets
kevin-smets / iterm2-solarized.md
Last active Sep 28, 2022
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)
View iterm2-solarized.md

Default

Default

Powerlevel10k

Powerlevel10k