Skip to content

Instantly share code, notes, and snippets.

View russellballestrini's full-sized avatar
💭
https://ai.untuf.com

Russell russellballestrini

💭
https://ai.untuf.com
View GitHub Profile
@pypt
pypt / pyyaml-duplicates.py
Created September 9, 2015 22:10
PyYAML: raise exception on duplicate keys on the same document hierarchy level
import yaml
from yaml.constructor import ConstructorError
try:
from yaml import CLoader as Loader
except ImportError:
from yaml import Loader
def no_duplicates_constructor(loader, node, deep=False):
@mmerickel
mmerickel / cors.py
Last active December 6, 2022 14:13
cors in pyramid
from pyramid.security import NO_PERMISSION_REQUIRED
def includeme(config):
config.add_directive(
'add_cors_preflight_handler', add_cors_preflight_handler)
config.add_route_predicate('cors_preflight', CorsPreflightPredicate)
config.add_subscriber(add_cors_to_response, 'pyramid.events.NewResponse')
class CorsPreflightPredicate(object):
@oztune
oztune / linkpeek.js
Last active December 11, 2015 02:10
Node.js script for generating Link Peek urls
function linkPeek(apiKey, secret) {
return function getUrl(uri, queryParams) {
queryParams = Object.assign({
size: 'original'
}, queryParams)
const token = md5(secret + uri + queryParams.size)
const extraParams = queryParams && Object.keys(queryParams).map(param => `${param}=${encodeURIComponent(queryParams[param])}`).join('&')
return `https://linkpeek.com/api/v1?uri=${encodeURIComponent(uri)}&apikey=${apiKey}&token=${token}${extraParams ? `&${extraParams}` : ''}`
@brianbruggeman
brianbruggeman / LICENSE
Last active April 23, 2025 17:20
Convert Viscosity to Open VPN
Public Domain
@gleicon
gleicon / list_objects_google_storage_boto3.py
Last active February 12, 2025 11:40
How to use boto3 with google cloud storage and python to emulate s3 access.
from boto3.session import Session
from botocore.client import Config
from botocore.handlers import set_list_objects_encoding_type_url
import boto3
ACCESS_KEY = "xx"
SECRET_KEY = "yy"
boto3.set_stream_logger('')
@lbernail
lbernail / ebsnvme-id
Created April 26, 2018 15:07
ebsnvme-id script
#!/usr/bin/env python2.7
# Copyright (C) 2017 Amazon.com, Inc. or its affiliates.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://aws.amazon.com/apache2.0/
@russellballestrini
russellballestrini / sts2env
Last active August 2, 2022 14:37
Configure your shell with temporary AWS environment variables from
#!/usr/bin/env python
"""
How to use:
eval $(eval "aws sts assume-role --role-arn arn:aws:iam::0123456789:role/the-role-name --role-session-name my-aws-prod | ./sts2env")
Then run `env` and you should see the environment vars in your shell.
"""