Skip to content

Instantly share code, notes, and snippets.

View bibarsov's full-sized avatar
💭
I may be slow to respond.

Timur bibarsov

💭
I may be slow to respond.
View GitHub Profile
@bibarsov
bibarsov / AppConfig.java
Last active October 25, 2024 07:12
Spring / Hikari / Postgres / Multiple datasources
package test.app.config;
import com.zaxxer.hikari.HikariDataSource;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
public static void main(String[] args) {
    CouchbaseCluster cluster = CouchbaseCluster.create(
        DefaultCouchbaseEnvironment.create(), 
        "localhost"//nodes
    );
    CouchbaseTemplate couchbaseTemplate = new CouchbaseTemplate(
        cluster.clusterManager(
            "user",//username
 "auth-example"//password
  1. Create ~/.m2/settings.xml
<settings>
    <servers>
        <server>
            <id>internal.repo</id>
            <username>${repo.login}</username>
            <password>${repo.pwd}</password>
        </server>
 
# Delete branches by regex
git branch | grep "<pattern>" | xargs git branch -D
# Always use current branch as the upstream branch (use: git push -u)
git config --global push.default current
public static void main(String[] args) {
File file = new File("/Users/tbibarsov/Downloads/1_000_000_Contacts.xlsx");
int[] arr = {100, 500, 1_000, 5_000, 10_000, 25_000, 50_000, 100_000, 500_000, 1_000_000, -1};
for (int i : arr) {
long s = System.currentTimeMillis();
RowIterator excelRowIterator = getExcelRowIterator(
StreamingReader.builder()
.sstCacheSize(i)
.open(file)
);
public static void main(String[] args) {
ch.qos.logback.classic.Logger rootLogger = (ch.qos.logback.classic.Logger)LoggerFactory.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME);
rootLogger.setLevel(Level.toLevel("trace"));
Logger logger = LoggerFactory.getLogger("Test");
if(!LOGGER.isDebugEnabled()){
LOGGER.info("BLA BLA INFO");
}
LOGGER.debug("BLA BLA DEBUG");
}
@bibarsov
bibarsov / gist:a7cf48068ed36f5742a5b17d8e2a7de2
Created February 26, 2017 21:10
Export to CSV from Rails Console
require 'csv'
file = "#{Rails.root}/public/data.csv"
schools = School.where(state_code: 'CO').order('name ASC')
CSV.open( file, 'w' ) do |writer|
schools.each do |s|
writer << [s.name, s.zipcode, s.id]
end
@bibarsov
bibarsov / gist:ed2f36ab22c9e45cc3c2eabf0a985db0
Created February 24, 2017 12:24
apache httpclient 4.5 proxy request example
CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(
new AuthScope("proxy host", 3128),
new UsernamePasswordCredentials("login", "password"));
CloseableHttpClient httpclient = HttpClients.custom()
.setDefaultCredentialsProvider(credsProvider).build();
try {
HttpHost target = new HttpHost("root target url", 443, "https");
HttpHost proxy = new HttpHost("proxy host", 3128);
@bibarsov
bibarsov / gist:3b17aa8af7a98c922ccff4e1a1418c27
Last active February 27, 2019 22:32
Export Jar with dependencies (Gradle)
task fatJar(type: Jar) {
manifest {
attributes 'Implementation-Title': 'Gradle Jar File Example',
'Implementation-Version': version,
'Main-Class': 'com.example.Main'
}
baseName = project.name + '-all'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}