Skip to content

Instantly share code, notes, and snippets.

View kmiyashiro's full-sized avatar
🐻

Kelly Miyashiro kmiyashiro

🐻
View GitHub Profile
@behe
behe / app_store_server_notifications_v2_validation.livemd
Created February 14, 2022 07:39
Apple App Store Server Notifications v2 validation

Apple App Store Server Notifications v2 validation

Background

I recently had to upgrade our backend's handling of App Store Server Notifications to the new v2 version. The old version had pretty basic security by only having a supplied password in the response that you verified with what you had configured it to be in App Store Connect. The new version on the other hand is now in JWS (JSON Web Signature) signed with an Apple X.509 certificate chain. Since it was not straight forward to figure out how to verify this certificate chain and signature I wanted to write down how I was able to do it in Elixir:

The following steps are needed to verify the notifications:

#!/bin/bash
echo "Generating an SSL private key to sign your certificate..."
openssl genrsa -des3 -out default.key 1024
echo "Generating a Certificate Signing Request..."
openssl req -new -key default.key -out default.csr
echo "Removing passphrase from key (for nginx)..."
cp default.key default.key.org
openssl rsa -in default.key.org -out default.key
@natelandau
natelandau / bootstrapNewMac
Created January 24, 2017 14:45
A bootstrap script to install my dotfiles and configure a new computer
#!/usr/bin/env bash
# This bootstraps installing ssh-keys to github
# set colors
if tput setaf 1 &> /dev/null; then
tput sgr0
if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then
ORANGE="$(tput setaf 172)"
else
@okonet
okonet / package.json
Created November 20, 2016 18:48
Automatic yarn updates as a post-checkout hook
{
"devDependencies": {
"ghooks": "^1.3.2"
},
"config": {
"ghooks": {
"post-checkout": "./script/yarn-update.hook.sh $2 $3"
}
}
}
@elithrar
elithrar / history.js
Last active January 10, 2016 14:03
smartScroll for Ember.js - reset the scroll position on forward transitions you haven't previously visited - via @rwjblue on embercommunity.slack.com
// app/locations/history.js
export default Ember.HistoryLocation.extend({
pushState() {
this._super(...arguments);
window.scrollTo(0, 0);
}
});
```​
@cyk
cyk / ember-data.dependent-relations.js
Last active December 12, 2020 21:17 — forked from slindberg/ember-data.dependent-relations.js
Dependent Relationships in Ember Data (for Ember Data v1.13.x)
/**
Ember Data: Dependent Relationships (Ember Data v1.13.x)
This package extends Ember Data to support creating relationships
where a model's dirty state depends not only on its own attributes
but on the dirty state of models in dependent relationships as well.
```javascript
App.Thing = DS.Model.extend({
name : DS.attr('string'),
@henrik
henrik / dokku_on_digital_ocean.md
Last active May 12, 2022 14:38
Notes from running Dokku on Digital Ocean.

My notes for Dokku on Digital Ocean.

These may be a bit outdated: Since I originally wrote them, I've reinstalled on a newer Dokku and may not have updated every section below.

Commands

Install dokku-cli (gem install dokku-cli) for a more Heroku-like CLI experience (dokku config:set FOO=bar).

# List/run commands when not on Dokku server (assuming a "henroku" ~/.ssh/config alias)

ssh henroku dokku

'use strict';
module.exports = function CustomError(message, extra) {
Error.captureStackTrace(this, this.constructor);
this.name = this.constructor.name;
this.message = message;
this.extra = extra;
};
CustomError.prototype = Object.create(Error.prototype);
@justmoon
justmoon / custom-error.js
Last active April 22, 2024 17:19 — forked from subfuzion/error.md
Creating custom Error classes in Node.js
'use strict';
module.exports = function CustomError(message, extra) {
Error.captureStackTrace(this, this.constructor);
this.name = this.constructor.name;
this.message = message;
this.extra = extra;
};
require('util').inherits(module.exports, Error);
@supinf
supinf / s3-invalidation.js
Last active January 7, 2023 08:57
AWS Lambda script:: CloudFront Invalidations which are triggered by s3 events.
console.log('Loading event');
var Q = require('q');
var aws = require('aws-sdk');
var cloudfront = new aws.CloudFront();
exports.handler = function (event, context) {
//_log('Received event: ', event);
var bucket = event.Records[0].s3.bucket.name;