Skip to content

Instantly share code, notes, and snippets.

@cpilsworth
cpilsworth / pom.xml
Created September 12, 2018 22:47
Maven POM for content sync - empty package creation | source upload | source build | source download | target install
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- ====================================================================== -->
<!-- P R O J E C T D E S C R I P T I O N -->
<!-- ====================================================================== -->
<groupId>uk.co.diffa.contentsync</groupId>
<artifactId>sync</artifactId>
@cpilsworth
cpilsworth / 001-index.md
Last active May 23, 2018 20:16
A+ SSL using Java 9

Configuring java for an A+ ssllabs.com server rating

It never used to be possible to get an A+ rating, as Java missed a couple of necessary features

Setting up the server

Getting Java 9

wget http://download.java.net/java/GA/jdk9/9/binaries/jdk-9+181_linux-x64_bin.tar.gz

Getting the LetsEncrypt/EFF certbot

@cpilsworth
cpilsworth / lambda-basic-auth.js
Created March 3, 2018 19:58 — forked from lmakarov/lambda-basic-auth.js
Basic HTTP Authentication for CloudFront with Lambda@Edge
'use strict';
exports.handler = (event, context, callback) => {
// Get request and request headers
const request = event.Records[0].cf.request;
const headers = request.headers;
// Configure authentication
const authUser = 'user';
const authPass = 'pass';
@cpilsworth
cpilsworth / gist:4482792
Created January 8, 2013 10:37
Configurable OSGI Service using Felix SCR Annotations
package com.sample.osgi;
import java.util.Map;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Modified;
import org.apache.felix.scr.annotations.Property;
@Component(label = "Service Label", description = "Service Description", metatype = true, immediate = true)
@cpilsworth
cpilsworth / pom.xml
Created July 29, 2016 10:44
Maven module pom for wrapping jjwt 0.6.0 and making android.util import optional
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.myapp</groupId>
<artifactId>jjwt</artifactId>
<version>0.6.0</version>
<packaging>bundle</packaging>
<name>JSON Web Token support for the JVM</name>
<description>
This bundle simply wraps ${pkgGroupId}-${pkgVersion}.jar and makes android.util optional
</description>
@cpilsworth
cpilsworth / post.POST.html
Last active April 21, 2016 13:42
Using acs-aem-commons forms functionality with Sightly
<sly data-sly-use.form="test.js"></sly>
sly data-sly-test.errors="${form.validate}"></sly>
<sly data-sly-test="${errors}">${form.renderForm}</sly>
<sly data-sly-test="${!errors}">${form.redirectSuccess}</sly>
@cpilsworth
cpilsworth / service-checklist.md
Created March 24, 2016 14:37 — forked from acolyer/service-checklist.md
Internet Scale Services Checklist

Internet Scale Services Checklist

A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."

Basic tenets

  • Does the design expect failures to happen regularly and handle them gracefully?
  • Have we kept things as simple as possible?
@cpilsworth
cpilsworth / GetMeAPage.java
Last active December 21, 2015 22:29
Getting a page from a OSGI component both inside and outside the scope of a sling request
package uk.co.diffa;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.resource.LoginException;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ResourceResolverFactory;
Note 1: The following CQ curl commands assumes a admin:admin username and password.
Note 2: For Windows/Powershell users: use two "" when doing a -F cURL command.
Example: -F"":operation=delete""
Note 3: Quotes around name of package (or name of zip file, or jar) should be included.
Uninstall a bundle (use http://localhost:4505/system/console/bundles to access the Apache Felix web console)
curl -u admin:admin -daction=uninstall http://localhost:4505/system/console/bundles/"name of bundle"
Install a bundle
curl -u admin:admin -F action=install -F bundlestartlevel=20 -F
@cpilsworth
cpilsworth / clean_dot_files.bat
Last active December 16, 2015 18:49
Powershell command to delete some files ._ files
# Remove the file metadata included in TAR files
gci . -r -include ._* -force | remove-item -r -force
# Remove SVN files from a project directory tree
# http://stackoverflow.com/questions/2210193/powershell-how-to-recursivelly-delete-all-svn-files
gci . -r -include .svn -force | remove-item -r -force