Skip to content

Instantly share code, notes, and snippets.

View stanio's full-sized avatar

Stanimir Stamenkov stanio

View GitHub Profile
@stanio
stanio / locations-comments.js
Created April 22, 2015 13:53
postbank.bg/Applications/Locations/_inc/js/locations.js comments
//тук ще се пазят всички маркери които съм залепил по картата това е Array от обекти тип {marker:object, JSONData:object} - JSONData се използва за да пазя обекта с даните както е дошъл от сървара.
//трябва ми за да си намеря панела при кликане в/у маркера и за да го скролирам до обекта, който е кликнат.
//ще го напълня в PutMarkers и в него ще седят само градовете, които ще нахаквам в комбото с градовете.
//за да не бия постоянно json заявки към сървара, веднъж след като съм го заредил, само крия, показвам! затова ползвам isLoad
//някой вика асинхронно два пъти на onload json ама не мога да го хвана кой. За да оправим проблема проверяваме арея дали е празен и чак тогава стартираме
//използваме малка простотия и си сетваме наш параметър на Google маркера
/*и както се вижда може да си го взема после*/
//правим чудесии от храброст, защото ondblclick изстрелва и clik, и става една мазня.. затова за гледам дали е отворен ако е .. не го пипам.. ако не е го отварям!
/*и както се вижда може да си го взема после*/
/*
@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)
@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 / 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 / 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 / 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 / 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 / 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 / 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 / SuperXBR.java
Last active October 18, 2022 01:24
Super-xBR Scaler: https://pastebin.com/cbH8ZQQT (Java version)
/*
* Copyright (c) 2016 Hyllian - [email protected]
*
* 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:
*