Skip to content

Instantly share code, notes, and snippets.

View zrzka's full-sized avatar
👓
Trying to do something

Robert Vojta zrzka

👓
Trying to do something
View GitHub Profile
@zrzka
zrzka / dynamo.py
Created March 28, 2017 22:48
Find DynamoDB table name in nested stack(s)
from .stack import find_stack, stack_resource_summary
def dynamodb_table_name(*logical_ids):
table_logical_id = logical_ids[-1]
stack_logical_ids = logical_ids[:-1]
stack = find_stack(stack_logical_ids)
resource = stack_resource_summary(stack, table_logical_id, 'AWS::DynamoDB::Table')
return resource.physical_resource_id
@zrzka
zrzka / info.md
Last active July 27, 2017 13:34
External screen support for Pythonista
@zrzka
zrzka / drag_provider.py
Last active September 5, 2017 10:01
Pythonista & Working Copy Drag & Drop Experiments
import ui
from objc_util import ObjCClass, ObjCInstance, ns, create_objc_class, on_main_thread, ObjCBlock
from ctypes import c_void_p, CFUNCTYPE, Structure, cast, c_int, c_ulong, c_char_p, POINTER
import editor
import os
import zipfile
ASYNC = True
DRAG_PATH = editor.get_path() # Drag itself, ie. drag_provider.py
# DRAG_PATH = os.path.expanduser('~/Documents/Examples') # Drag ZIPpped folder
@zrzka
zrzka / lambda-remove-versions.py
Created October 10, 2017 18:46
Quick hack to remove all lamba function versions except X latest ones
#!/usr/bin/env python3
import os
import boto3
from boto3.session import Session
import argparse
session = Session()
client = session.client('lambda')
@zrzka
zrzka / CIImage.properties.txt
Last active October 20, 2017 19:37
Image properties
{
ColorModel = RGB;
DPIHeight = 72;
DPIWidth = 72;
Depth = 8;
Orientation = 1;
PixelHeight = 960;
PixelWidth = 1280;
ProfileName = "sRGB IEC61966-2.1";
"{ExifAux}" = {
#!python3
import unittest
import notification
# https://github.com/omz/Pythonista-Issues/issues/21
class TestScheduledNotifications(unittest.TestCase):
delay = 300 # Keep it in the distant future, so, it won't fire during tests
@zrzka
zrzka / autolayout.py
Last active January 4, 2018 00:06
Pythonista & auto layout
#!python3
import ui
from objc_util import ObjCInstance, ObjCClass, on_main_thread
from enum import Enum
from functools import partial
from collections import defaultdict
_LayoutConstraint = ObjCClass('NSLayoutConstraint')
@zrzka
zrzka / README.md
Last active January 29, 2018 21:16
Pythonista Forum Post Copy Code
  • Copy forum-post-copy-code.py script into the Pythonista
  • Go to Settings - Share Extension Shortcuts
  • Tap on + button and add forum-post-copy-code.py there
  • Open Safari, visit forum, find a topic & post with some code
  • Make sure that URL ends with /NUMBER, like /5, /6, ... (it's a post number)
  • Tap on action button in Safari
  • Tap on Run Pythonista Script
  • Tap on shortcut you did previously add
  • All code elements are copied to the clipboard
@zrzka
zrzka / imgur-upload.py
Created February 1, 2018 09:09
Imgur Upload
#!python3
import base64
import json
import appex
import clipboard
import objc_util
import photos
import requests
@zrzka
zrzka / tile-game.py
Last active February 2, 2018 11:00
Tiles
import math
from scene import run, Scene, LabelNode, SpriteNode, Size, Point, Texture, Action
import secrets
from enum import Enum
class Direction(tuple, Enum):
UP = (-1, 0) # 1 row up, no column change