Skip to content

Instantly share code, notes, and snippets.

View billy-bacon's full-sized avatar

Billy Bacon billy-bacon

View GitHub Profile
@billy-bacon
billy-bacon / AWSCredentialsFactoryTest.java
Created November 6, 2013 18:22
AWSCredentialsFactoryTest snippet
@After
public void after() {
System.clearProperty("AWS_ACCESS_KEY_ID");
System.clearProperty("AWS_SECRET_KEY");
}
@Test
public void should_get_aws_credentials_in_local_environment() throws Exception {
// setup test
@billy-bacon
billy-bacon / LendingPolicyMapper.xml
Created November 12, 2013 17:46
LendingPolicy SQL
select
max(library.name) as libraryName,
libraryId,
max(tv_rating_system) as tv_rating_system,
max(movie_rating_system) as movie_rating_system,
max(ab_enabled) as ab_enabled,
max(movie_enabled) as movie_enabled,
max(music_enabled) as music_enabled,
max(tv_enabled) as tv_enabled
from (
package com.alex.integration.processor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@Component("pushNotificationMessageProcessor")
public class PushNotificationMessageProcessor {
private static final Logger log = LoggerFactory.getLogger(PushNotificationMessageProcessor.class);
// todo: figure out how to load this from PEM file
// (ANDROID) not applicable; this will be null;
// (iOS) the certificate in pem format with \n at the end of each line.
private String principal;
// todo: figure out how to load this from PEM file
// (ANDROID) the server api key from the google api console
// (iOS) the private key in pem format with \n at the end of each line.
private String credential;
private CreatePlatformApplicationResult createPlatformApplication(String applicationName, Platform platform, String principal, String credential) {
CreatePlatformApplicationRequest platformApplicationRequest = new CreatePlatformApplicationRequest();
Map<String, String> attributes = new HashMap<String, String>();
attributes.put("PlatformPrincipal", principal == null ? "" : principal);
attributes.put("PlatformCredential", credential);
platformApplicationRequest.setAttributes(attributes);
platformApplicationRequest.setName(applicationName);
platformApplicationRequest.setPlatform(platform.name());
return snsClient.createPlatformApplication(platformApplicationRequest);
}
@Mock
private PublishResult publishResult;
@Value("${GOOGLE_SERVER_API_KEY}")
private String googleServerApiKey;
@Value("${APPLE_CERT_FILE}")
private String appleCertificate;
@Value("${APPLE_PRIVATE_KEY_FILE}")
package com.alex.integration.processor;
import com.alex.integration.bean.PatronDevice;
import com.alex.integration.bean.Platform;
import com.alex.integration.bean.PushNotificationMessage;
import com.amazonaws.AmazonClientException;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.services.sns.AmazonSNS;
import com.amazonaws.services.sns.model.*;
import com.fasterxml.jackson.core.JsonProcessingException;
<select id="getRemainingBorrowsForMonth" resultType="java.lang.Integer">
select
(
select circsPerPatronMonth
from Account
where libraryId = (select libraryId from Patron where id=#{value})
)
-
(
select count(*)
package com.alexandria.licenseproxy.stripes.ebook;
import com.alexandria.licenseproxy.helper.CircHelper;
import com.alexandria.licenseproxy.helper.EBookHelper;
import com.google.inject.Inject;
import net.sourceforge.stripes.action.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletResponse;
@Component("pushNotificationListProcessor")
public class PushNotificationListProcessor {
private static final Logger log = LoggerFactory.getLogger(PushNotificationMessageProcessor.class);
private final PatronDeviceHelper patronDeviceHelper;
@Autowired
public PushNotificationListProcessor(final PatronDeviceHelper patronDeviceHelper) {
this.patronDeviceHelper = patronDeviceHelper;
}