Skip to content

Instantly share code, notes, and snippets.

@skuenzli
skuenzli / heroku_ssl_grails_232.md
Created January 12, 2014 19:03
Configure SSL for a Grails 2.3.2 app hosted on *.herokuapp.com

configure ssl for a grails 2.3.2 app hosted on *.herokuapp.com

This snippet configures proper detection of the http/https channel security by a Grails 2.3.2 application using the (latest) Spring Security 2.0-RC2 grails plugin. This configuration resides-in grails-app/conf/Config.groovy.

// belongs in 'production' environment block or guarded by, e.g. a System.property-check.

// [heroku] proxy support -- allow SSL to be terminated at the load balancer / proxy
// look for X-FORWARDED-PROTO (case-sensitive)
// https://discussion.heroku.com/t/grails-spring-security-core-securechannel-definition-causes-redirect-loop/219/2
@skuenzli
skuenzli / AppDelegate.m
Created November 1, 2014 21:56
AppDelegate with automatic measurement of http requests
#import "AppDelegate.h"
#import <WNGLogger/logger.h>
#import <WNGLogger/NSURLConnection+WNGLogging.h> //add WNGLogging category to NSURLConnection
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
@skuenzli
skuenzli / main.swift
Created November 1, 2014 21:57
main.swift with automatic measurement of http requests
import Foundation
import UIKit
let apiKey = "specify your api key here";
WNGLogger.initSharedLogger(apiKey)
WNGLogger.sharedLogger().recordStart("application-launch")
NSURLConnection.wng_enableLogging()
UIApplicationMain(C_ARGC, C_ARGV, NSStringFromClass(UIApplication), NSStringFromClass(AppDelegate))
@skuenzli
skuenzli / Gruntfile.js
Created August 19, 2015 05:11
grunt-based sitespeed.io task
module.exports = function (grunt) {
grunt.initConfig({
sitespeedio: {
default: {
options: {
urls: ['http://localhost:8000'],
deepth: 1,
connection: 'cable',
resultBaseDir: 'sitespeed.out',
@skuenzli
skuenzli / gulp.out
Created August 19, 2015 05:37
gulp-based sitespeed.io
kermit:iteratephx.github.io(frontend-perfmatters) skuenzli$ open sitespeed.out/localhost/2015-08-18-22-32-55
kermit:iteratephx.github.io(frontend-perfmatters) skuenzli$ node_modules/.bin/gulp sitespeedio
[22:34:37] Analyze your sites web performance
[22:34:37] Using gulpfile ~/dev/dev.weblog-ng/iteratephx.github.io/gulpfile.js
[22:34:37] Starting 'sitespeedio'...
info: OS: 'darwin 14.3.0', Node.js: 'v0.10.23', sitespeed.io: '3.5.0', PhantomJS: '1.9.8', java: '1.7.0_67', browsertime: '0.9.4'
info: Will analyze 1 pages
info: Running YSlow for http://localhost:8000 [phantomjs]
verbose: Done processing url in yslow: http://localhost:8000
info: Done analyzing urls
@Bean
public ActorSystem actorSystem() {
ActorSystem system = ActorSystem.create("actor-system");
// initialize the application context in the Akka Spring Extension
SpringExtProvider.get(system).initialize(applicationContext);
return system;
}
/**
* Create a Props for the specified actorBeanName using the
* SpringActorProducer class.
*
* @param actorBeanName The name of the actor bean to create Props for
* @return a Props that will create the named actor bean using Spring
*/
public Props props(String actorBeanName) {
return Props.create(SpringActorProducer.class, applicationContext, actorBeanName);
}
@Override
public Actor produce() {
println "produce() called for actorBeanName: ${actorBeanName}"
return (Actor) applicationContext.getBean(actorBeanName);
}
class NumberController {
static final FiniteDuration DURATION_3_SECONDS = FiniteDuration.create(3, TimeUnit.SECONDS)
static final TIMEOUT_3_SECONDS = Timeout.durationToTimeout(DURATION_3_SECONDS)
ActorSystem actorSystem //actorSystem is injected by Spring via standard Grails behavior
def random() {
def requestId = UUID.randomUUID().toString()
// the service that will be automatically injected
final NumberService numberService;
@Inject
public NumberActor(@Named("NumberService") NumberService numberService) {
this.numberService = numberService;
}
@Override
public void onReceive(Object message) throws Exception {