Skip to content

Instantly share code, notes, and snippets.

View christianklotz's full-sized avatar

Christian Klotz christianklotz

View GitHub Profile
@christianklotz
christianklotz / gcp-template-bucket-custom.jinji
Created June 19, 2018 17:16
Google Cloud Deployment Manager template creating bucket with custom service account
resources:
# Bucket to hold all asset
- name: {{ properties['bucket-prefix'] }}-assets
type: storage.v1.bucket
accessControl:
gcpIamPolicy:
bindings:
- role: roles/storage.objectAdmin
members:
@christianklotz
christianklotz / aws-cloudformation-resource-name-limit.md
Last active July 18, 2018 19:04
AWS CloudFormation resource name character limit

Using custom resource names in CloudFormation can potentially cause resources' physical ids to exceed the allowed limit of 64 characters. Especially with nested stacks, as AWS::CloudFormation::Stack does not support custom names causing nested stacks to always be named automatically in the format <logical-id>-XXXXXXXXXXXX, with XXXXXXXXXXXX being a autogenerated identifier.

Below is an example of AWS::Lambda::Function within a nested CloudFormation stack.

With functionName

Physical resource id is generated using the following format.

<root-stack-name>-XXXXXXXXXXXX-<lambda-function-name>

Quickly exceeds max length 64 characters.

@christianklotz
christianklotz / sketch-load-json.js
Created March 19, 2019 15:59
Load JSON file into Sketch
let readBinaryFile = (filepath) => {
return NSData.alloc().initWithContentsOfFile(filepath);
};
let path = "path/to/file.json"
let data = readBinaryFile(path)
let contents = NSString.alloc().initWithData_encoding(data, NSUTF8StringEncoding)
console.log(JSON.parse(contents))
@christianklotz
christianklotz / sketch-organisation-assistant.ts
Created July 21, 2020 16:00
Create Sketch Assistant using existing rules
/**
Simple Assistant setting exactly one rule, limiting the number of layers that should be
allowed per group. The rule is provided by the Sketch Core Assistant.
1. Use Assistant Template from https://github.com/sketch-hq/sketch-assistant-template/
2. Find and replace all `sketch-assistant-template` with `sketch-organisation-assistant`
3. Install dependencies and add Core Assistant
npm install
@christianklotz
christianklotz / sketch-comic-assistant.ts
Last active July 21, 2020 16:29
Create Sketch Assistant writing a custom rule
/**
Simple Assistant setting exactly one rule that ensures text layers are only using
specific fonts, in this case set to Comic Sans and Cochin.
1. Use Assistant Template from https://github.com/sketch-hq/sketch-assistant-template/
2. Find and replace all `sketch-assistant-template` with `sketch-comic-assistant`
3. Install dependencies
npm install
@christianklotz
christianklotz / aws-template-bucket-custom-acl.yaml
Created June 19, 2018 17:30
CloudFormation template to create S3 bucket resource with custom role
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Parameters:
BucketPrefix:
Type: String
Description: "The prefix used for all S3 buckets."
AllowedPattern: "[a-z-]+"
Resources:
@christianklotz
christianklotz / ios-default-fontsize-table.swift
Created February 2, 2016 16:42
List of default font sizes for dynamic type
let defaultFontSizeTable = [
UIFontTextStyleHeadline: [
UIContentSizeCategoryAccessibilityExtraExtraExtraLarge: 26,
UIContentSizeCategoryAccessibilityExtraExtraLarge: 25,
UIContentSizeCategoryAccessibilityExtraLarge: 24,
UIContentSizeCategoryAccessibilityLarge: 24,
UIContentSizeCategoryAccessibilityMedium: 23,
UIContentSizeCategoryExtraExtraExtraLarge: 23,
UIContentSizeCategoryExtraExtraLarge: 22,
UIContentSizeCategoryExtraLarge: 21,