Skip to content

Instantly share code, notes, and snippets.

View etataurov's full-sized avatar

Eugene Tataurov etataurov

  • Amsterdam, The Netherlands
View GitHub Profile
@heitorlessa
heitorlessa / presign_url.py
Created January 11, 2017 16:11
Quick and dirty S3 Presign URL using Python Boto3 and Click
import boto3
import click
@click.command()
@click.argument("bucket")
@click.argument("key")
@click.option("-e", "--expiration", default=3600, type=int, help="How long this presigned URL will live for")
def presign_s3(bucket, key, expiration):
""" Simple utility to generate presigned URL on S3 (Default 1 hour expiration)
@gene1wood
gene1wood / role_arn_to_session.py
Created December 29, 2016 17:38
Simple python function to assume an AWS IAM Role from a role ARN and return a boto3 session object
import boto3
def role_arn_to_session(**args):
"""
Usage :
session = role_arn_to_session(
RoleArn='arn:aws:iam::012345678901:role/example-role',
RoleSessionName='ExampleSessionName')
client = session.client('sqs')
"""
@matangover
matangover / Compiling Python with custom OpenSSL on Heroku.md
Last active June 14, 2020 19:24
Instructions for compiling Python with custom OpenSSL on Heroku

Prepare a dyno for compilation with the latest OpenSSL

  1. Create a one-off Heroku app (or use an existing one) for the compilation.

  2. Set the app to use the Python buildpack with OpenSSL 1.0.2g

    heroku buildpacks:set https://github.com/yuvadm/heroku-buildpack-python-openssl-1.0.2.git -a myapp
    
  3. Run a one-off dyno to do the compilation:

@progrium
progrium / 0_demo
Last active February 18, 2016 13:36
11 lines that makes interactively using asyncio libraries nice again
$ python3 -i shellasync.py
>>> import websockets
>>> websockets.connect("ws://localhost:8000/echo")
<websockets.client.WebSocketClientProtocol object at 0x1041a34e0>
>>> ws = _ # only caveat is assignment has to be done after
>>> ws.send("Hello world")
None
>>> ws.recv()
'Hello world'
>>>
@PyYoshi
PyYoshi / _results.txt
Last active August 3, 2018 08:47 — forked from maxpert/results.txt
JSON vs MsgPack using Gzip + LZ4
---------- RAW ----------
JSON 34291 byte(s)
MsgPack 26364 byte(s)
---------- GZIP ---------
JSON 05986 byte(s)
MsgPack 06198 byte(s)
---------- LZ4 ----------
JSON 09758 byte(s)
MsgPack 08548 byte(s)
@yoichitgy
yoichitgy / mergegenstrings.py
Last active July 9, 2022 23:59
A script to generate .strings file for .swift, .m, .storyboard and .xib files by genstrings and ibtool commands, and merge them with existing translations.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Localize.py - Incremental localization on XCode projects
# João Moreno 2009
# http://joaomoreno.com/
# Modified by Steve Streeting 2010 http://www.stevestreeting.com
# Changes
# - Use .strings files encoded as UTF-8
@ShamylZakariya
ShamylZakariya / debounce.swift
Created September 4, 2014 21:01
Simple Swift Debouncer
func debounce( delay:NSTimeInterval, #queue:dispatch_queue_t, action: (()->()) ) -> ()->() {
var lastFireTime:dispatch_time_t = 0
let dispatchDelay = Int64(delay * Double(NSEC_PER_SEC))
return {
lastFireTime = dispatch_time(DISPATCH_TIME_NOW,0)
dispatch_after(
dispatch_time(
DISPATCH_TIME_NOW,
@zemlanin
zemlanin / push.sh
Created August 14, 2014 16:14
push.sh
# send message to your devices via pushover.net API
# add next two or three lines to .bashrc/.zshrc to use this script
# export PUSHOVER_APP="your pushover.net app token"
# export PUSHOVER_USER="your pushover.net user key"
# # optional:
# export PUSHOVER_DEVICE="default device"
# USAGE: push <message> [-d=<device>]
# OPTIONS:
@zemlanin
zemlanin / yop.sh
Created August 14, 2014 16:08
yop.sh
# send yo to your devices via Yo API
# add next line to .bashrc/.zshrc to use this script
# export YO_APP="your justyo.co app token"
# USAGE: yop [link]
__yop(){
local link=$1
local api_url="http://api.justyo.co/yoall/"
@vlasovskikh
vlasovskikh / tweetread.py
Created June 1, 2014 23:26
Actor-based CLI Twitter client example for using asyncio
# Copyright (c) 2014 Andrey Vlasovskikh
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in