Skip to content

Instantly share code, notes, and snippets.

View andyczerwonka's full-sized avatar

Andy Czerwonka andyczerwonka

View GitHub Profile
freezeApp.controller('UserController', function UserController($scope, userService) {
$scope.update = function() {
userService.update($scope.user).success(function() {
// it worked!!
});
};
});
@andyczerwonka
andyczerwonka / login.js
Created October 20, 2015 14:50
This code works using `ionic serve` but not `ionic emulate android`
var login = function(credentials) {
var deferred = $q.defer();
$http.post(loginEndpoint, credentials).then(function(response) {
console.log("Login successful");
localStorage.authToken = response.data;
$http.defaults.headers.common.Authorization = 'auth-token ' + localStorage.authToken;
$http.get(whoamiEndpoint).then(function(response) {
self.user = response.data;
deferred.resolve(response.data);
});
package uk.gov.hmrc.mongo.json
/**
* Thanks goes to Alexander Jarvis for his Gist (https://gist.github.com/alexanderjarvis/4595298)
*/
trait TupleFormats {
import play.api.libs.json._
import play.api.data.validation._
implicit def tuple2Reads[B, T1, T2](c : (T1, T2) => B)(implicit aReads: Reads[T1], bReads: Reads[T2]): Reads[B] = Reads[B] {
@andyczerwonka
andyczerwonka / MockSecurityProvider.java
Created December 26, 2015 16:42
This is the provider implementation that is working under Windows, but not under Linux.
// (c) Copyright 3ES Innovation Inc. 2013. All rights reserved.
package jespa.http;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import jespa.security.Account;
import jespa.security.Properties;
@andyczerwonka
andyczerwonka / RestApiTestBase.java
Last active December 26, 2015 17:05
This configures the Jersey service for the unit tests
@Override
protected DeploymentContext configureDeployment() {
Map<String, String> jespaInit = new HashMap<String, String>();
jespaInit.put("properties.path", "src/test/resources/jespa_ntlm.prp");
ServletContainer servlet = new ServletContainer(
new PortfolioApplication());
return ServletDeploymentContext.forServlet(servlet)
.initParam("javax.ws.rs.Application", "com._3esi.portfolio.PortfolioApplication")
2015-11-14 03:21:58 -0500 [ERROR] from play.core.server.netty.PlayDefaultUpstreamHandler in New I/O worker #4 - Exception caught in Netty
java.lang.IllegalArgumentException: invalid version format: ?+??H???9 ?
at org.jboss.netty.handler.codec.http.HttpVersion.<init>(HttpVersion.java:94) ~[io.netty.netty-3.10.4.Final.jar:na]
at org.jboss.netty.handler.codec.http.HttpVersion.valueOf(HttpVersion.java:62) ~[io.netty.netty-3.10.4.Final.jar:na]
at org.jboss.netty.handler.codec.http.HttpRequestDecoder.createMessage(HttpRequestDecoder.java:75) ~[io.netty.netty-3.10.4.Final.jar:na]
at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:191) ~[io.netty.netty-3.10.4.Final.jar:na]
at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:102) ~[io.netty.netty-3.10.4.Final.jar:na]
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:500) ~[io.netty.netty-3.10.4.Final.jar:na]
at org.jboss.netty.handler.codec.replay.Re
@andyczerwonka
andyczerwonka / nginx.conf
Created January 9, 2016 00:54 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@andyczerwonka
andyczerwonka / Tyrion.scala
Last active March 14, 2016 23:14
Example of class that isn't being called
import akka.actor._
import javax.inject._
import database.MongoEnvironment
import play.api.inject.ApplicationLifecycle
import play.api._
import scala.concurrent.ExecutionContext
@Singleton
[Fact]
public void DepreciationCalculation_NoDepreciationEntries()
{
_test
.MonthlyWindow("2016-01-01", 12)
.DecliningBalance(depreciationRate: 0.0)
.CapexEntry("2016-01-01", 100)
.Expect(
"2016-01-01 0",
"2016-01-02 0",
object ApplicationConfiguration {
private[this] lazy val configuration = expensiveLoadOperation()
def get(excuse: Controller): ApplicationConfiguration = configuration
def get(excuse: ImportProvider): ApplicationConfiguration = configuration
}