Skip to content

Instantly share code, notes, and snippets.

@sirosen
sirosen / gitconfig.md
Last active December 31, 2015 06:49
Simple git alias demo.

Example ~/.gitconfig is given below. In it, I define a simple alias that will print a nice log graph, "logtree". "logtree" is invoked from the commandline as "git logtree". Arguments are passed, so I can do "git logtree --oneline" and get the expected result.

[user]
    name = "Stephen Rosen"
    email = "sirosen@uchicago.edu"
[alias]
    logtree = "log --graph --decorate --all"
[push]
@sirosen
sirosen / attributes.rb
Created September 22, 2015 15:34
ChefAttributesByTagsDemo
default['cookbook']['services']['service1']['source_url'] = 'https://example.com/s1'
default['cookbook']['services']['service2']['source_url'] = 'https://example.com/s2'
default['cookbook']['services']['service3']['source_url'] = 'https://example.com/s3'
default['cookbook']['base_service_set'] = []
default['cookbook']['service_set'] = []
@sirosen
sirosen / vault-dump.rb.erb
Created October 15, 2015 16:25
vault-dump.rb.erb
#!<%= File.join(Chef::Config.embedded_dir, 'bin', 'ruby') %>
require 'chef'
require 'chef-vault'
Chef::Config.from_file('/etc/chef/client.rb')
puts ChefVault::Item.load(ARGV[0], ARGV[1]).to_json
@sirosen
sirosen / bot-harder.txt
Last active June 17, 2016 18:46
joshbot2
legal reasons. ibid. 90. ibid., 17. the university of chicago 258 259 chicago studies some former substantial business building, where a big city of people had lived in general happiness just three days before.24 everything had burned. the sidewalks were gone, and even the streetcar rail was “twisted and warped like dead black snakes in agonies of contortion.”25 loesch saw at least two charred corpses before he reached the river. loesch’s group crossed the chicago river through the lasalle street tunnel. they had to grope through the darkness, amid still-warm bricks. emerging on the other side, elites were concerned that they would be treated the same as the poor by the citizens’ committee, ... but such structures were open to grave objections as the homes of forty or fifty thousand people in the winter. so large a number brought into promiscuous and involuntary association, would almost certainly engender disease and pro- mote idleness, disorder and vice ... to construct barracks for the homeless, therefore,
@sirosen
sirosen / example_client_creds_grant.rst
Last active February 6, 2017 17:53
Example of Globus SDK Client Credentials Grant

Client Credentials Authentication

This is an example of the use of the Globus SDK to carry out an OAuth2 Client Credentials Authentication flow.

The goal here is to have an application authenticate in Globus Auth directly, as itself. Unlike many other OAuth2 flows, the application does not act on behalf of a user, but on its own behalf.

@sirosen
sirosen / server_timing.py
Created April 14, 2017 17:28
Server-Timing header tools
"""
Originally based on Jason Williams' (@jaswilli), timing work for GCSv5 API
"""
from timeit import default_timer as timer
import logging
from flask import g
log = logging.getLogger(__name__)
@sirosen
sirosen / gen_csr.sh
Last active May 5, 2017 12:47
Create a Globus CSR
#!/bin/bash
name="$1"
openssl genrsa -out "$name.key" 2048
openssl req -new -sha256 -key "$name.key" -out "$name.csr" \
-subj "/C=US/ST=Illinois/L=Chicago/O=Globus/OU=Globus/CN=$name/emailAddress=domains@globus.org"
@sirosen
sirosen / shared-funcs.sh
Created May 10, 2017 16:31
Useful bash funcs
# Shell Scripting Functions so that scripting is less sad
# not an executable script -- source me in other scripts!
# always start unset
unset abort_message
# start with default of 0
rc=0
# Abort with message
function abort () {
echo "$abort_message" >&2
@sirosen
sirosen / sign.py
Last active January 25, 2024 20:46
Sign and Verify Using RSA via cryptography (python)
"""
RSA Sign a Message using a private key
Just turns this example into a script:
https://cryptography.io/en/latest/hazmat/primitives/asymmetric/rsa/#signing
"""
import sys
import hashlib
import base64
#!/usr/bin/env python3
"""
python3.5+ ( uses subprocess.run(), added in 3.5 )
USAGE:
>>> from cli_invoker import COMMAND, invoke
>>> cmd = COMMAND.globus('-F', 'JSON')
>>> invoke(cmd.whoami)