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 / 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>
/*
* 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 / Avg.java
Last active October 11, 2020 13:43
Calculating the average incrementally
//package ;
/**
* @see <a href="https://ubuntuincident.wordpress.com/2012/04/25/calculating-the-average-incrementally/">Calculating the average incrementally</a>
*/
public class Avg {
private double value = Double.NaN;
private long count;