Skip to content

Instantly share code, notes, and snippets.

@DDmitrid
DDmitrid / datetime.java
Created February 6, 2019 13:36 — forked from salomvary/datetime.java
Java 8 Date and Time Parsing and Formatting Microtutorial
import java.time.format.DateTimeFormatter;
import java.time.Instant;
import java.time.ZonedDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
Instant.now();
// java.time.Instant = 2015-08-13T09:28:27.141Z
DateTimeFormatter.ISO_INSTANT.format(Instant.now());
@DDmitrid
DDmitrid / CamelCaseMacro.velocity
Last active January 22, 2019 14:43 — forked from Pencroff/CamelCaseMacro.velocity
Transformation file name to CamelCase in IntelliJ IDEA file templates
## file name transformation
## file-name => FileName
## Sources:
## http://stackoverflow.com/questions/6998412/velocity-string-function
## http://stackoverflow.com/questions/21288687/using-velocity-split-to-split-a-string-into-an-array-doesnt-seem-to-work
## http://velocity.apache.org/engine/releases/velocity-1.7/apidocs/org/apache/velocity/util/StringUtils.html#split(java.lang.String, java.lang.String)
#set( $CamelCaseName = "" )
#set( $part = "" )
-------------------------------------------------------------------------------------------------------------------
--- CustomDomain
#set( $regex = "([a-z])([A-Z]+)")
#set( $replacement = "$1_$2")
#set( $UpperCaseTableName = $NAME.replaceAll($regex, $replacement).toUpperCase())
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
import lombok.AllArgsConstructor;
import lombok.Builder;
@DDmitrid
DDmitrid / hikaricp-sqlserver-datasource
Created July 31, 2018 09:14 — forked from jampajeen/hikaricp-sqlserver-datasource
Create spring datasource for SQL Server & HikariCP
jdbc.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
jdbc.url=jdbc:sqlserver://localhost:1433;databaseName=test
jdbc.username=myuser
jdbc.password=mypass
hikariCP.dataSourceClassName=com.microsoft.sqlserver.jdbc.SQLServerDataSource
@Bean
public DataSource dataSource(@Value("${hikariCP.dataSourceClassName}") String dataSourceClassName,
@Value("${jdbc.url}") String url,
@DDmitrid
DDmitrid / big-o-java-collections.md
Created July 27, 2018 11:34 — forked from FedericoPonzi/big-o-java-collections.md
Big O notation for java's collections

The book Java Generics and Collections has this information (pages: 188, 211, 222, 240).

List implementations:

                      get  add  contains next remove(0) iterator.remove
ArrayList             O(1) O(1) O(n)     O(1) O(n)      O(n)
LinkedList O(n) O(1) O(n) O(1) O(1) O(1)
@DDmitrid
DDmitrid / gist:9aaca12faa5d08255a8d297433cc2bce
Created July 27, 2018 11:31 — forked from psayre23/gist:c30a821239f4818b0709
Runtime Complexity of Java Collections
Below are the Big O performance of common functions of different Java Collections.
List | Add | Remove | Get | Contains | Next | Data Structure
---------------------|------|--------|------|----------|------|---------------
ArrayList | O(1) | O(n) | O(1) | O(n) | O(1) | Array
LinkedList | O(1) | O(1) | O(n) | O(n) | O(1) | Linked List
CopyOnWriteArrayList | O(n) | O(n) | O(1) | O(n) | O(1) | Array
@DDmitrid
DDmitrid / upgrade-postgres-9.6-to-10.md
Created July 16, 2018 08:56 — forked from mdesantis/upgrade-postgres-9.6-to-10.md
Upgrading PostgreSQL from 9.6 to 10 on Ubuntu 16.04

TL;DR

Install Postgres 10, and then:

sudo pg_dropcluster 10 main --stop
sudo pg_upgradecluster 9.6 main
sudo pg_dropcluster 9.6 main
@DDmitrid
DDmitrid / ffmpeg.md
Created May 7, 2018 09:21 — forked from protrolium/ffmpeg.md
using ffmpeg to extract audio from video files

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

Convert WAV to MP3, mix down to mono (use 1 audio channel), set bit rate to 64 kbps and sample rate to 22050 Hz:

cd ~/.IntelliJIdea2017.3/
rm config/eval/idea173.evaluation.key
rm config/options/options.xml
cd ~/.java/.userPrefs/jetbrains/
rm -rf idea
sed -i '/evlsprt/d' ~/.IntelliJIdea2018.3/config/options/other.xml
https://gist.github.com/Bleser92/06441ca800095729b1041a0175418335
https://gist.github.com/denis111/c3e08bd7c60febc1de8219930a97c2f6

Best Practices for Azure Redis

Below are a set of best practices that I recommend for most customers. This information is based on my experience helping hundreds of Azure Redis customers investigate various issues.

Configuration and Concepts

  1. Use Standard or Premium Tier for Production systems. The Basic Tier is a single node system with no data replication and no SLA. Also, use at least a C1 cache. C0 caches are really meant for simple dev/test scenarios since they have a shared CPU core, very little memory, are prone to "noisy neighbor", etc.
  2. Remember that Redis is an In-Memory data store. Read this article so that you are aware of scenarios where data loss can occur.
  3. Configure your client library to use a "connect timeout" of at least 10 to 15 seconds, giving the system time to connect even under higher CPU conditions. If your client or server tend to be under high load