Skip to content

Instantly share code, notes, and snippets.

View stanio's full-sized avatar

Stanimir Stamenkov stanio

View GitHub Profile
/*
* xBRZ project is distributed under
* GNU General Public License: https://www.gnu.org/licenses/gpl-3.0
* Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved
*
* Additionally and as a special exception, the author gives permission
* to link the code of this program with the following libraries
* (or with modified versions that use the same licenses), and distribute
* linked combinations including the two: MAME, FreeFileSync, Snes9x, ePSXe
* You must obey the GNU General Public License in all respects for all of
@stanio
stanio / SuperXBR.java
Last active October 18, 2022 01:24
Super-xBR Scaler: https://pastebin.com/cbH8ZQQT (Java version)
/*
* Copyright (c) 2016 Hyllian - sergiogdb@gmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
@stanio
stanio / Permutations.java
Created January 5, 2020 02:20
Permutations of an Array in Java
package net.example.math;
import java.io.PrintStream;
import java.util.Arrays;
/**
* <blockquote>
* <p>The number of permutation increases fast with <em>n</em>. While it takes
* only a few seconds to generate all permutations of ten elements, it will
* take two weeks to generate all permutations of 15 elements:</p>
@stanio
stanio / MySQLLockService.java
Last active March 25, 2022 20:19
Liquibase LockService using database session-level locks (moved to https://github.com/blagerweij/liquibase-sessionlock)
/*
* This module, both source code and documentation,
* is in the Public Domain, and comes with NO WARRANTY.
*/
package net.example.liquibase.lockservice.ext;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@stanio
stanio / README.md
Last active December 18, 2019 05:48
Transform Liquibase XML into Groovy DSL syntax
<?xml-stylesheet href="liquibase-groovy.xslt" type="text/xml"?>

<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" ...>
    ...
</databaseChangeLog>
databaseChangeLog {
@stanio
stanio / BasePath.java
Created December 16, 2019 22:43
Find the common base path of a list of file paths
//package ;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
/**
* @see <a href="https://www.geeksforgeeks.org/longest-common-prefix-using-binary-search/">Longest
* Common Prefix using Binary Search</a>
*/
@stanio
stanio / StringUtil.java
Created December 16, 2019 22:32
Longest Common Prefix using Binary Search
//package ;
/**
* @see <a href="https://www.geeksforgeeks.org/longest-common-prefix-using-binary-search/">Longest
* Common Prefix using Binary Search</a>
*/
public class StringUtil {
public static String commonPrefix(CharSequence... strings) {
int low = 0, high = minLength(strings) - 1;
@stanio
stanio / KeyedObjects.java
Last active January 10, 2019 13:25
Dynamic lock set
/*
* This module, both source code and documentation,
* is in the Public Domain, and comes with NO WARRANTY.
*/
package net.example.concurrent;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@stanio
stanio / exception_formatter.rb
Last active September 7, 2017 13:12
Formatting function to provide full exception chain backtrace
# frozen_string_literal: true
#
# This module, both source code and documentation,
# is in the Public Domain, and comes with NO WARRANTY.
#
require 'stringio'
module ExceptionFormatter
module_function
@stanio
stanio / active_record_reference.rb
Created June 29, 2015 14:38
ActiveRecord Reference Proxy (lazy-load)
require 'active_record'
module ActiveRecord
#
# @see http://stackoverflow.com/questions/28434966/lazy-load-activerecord-proxy-instance Lazy-load ActiveRecord proxy instance
#
class Reference < ActiveSupport::ProxyObject
def initialize(record_class, primary_key)