Skip to content

Instantly share code, notes, and snippets.

@ryankennedy
ryankennedy / GithubClientTest.java
Created March 25, 2015 23:04
Using DropwizardClientRule to test the GitHub API.
package com.hypnoticocelot.github;
import io.dropwizard.jackson.Jackson;
import io.dropwizard.jersey.jackson.JacksonMessageBodyProvider;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
### Keybase proof
I hereby claim:
* I am ryankennedy on github.
* I am rckenned (https://keybase.io/rckenned) on keybase.
* I have a public key whose fingerprint is 85FC 20AA E092 3128 DBE7 61F6 5344 89C6 1213 23D0
To claim this, I am signing this object:
@ryankennedy
ryankennedy / output.txt
Created September 11, 2015 05:19
node trying to do substring on unicode
$ node substring.js 🙅🏿
🙅🏿.substring(0, 1) = �
🙅🏿.substring(0, 2) = 🙅
🙅🏿.substring(0, 3) = 🙅�
🙅🏿.substring(0, 4) = 🙅🏿
@ryankennedy
ryankennedy / BulkUpdate.java
Created September 11, 2015 19:24
Bulk re-enable SNS endpoints
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.regions.Region;
import com.amazonaws.regions.RegionUtils;
import com.amazonaws.services.sns.AmazonSNS;
import com.amazonaws.services.sns.AmazonSNSClient;
import com.amazonaws.services.sns.model.Endpoint;
import com.amazonaws.services.sns.model.ListEndpointsByPlatformApplicationRequest;
import com.amazonaws.services.sns.model.ListEndpointsByPlatformApplicationResult;
import com.amazonaws.services.sns.model.SetEndpointAttributesRequest;
import com.google.common.collect.ImmutableMap;
import java.util.*;
/**
* List implementation that facilitates wrapping an existing list to convert the contents to another type.
*
* <pre>
* List<String> stringList = Arrays.asList("0", "1", "2", "3", "4");
* List<Integer> integerList = new TypeAdaptingList<Integer, String>() {
* Integer adapt(String value) {
* return Integer.parseInt(value);
import javax.ws.rs.*;
import java.io.File;
import java.lang.reflect.Method;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* JAX-RS utility class for locating all JAX-RS resources under a given ClassLoader.
Hi Ryan,
You have been identified as a candidate for Amazon or one of its many affiliate companies. As a US Federal Contractor, we are required to request that all candidates complete an on-line application that collects information necessary for Amazon and its affiliates to comply with federal reporting obligations.
If you are interested in being considered for an employment opportunity with us, please follow the link below to complete a short application.
To access this form, you will need a login name and password. To access your system-generated password, click the link below, then click "Forgot your Login or Password?" link at the bottom of the page. Enter your login name and we will send you an e-mail with a link to reset your password.
Your login name is: xxxxxxxxxxxxxxxxxx
@ryankennedy
ryankennedy / LeakyBucket.scala
Created July 28, 2011 17:20
A leaky bucket implemented in Scala
import java.util.concurrent.{TimeUnit, SynchronousQueue}
/**
* Simple leaky bucket (http://en.wikipedia.org/wiki/Leaky_bucket) implementation using a
* SynchronousQueue.
*
* // This should take roughly 10 seconds to complete.
* val bucket = new LeakyBucket(100, TimeUnit.SECONDS)
* for (i <- 1 to 1000) {
* bucket.take()
@ryankennedy
ryankennedy / bite_me.txt
Created August 2, 2011 20:40
bite me, java.net.URI
#
# WTF is java.net.URI thinking?
#
scala> new URI("http", null, "hostname", 80, "/foo", "bar%20is=baz", null)
res5: java.net.URI = http://hostname:80/foo?bar%2520is=baz
#
# Oh, I see...I have to do this the inconvenient way.
#
scala> URI.create("http://hostname:80/foo?bar%20is=baz")
@ryankennedy
ryankennedy / SolrWtf.java
Created September 6, 2011 21:41
solr wtf?
/**
* Set the duration for which commit point is to be reserved by the deletion policy.
*
* @param indexVersion version of the commit point to be reserved
* @param reserveTime time in milliseconds for which the commit point is to be reserved
*/
public void setReserveDuration(Long indexVersion, long reserveTime) {
long timeToSet = System.currentTimeMillis() + reserveTime;
for(;;) {
Long previousTime = reserves.put(indexVersion, timeToSet);