Skip to content

Instantly share code, notes, and snippets.

View ashleywxwx's full-sized avatar

Ashley Weatherwax ashleywxwx

  • St. Louis, MO
View GitHub Profile
@ashleywxwx
ashleywxwx / retry-with-backoff.js
Created April 3, 2019 16:41
Retries, but with an exponential backoff
const retryWithBackoff = (eventuallyTrue, callback, retries = 10, msDelay = 100) => {
if (eventuallyTrue()) {
callback();
} else if (retries > 0) {
setTimeout(() => retryWithBackoff(eventuallyTrue, --retries, msDelay * 2, callback), msDelay);
}
};
@ashleywxwx
ashleywxwx / mocha-promise-hooks-test
Created August 15, 2017 14:24
Mocha Promise Hooks Example
const {expect} = require("chai");
let asyncValue = null;
function slowPromise() {
return new Promise((resolve, reject) => {
let wait = setTimeout(() => {
clearTimeout(wait);
console.log("Timeout complete");
resolve("Finished");
@ashleywxwx
ashleywxwx / SlackJenkinsDSL
Created May 31, 2016 21:02
Configuring Jenkins Job DSL for Slack
configure {
it / 'publishers' / 'jenkins.plugins.slack.SlackNotifier'(plugin: "[email protected]") {
teamDomain('myteam')
authToken('mytoken')
buildServerUrl('http://mydomain:8080/')
room('#my-room')
notifyUnstable(true)
notifyFailure(true)
notifyBackToNormal(true)
includeTestSummary(true)
package com.recursivechaos.rcutils;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ashleywxwx
ashleywxwx / java8jRedditDemo
Created May 12, 2014 23:44
jReddit and Java 8 Wordcount
import java.util.List;
import com.github.jreddit.user.Comment;
import com.github.jreddit.user.User;
public class Main {
public static void main(String[] args) throws Exception {
// Provide user account for credentials
User user = new User("username","password");
user.connect();
@ashleywxwx
ashleywxwx / CSVParserExample.java
Last active August 29, 2015 13:58
How to read a CSV from a file, by label using Ostermiller.util.LabeledCSVParser
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import com.Ostermiller.util.CSVParser;
import com.Ostermiller.util.LabeledCSVParser;
/**
* Opens a csv file, grabs the label, and fetches fields via label names.