This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Retry { | |
private static final Logger log = Logger.getLogger(Retry.class); | |
public static interface CallToRetry<T> { | |
<T> T doIt() throws Exception; | |
} | |
public static T withRetry(int maxTimes, long initialWait, int waitMultiplier, CallToRetry<T> call) { | |
if(maxTimes <= 0) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var handle = null; | |
handle = $.PeriodicalUpdater('/notifications', { | |
method: 'GET', | |
data: id: $field_id, | |
cookie: false, | |
maxTimeout: 5000, | |
error: function (xhr,status,message) { | |
// Do stuff | |
handle.stop(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE groupID INT; | |
INSERT INTO TRACKER_REVIEW_AUDIT (trCTM_DataID, AUDIT_Date, EditWho_Id, WAS_Value, IS_Value, WAS_trCTM_ItemID, IS_trCTM_ItemID, WAS_Approved, IS_Approved, WAS_Expiration_Date, IS_Expiration_Date, WAS_Rej_Reason, IS_Rej_Reason, WAS_Reviewer, IS_Reviewer, WAS_Dose, IS_Dose, WAS_Administered_Date, IS_Administered_Date, IS_Test_Results, IS_Test_Result_Notes, IS_Next_Step, IS_Complete, IS_Pre, IS_Pre_Date, IS_Post, IS_Post_Date, WAS_Test_Results, WAS_Test_Result_Notes, WAS_Next_Step, WAS_Complete, WAS_Pre, WAS_Pre_Date, WAS_Post, WAS_Post_Date, IS_Record_Type, WAS_Record_Type, IS_trCTM_Status, WAS_trCTM_Status) | |
VALUES (NEW.trCTM_DataID, NOW(), NEW.EDIT_Who, NULL, NEW.trCTM_Value, NULL, NEW.trCTM_ItemID, NULL, NEW.trCTM_Approved, NULL,NEW.trCTM_Expiration_Date, NULL, NEW.trCTM_Rej_Reason, NULL, NEW.trCTM_Reviewer, NULL, NEW.trCTM_Dose,NULL, NEW.trCTM_Administered_Date,NEW.trCTM_Test_Results, NEW.trCTM_Test_Result_Notes, NEW.trCTM_Next_Step, NEW.trCTM_Complete, NEW.trCTM_Pre, NEW.tr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Use this in a try-with-resources block to automatically implement logging timing. | |
*/ | |
public class TimingLogger implements AutoCloseable { | |
private final Logger logger; | |
private final String description; | |
private final long startTime; | |
private final AtomicBoolean closed = new AtomicBoolean(false); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private interface RedisCallback<T> { | |
T apply(Jedis jedis) throws IOException; | |
} | |
private <T> T withRedis(RedisCallback<T> callback) throws IOException { | |
Objects.requireNonNull(redisConnectionPool, "redis connection pool must be initialized"); | |
Objects.requireNonNull(callback, "callback needs to be provided"); | |
try(Jedis jedis = redisConnectionPool.getResource()) { | |
T result = callback.apply(jedis); | |
redisConnectionPool.returnResource(jedis); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AnonymousExtend { | |
public static class Doer { | |
public void doIt() { | |
System.out.println("Hello, World!"); | |
} | |
} | |
public static final Doer MY_DOER = new Doer() { | |
@Override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
toFixed: function(num) { | |
return num.toFixed(0).replace(/./g, function(c, i, a) { | |
return i > 0 && c !== "." && (a.length - i) % 3 === 0 ? "," + c : c; | |
}); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-# Here are the assumptions. | |
-# 1. We have a consistent UI concept of 'tabbed pages', which have a consistent frame (at least in terms of Haml). | |
-# 2. Each component of the tabbed pages can be represented as a partial. | |
-# | |
-# Given that, I propose that we create a helper that you would call like this. | |
= tabs {:first => "First Tab!", :second => "2nd Tab", :third => "last tab"} | |
-# The argument to that function we will call "tab_hash" | |
-# It would then first load the tab UI component, roughly equivalent to something like this. | |
= partial "partials/tabs", {:locals => tab_hash} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Aliasing { | |
// Put your type alias right before the return value. | |
public static <L extends Long> String parseToHex(String str) { | |
return L.toHexString(L.parseLong(str)); | |
} | |
// Use this for when you have some ugly type. | |
public static <MAP extends Map<String,Set<String>>> boolean addToKey(String key, String value) { | |
MAP x = service.getKeyMap(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Here's the approach that I would take. In the description that follows, | |
P denotes the point where the user clicked, which has coordinates (x_p, y_p). | |
Each of these steps will involve checking pairs of points against the point | |
where the user clicked, denoted as A and B, with coordinates (x_a, y_a) | |
and (x_b, y_b). | |
We will move forward in three steps: | |
first, we will identify those pairs of points that could possibly be our point; | |
second, we will calculate the distance from the point to the line defined by |