Skip to content

Instantly share code, notes, and snippets.

@jasondevj
jasondevj / gist:9439d975767f3ce7d54394503005ce29
Last active September 17, 2025 10:42
This script transfers data from a source PostgreSQL database to a destination database with support for upsert operations (insert or update) and table selection.
#!/usr/bin/env python3
"""
PostgreSQL Database Transfer Tool
This script transfers data from a source PostgreSQL database to a destination database
with support for upsert operations (insert or update) and table selection.
"""
import argparse
import json
@jasondevj
jasondevj / onCreateCommand.sh
Last active January 9, 2024 04:38
Devcontainer onCreateCommand.sh
apt-get update && apt-get upgrade -y && apt-get install -y curl && apt-get clean
# Create aliases in here that you may want to use in the devcontainer
echo alias ll=\'ls -l\' >> ~/.bashrc
@jasondevj
jasondevj / out.java
Last active January 11, 2016 04:44
What is the output?
public class LuckyNumber {
static int luckyNumber = 21;
public static LuckyNumber getInstance() {
return null;
}
public static void main(String[] args) {
System.out.println(LuckyNumber.getInstance().luckyNumber);
System.out.println(LuckyNumber.getInstance().getInstance());
}
}
@jasondevj
jasondevj / Java8StreamTestParallelArraySynch.java
Last active August 29, 2015 14:09
Java 8 Stream Performance Test and how if a developer spends sufficient time developing he can come up with a more faster code
public static long parallelArraySynchronised() {
final long[] sum = {0};
CountDownLatch countDownLatch = new CountDownLatch(NUMBER_OF_PROCESSORS);
long totalPerThread = LIMIT / NUMBER_OF_PROCESSORS;
for (int i = 0; i < NUMBER_OF_PROCESSORS; i++) {
final int finalI = i;
executors.execute(() -> {
for (int j = (int) (totalPerThread * finalI); j < (totalPerThread * (finalI + 1)); j++) {
synchronized (Java8PerfTest.class) {
sum[0] += j;