Skip to content

Instantly share code, notes, and snippets.

@dannyduc
dannyduc / FindAges.java
Last active November 8, 2016 19:01
Ages Of Three Children Puzzle Solution http://gohighbrow.com/how-old-are-my-children-solution/
import java.util.*;
public class Main {
public static void main(String[] args) {
int max = 72;
int maxDate = 31;
Set<Ages> agesPerms = getProducPerms(max, maxDate);
Map<Integer, List<Ages>> sumToAgesMap = getSumToAgesMap(agesPerms);
Map<Integer, List<Ages>> sumWithDups = getSumWithDups(sumToAgesMap);
public class Something {
private Something() {
System.out.println("Constructor called...");
}
/**
* SingletonHolder is loaded on the first execution of Singleton.getInstance() or the first access to SingletonHolder.INSTANCE, not before.
*/
private static class LazyHolder {
private static final Something INSTANCE = new Something();
@dannyduc
dannyduc / svnLogFirstVersion.bash
Created November 4, 2015 03:58
svn log command to get first check in
svn log -r 1:HEAD --limit 1 http://svn.ingenui.com:8081/repos/trunk/ing/ims_component
var partialAny = (function() {
var slice = Array.prototype.slice;
function partialAny(fn /*, args...*/) {
var orig = slice.call(arguments, 1);
return function() {
var partial = slice.call(arguments, 0);
var args = [];
for (var i = 0; i < orig.length; i++) {
@dannyduc
dannyduc / setZeroTimeout.js
Created October 27, 2014 06:50
setZeroTimeout
// http://dbaron.org/log/20100309-faster-timeouts
// Only add setZeroTimeout to the window object, and hide everything
// else in a closure.
(function() {
var timeouts = [];
var messageName = "zero-timeout-message";
// Like setTimeout, but only takes a function argument. There's
// no time argument (always zero) and no arguments (you have to
// use a closure).
shasum -a 256 $1
@dannyduc
dannyduc / gist:9920671
Created April 1, 2014 18:57
git firewall workaround
git config --global url."https://".insteadOf git://
@dannyduc
dannyduc / drop_all.sql
Created February 28, 2014 23:09
drop all in oracle
BEGIN
FOR cur_rec IN (SELECT object_name, object_type
FROM user_objects
WHERE object_type IN
('TABLE',
'VIEW',
'PACKAGE',
'PROCEDURE',
'FUNCTION',
'SEQUENCE'
@dannyduc
dannyduc / epoc.sh
Last active August 29, 2015 13:56
command line for epoc time
ts=`date +%s1`
echo $ts
date -r $ts
public class IntegrationTestUtil {
public static void addParameters(Object formObject, MockHttpServletRequest request) {
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);
Map<String, Object> propertyValues = mapper.convertValue(formObject, Map.class);
Set<String> propertyNames = propertyValues.keySet();
Iterator<String> nameIter = propertyNames.iterator();