Skip to content

Instantly share code, notes, and snippets.

View jkrnak's full-sized avatar

Janos Krnak jkrnak

  • Budapest, Hungary
View GitHub Profile
@jkrnak
jkrnak / example CORS response
Last active September 14, 2018 13:40
example CORS response to allow www.example.com to access resources on the server
< HTTP/2 200
< access-control-allow-methods: GET, PUT, POST, DELETE
< access-control-allow-origin: www.example.com
@jkrnak
jkrnak / log-policy.json
Last active November 21, 2018 15:37
Allow full access to logs
{
"Version": "2012-10-17",
"Statement": [ {
"Action": ["logs:*"],
"Effect": "Allow",
"Resource": "*"
} ]
}
@jkrnak
jkrnak / trust-policy.json
Last active November 21, 2018 15:40
Trust policy for Lambda@Edge
{
"Version": "2012-10-17",
"Statement": [ {
"Effect": "Allow",
"Principal": {
"Service": ["lambda.amazonaws.com", "edgelambda.amazonaws.com" ]
},
"Action": "sts:AssumeRole"
} ]
}
@jkrnak
jkrnak / serverless.yml
Created November 21, 2018 17:25
Create Lambda@Edge project
service: LambdaAtEdge
provider:
name: aws
runtime: nodejs8.10
region: us-east-1
resources:
Resources:
LambdaAtEdgeRole:
@jkrnak
jkrnak / dotenv.tmpl
Last active December 16, 2018 13:20
Confd example
# /etc/confd/templates/dotenv.tmpl
PASSWORD={{getv "/client-api/database/password"}}
USER={{getv "/client-api/database/user"}}
MAPS_API_KEY={{getv "/client-api/maps/api/key"}}
@jkrnak
jkrnak / xps_15_9570__dualboot_with_encryption__notes.md
Created June 15, 2019 14:54 — forked from mdziekon/xps_15_9570__dualboot_with_encryption__notes.md
XPS 15 9570 - DualBoot with Encryption (Windows 10 with BitLocker + Ubuntu 18.04 with LVM on LUKS)
  • Based on https://askubuntu.com/a/293029/286776
  • Installation date: 15-09-2018
  • Additional notes based on my own experience
  • The process describes a completely fresh installation with a complete repartitioning, however it should work fine when Windows is already installed (eg. brand new machine with Windows preinstalled).
  • The process was conducted on Dell's XPS 15 9570 (2018) with specs:
    • CPU: i7-8750H
    • Screen: 4K with Touch
    • RAM: 16 GB (original) / 32 GB (manually upgraded)
  • Drive: 512 GB (SK Hynix PC401)
@jkrnak
jkrnak / handler.js
Last active April 6, 2021 12:30
Example Lambda@Edge function to add cache control header to assets
// Lambda function to set cache control public header in case of missing cache control header
exports.handler = (event, context, callback) => {
const { response } = event.Records[0].cf;
const { headers } = response;
const headerCacheControl = 'Cache-Control';
const defaultTimeToLive = 60 * 60 * 24 * 14; // 14 days
if (response.status === '200') {
if (!headers[headerCacheControl.toLowerCase()]) {