Skip to content

Instantly share code, notes, and snippets.

View leadVisionary's full-sized avatar

Nicholas Vaidyanathan leadVisionary

View GitHub Profile
@leadVisionary
leadVisionary / TraditionalLeadership.groovy
Created August 16, 2012 07:40
Leadership view differences
public interface Drone{
Object work();
}
public interface Expert extends Drone{
final boolean knowledgable = true;
List<Object> work();
}
public interface Manager {
@leadVisionary
leadVisionary / BundleInformer.java
Created August 15, 2012 19:11
Ugly vs Clean OSGi Tests - Dumb Example
package dumb.test;
import java.util.Comparator;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
private class LatZones
{
private char[] letters = { 'A', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K',
'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Z' };
private int[] degrees = { -90, -84, -72, -64, -56, -48, -40, -32, -24, -16,
-8, 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 84 };
private char[] negLetters = { 'A', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K',
'L', 'M' };
@leadVisionary
leadVisionary / PermutationEstimator.cpp
Created April 16, 2012 23:41
PermutationEstimator
// $Id$
/* Copyright (C) 2008 John B. Shumway, Jr.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@leadVisionary
leadVisionary / DatastoreService.groovy
Created March 2, 2012 02:36
Conflict arises from refactoring
package com.visionarysoftwaresolutions
//Refactored
class DatastoreService {
def parseService
public Zapper createUser(String email){
parseService.createUser(email)
}
@leadVisionary
leadVisionary / AbstractParseAPI.groovy
Created March 2, 2012 02:07
Clean Boundaries for 3rd party APIs
package com.quantumaspects
import groovyx.net.http.*
import net.sf.json.JSONArray
abstract class AbstractParseAPI implements ParseAPI {
public Collection retrieve(String parseEntity){
return retrieveFromParse(parseEntity)
@leadVisionary
leadVisionary / DatastoreService.groovy
Created March 2, 2012 02:03
Initial controller approach
package com.visionarysoftwaresolutions
class DatastoreService {
def parseService
def zapCardService
public Zapper createUser(String email){
parseService.createUser(email)
}
package com.visionarysoftwaresolutions
import grails.test.mixin.*
import org.junit.*
/**
* See the API for {@link grails.test.mixin.web.ControllerUnitTestMixin} for usage instructions
*/
@TestFor(DemoController)
@Mock([ ZapCard, Zapper ])
package com.visionarysoftwaresolutions
class DemoController {
def datastoreService
def index(){
}
def live(){
@leadVisionary
leadVisionary / simulator
Created December 18, 2011 05:21
MicroprocessorSimulator Mock Object
// C++
class MicroprocessorSimulator
{
public:
int (MicroprocessorSimulator::*pt2Member)(float, char, char) = NULL; // C++
void interruptHandler(char toTransform) { return toTransform+10; }
void handleInterrupt39(void (*interruptHandler)(char))
{
char transformed = (*interruptHandler)(a)