An introduction to curl
using GitHub's API.
Makes a basic GET request to the specifed URI
curl https://api.github.com/users/caspyin
Includes HTTP-Header information in the output
import code; code.interact(local=dict(globals(), **locals())) |
#!/bin/bash | |
# bash functions to autenticate and assume roles in aws federated accounts | |
# required tools on $PATH - aws, date, curl, jq, libxml2-utils | |
# requried environment variables: | |
export AWS_CLI=`which aws` | |
# optional environment variable, to automatically assume a specific role when calling assume() | |
# AWS_ASSUME_ROLE=arn:aws:iam::369407384105:role/cross-account-federated-role |
An introduction to curl
using GitHub's API.
Makes a basic GET request to the specifed URI
curl https://api.github.com/users/caspyin
Includes HTTP-Header information in the output
Our goal is to run python -c "import caffe"
without crashing. For anyone who doesn't spend most of their time with build systems, getting to this point can be extremely difficult on OS X. Instead of providing a list of steps to follow, I'll try to explain why each step happens.
This page has OS X specific install instructions.
I assume:
#! /usr/bin/env python | |
import logging | |
""" | |
I never remember all the steps for setting up logging in python. | |
This gist goes through the steps so I can copy and paste what I need. | |
""" | |
# create logger on the current module and set its level | |
logger = logging.getLogger(__file__) |
# Compare four methods for computing the R-squared (R2, coefficient of determination) | |
# with wieghted observations for a linear regression model in R. | |
# This work was written by Daniel Himmelstein (@dhimmel) with guidance | |
# from Alex Pankov (@a-pankov). It is released as CC0 (public domain). | |
get_r2_cor <- function(y, y_pred, w) { | |
# Calculate R2 using the correlation coefficient method | |
xy = cbind(y, y_pred) | |
return(boot::corr(d=xy, w=w) ^ 2) | |
} |
__author__ = 'dkarchmer' | |
''' | |
This script emulates a stand-alone Python based client. It relies on Boto3 to access AWS, but | |
requires your Django server to have an API for your user to access Cognito based credentials | |
Because of Cognito, the client (this script) will only get temporary AWS credentials associated | |
to your user and only your user, and based on whatever you configure your AIM Policy to be. | |
Most Cognito examples demonstrate how to use Cognito for Mobile Apps, so this scripts demonstrate | |
how to create a stand-alone Python script but operating similarly to these apps. |
############# | |
### SETUP ### | |
############# | |
# Set up remote session | |
$Credential = Get-Credential TestUser | |
$AdminCred = Get-Credential Administrator | |
$SessionOption = New-CimSessionOption -Protocol Dcom | |
$CimSession = New-CimSession -Credential $Credential -ComputerName TestPC -SessionOption $SessionOption | |
$AdminCimSession = New-CimSession -Credential $AdminCred -ComputerName TestPC -SessionOption $SessionOption |
AWS have released a new featue called CloudWatch Events, which lets you configure events fired by cloudwatch and direct them to SNS, Lambda functions, etc. Here's the blog post
Here's the motivational image:
The security group and Network ACLs parts of CloudFormation templates can be difficult to read. This template containing Jinja macros converts easier-to-read YAML dictionaries of security group and NACL rules into JSON.
Here ais a generic macro template and some example files showing how to use it.