Skip to content

Instantly share code, notes, and snippets.

@jamesls
jamesls / alias
Last active Oct 8, 2021
AWS CLI v2 upgrade aliases.
View alias
[toplevel]
# Put this in ~/.aws/cli/alias
# and you'll have an "aws upgrade"
# and an "aws check-upgrade" command.
#
# Only works on macOS and installs using
# the .pkg installer.
#
upgrade = !f() {
curl -s "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "/tmp/AWSCLIV2.pkg"
View gist:08a79968d11271a1895d401dbd096e2c
$ aws ec2 describe-regions --output for-real-xml
<?xml version="1.0" ?>
<response>
<Regions>
<item>
<Endpoint>ec2.eu-north-1.amazonaws.com</Endpoint>
<RegionName>eu-north-1</RegionName>
<OptInStatus>opt-in-not-required</OptInStatus>
</item>
<item>
View gist:c80880fb7df39bc33ef4d30aca7d6995
Given this app.py
from chalice import Chalice
app = Chalice(app_name='sam-compare')
@app.authorizer()
def myauth(auth_event):
return None
@jamesls
jamesls / test_s3_combinations.py
Last active Mar 23, 2018
One off integ test to verify head object behavior
View test_s3_combinations.py
# -*- coding: utf-8 -*-
import botocore.session
from botocore.exceptions import ClientError
import logging
import pytest
LOG = logging.getLogger('botocore.tests.integration')
session = botocore.session.get_session()
View keybase.md

Keybase proof

I hereby claim:

  • I am jamesls on github.
  • I am jamesls (https://keybase.io/jamesls) on keybase.
  • I have a public key ASCDOSbobSCCeNzUGODTUjSWyXq191v8lTIFsXrHn0lTtwo

To claim this, I am signing this object:

View seekable?
$ python3 -c 'import sys; print("Seekable:", sys.stdin.seekable())'
Seekable: True
$ echo hello | python3 -c 'import sys; print("Seekable:", sys.stdin.seekable())'
Seekable: False
@jamesls
jamesls / sqlite-threads.py
Last active Feb 2, 2022
Making sqlite slower in python by using threads:
View sqlite-threads.py
import os
import time
import sqlite3
import threading
conn = None
def create_table():
@jamesls
jamesls / gen-inflections.py
Created Oct 26, 2015
Show all inflections used in botocore
View gen-inflections.py
#!/usr/bin/env python
import botocore.session
from botocore import xform_name
import time
# Original -> xform'd
all_params = {}
total_time = 0
View gist:e73d0adf20c6460369be
$ make test
go test -v ./...
? github.com/jmespath/jmespath.go/cmd/jp [no test files]
=== RUN TestCompliance
Best: a
--- PASS: TestCompliance (0.02s)
=== RUN TestCanLexTokens
--- PASS: TestCanLexTokens (0.00s)
=== RUN TestLexingErrors
--- PASS: TestLexingErrors (0.00s)
@jamesls
jamesls / async-confusing.py
Created Mar 28, 2015
Asyncio and coroutines confusion
View async-confusing.py
import asyncio
@asyncio.coroutine
def coro():
return "foo"
# Writing the code without a list comp works,
# even with an asyncio.sleep(0.1).
@asyncio.coroutine