Skip to content

Instantly share code, notes, and snippets.

milancermak / app-session.ts
Last active May 13, 2021
Custom session storage for a Shopify app in SQL using Prisma
View app-session.ts
import { PrismaClient } from '@prisma/client'
import Shopify from '@shopify/shopify-api'
import { Session } from '@shopify/shopify-api/dist/auth/session';
const prisma = new PrismaClient({ log: ['info', 'warn', 'error'] })
async function storeCallback(session: Session): Promise<boolean> {
const payload: { [key: string]: any } = { ...session }
return prisma.appSession.upsert({
create: { id:, payload: payload },
milancermak /
Created Mar 7, 2019
Experiments with DynamoDB and Connection HTTP headers
import json
import os
import time
import uuid
import boto3
def set_connection_header(request, operation_name, **kwargs):
# request.headers['Connection'] = 'keep-alive'
View buildspec_container.yml
version: 0.2
- $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email)
- IMAGE_TAG="${COMMIT_HASH:=latest}"
- printenv
milancermak / timeout.swift
Created Jan 30, 2019
Set custom request timeout for AWSLambdaInovker
View timeout.swift
// my swift is a little bit rusty, hope this works
let configuration = AWSServiceManager.defaultServiceManager().defaultServiceConfiguration.copy();
configuration.timeoutIntervalForRequest = 90;
AWSLambdaInvoker.register(with: configuration!, forKey: "USWest2LambdaInvoker")
let lambdaInvoker = AWSLambdaInvoker(forKey: "USWest2LambdaInvoker")
// lambdaInvoker.invokeFunction ...
milancermak /
Created Jun 14, 2018
Streaming upload of a file directly to S3 in AWS Lambda
from botocore.vendored import requests
import boto3
def main(event, context):
s3 = boto3.resource('s3')
bucket = s3.Bucket('mybucket')
destination = bucket.Object('path/to/destination')
url = ''
class NotReadyError(Exception):
Custom exception signaling to the Step Function
that it cannot move to the next state. Instead,
the Retry block is triggered, pausing the process.
You can pass details about the progress as a
string when initializing it. It will be shown
in the SF console.
milancermak / classMethodIntrospection.swift
Created Dec 21, 2015
A way how to introspect methods in Swift at runtime
View classMethodIntrospection.swift
var methodCount: UInt32 = 0
let methods = class_copyMethodList(anInstance.dynamicType, &methodCount) // replace anInstace
for i in 0..<Int(methodCount) {
NSLog("method: \(NSStringFromSelector(method_getName(methods[i])))")
milancermak / gist:e0b959a5195d28133a1f
Created Dec 4, 2014
Drawing a dashed line on GoogleMaps for iOS
View gist:e0b959a5195d28133a1f
- (void)drawDashedLineOnMapBetweenOrigin:(CLLocation *)originLocation destination:(CLLocation *)destinationLocation {
[self.mapView clear];
CGFloat distance = [originLocation distanceFromLocation:destinationLocation];
if (distance < kMinimalDistance) return;
// works for segmentLength 22 at zoom level 16; to have different length,
// calculate the new lengthFactor as 1/(24^2 * newLength)
CGFloat lengthFactor = 2.7093020352450285e-09;
CGFloat zoomFactor = pow(2, + 8);
milancermak / gist:5775152
Created Jun 13, 2013
Question about combining signals in ReactiveCocoa
View gist:5775152
@interface LoginViewController ()
@property (strong, nonatomic) RACSubject *textFieldReturnPressed;
@property (strong, nonatomic) UITextField *usernameTextField;
@property (strong, nonatomic) UITextField *passwordTextField;
@implementation LoginViewController
milancermak / gist:4518064
Last active Dec 11, 2015
An example of a good error message coming from an HTTP API (illustrative for
View gist:4518064
HTTP/1.1 402 Payment Required
Content-Type: application/json
"title": "End of trial",
"description": "Unfortunately, your trial period has ended. To continue using the application, you need to purchase a subscription.",
"explanation_url": "",
"trace_url": ""