Skip to content

Instantly share code, notes, and snippets.

View pkazmierczak's full-sized avatar
🏋️‍♂️
at the gym.

Piotr Kazmierczak pkazmierczak

🏋️‍♂️
at the gym.
View GitHub Profile
@pkazmierczak
pkazmierczak / main.py
Last active January 2, 2018 13:22
lambda function for automatic whitelisting of AWS IPs on an SG (python3), see https://spin.atomicobject.com/2016/03/01/aws-cloudfront-security-group-lambda/ for the original
import copy
import json
from urllib.request import urlopen
import boto3
def handle(event, context):
response = urlopen('https://ip-ranges.amazonaws.com/ip-ranges.json')
json_data = json.loads(response.read())

Keybase proof

I hereby claim:

  • I am pkazmierczak on github.
  • I am pkazmierczak (https://keybase.io/pkazmierczak) on keybase.
  • I have a public key whose fingerprint is 8249 E5DB A08C 3726 18E0 D50E CB0E 4C33 F6A3 9502

To claim this, I am signing this object:

@pkazmierczak
pkazmierczak / asw-csgo.yaml
Last active April 1, 2020 11:18
CounterStrike Global Offensive linux server AWS CF template
---
AWSTemplateFormatVersion: '2010-09-09'
Description: CounterStrike Global Offensive linux server template
Mappings:
AWSRegion2AMI:
eu-central-1:
AMI: ami-26c43149
eu-west-1:
AMI: ami-ed82e39e
Parameters:
package main
import (
"fmt"
"time"
)
var c = make(chan int)
func factorial(name string, number int) {
import trollius as asyncio
from trollius import From
@asyncio.coroutine
def factorial(name, number):
f = 1
for i in range(2, number + 1):
print("Task %s: Compute factorial(%d)..." % (name, i))
yield From(asyncio.sleep(1))
@pkazmierczak
pkazmierczak / waf.py
Created January 28, 2016 13:29
WAF IPSet with troposphere
from troposphere import Template
from troposphere.waf import IPSet
t = Template()
t.add_description("CF Template for setting IP ranges for whitelisting on the WAF.")
Whitelist1 = t.add_resource(IPSet(
"internaladdresses",
Name="Internal_addresses",
@pkazmierczak
pkazmierczak / async-python.py
Last active November 23, 2022 09:49
asyncio example (python3 & python2)
import asyncio
@asyncio.coroutine
def factorial(name, number):
f = 1
for i in range(2, number + 1):
print("Task %s: Compute factorial(%d)..." % (name, i))
yield from asyncio.sleep(1)
f *= i
@pkazmierczak
pkazmierczak / iam.json
Created January 12, 2016 12:31
AWS IAM policy for allowing access to all but the specified resources
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1452600517000",
"Effect": "Allow",
"Action": [
"s3:*"
],
"NotResource": [
@pkazmierczak
pkazmierczak / aws-openvpn-cf.py
Last active April 12, 2016 14:44
Troposphere template for creating a simple OpenVPN server Raw
from troposphere import (Base64, Join, FindInMap,
Parameter, Ref, Tags, Template)
import troposphere.ec2 as ec2
# Mappings of OpenVPN AMIs
OPENVPN_AMI = {
'ap-northeast-1': {"AMI": 'ami-5ea72b5e'}, # Asia Pacific (Tokyo)
'ap-southeast-1': {"AMI": 'ami-365c5764'}, # Asia Pacific (Singapore)
'ap-southeast-2': {"AMI": 'ami-831d51b9'}, # Asia Pacific (Sydney)
@pkazmierczak
pkazmierczak / aws-openvpn-cf.json
Last active December 15, 2019 20:03
Cloudformation template for creating a simple OpenVPN server
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "OpenVPN server template",
"Mappings": {
"AWSRegion2AMI": {
"ap-northeast-1": {
"AMI": "ami-5ea72b5e"
},
"ap-southeast-1": {
"AMI": "ami-365c5764"