Skip to content

Instantly share code, notes, and snippets.

View cikasfm's full-sized avatar

Zilvinas Vilutis cikasfm

View GitHub Profile
/**
* The problem:
*
* http://stackoverflow.com/questions/15314616/removing-minimal-letters-from-a-
* string-a-to-remove-all-instances-of-string-b
*
* <p>
* If we have string A of length N and string B of length M, where M < N, can I
* quickly compute the minimum number of letters I have to remove from string A
* so that string B does not occur as a substring in A?<br/>
@cikasfm
cikasfm / MoonPhaseCalc.java
Last active August 29, 2015 14:02
MoonPhaseCalc
/**
* Moon Phase Calculator
*
* @author Zilvinas Vilutis
*/
public class MoonPhaseCalc {
public final static String format = "yyyy-MM-dd";
private static final int moonPhaseHours = 709;
@cikasfm
cikasfm / MvelTest.java
Created July 11, 2014 07:22
Verifies MVEL "contains" operator behavior
import static org.junit.Assert.*;
import java.util.*;
import org.junit.Test;
import org.mvel2.MVEL;
/**
* @author Zilvinas Vilutis
sciApp.controller('AngularedCollectionController', ['$scope', '$compile', function ($scope, $compile) {
$scope.index = 1;
$scope.init = function (collectionId) {
var indexes = [];
$('#' + collectionId).find('input[type=hidden]').each(function () {
var attrName = $(this).attr('name');
var indexFinder = new RegExp('\\]\\[(\\d+)\\]\\[');