Skip to content

Instantly share code, notes, and snippets.

View mredar's full-sized avatar

Mark Redar mredar

  • CDL
  • Oakland, CA
View GitHub Profile
@mredar
mredar / gist:5681352
Last active September 26, 2019 11:41
Decoding unpadded base64 data (e.g. SQS messages) in python. You need to pad out the string, found this snippet on: http://stackoverflow.com/questions/2941995/python-ignore-incorrect-padding-error-when-base64-decoding
>>> import base64
>>> s='eyJ1cmwiOiAiaHR0cDovL2RpZ2l0YWwyLmxpYnJhcnkudWNsYS5lZHUvb2FpMl8wLmRvIiwgI
nNldF9zcGVjIjogImFpZHNwb3N0ZXJzIiwgImNhbXB1cyI6IFt7InNsdWciOiAiVUNMQSIsICJuYW1lI
jogIlVDTEEiLCAicmVzb3VyY2VfdXJpIjogIi9hcGkvdjEvY2FtcHVzLzEwLyJ9XX0'
>>> d=base64.b64decode(s)
Traceback (most recent call last):
...
TypeError: Incorrect padding
>>> d=base64.decodestring(s + '='*(-len(s) % 4))
>>> d
@mredar
mredar / gist:6033503
Created July 18, 2013 22:00
Ignore certificates in git
export GIT_SSL_NO_VERIFY=true
git <xxxx>
or env GIT_SSL_NO_VERIFY=true git <xxx>
@mredar
mredar / ec2-ips
Last active December 19, 2015 23:18
IP addresses for ec2 instance
To determine your instance's IP addresses using instance metadata
Connect to the instance.
Use the following command to access the private IP address:
GET http://169.254.169.254/latest/meta-data/local-ipv4
Use the following command to access the public IP address:
@mredar
mredar / resourcelist.xml
Created October 9, 2013 16:34
Resourcelist sample v0.0. For harvesting of metadata and associated asset urls into the UCLDC solr instance. This is a bare minimum.
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:rs="http://www.openarchives.org/rs/terms/">
<rs:ln rel="resourcesync" href="http://example.com/capabilitylist.xml"/>
<rs:md capability="resourcelist" modified="2013-01-03T09:00:00Z"/>
<url>
<!-- this could point directly to the asset if "canonical" used as
well. This will allow for a richer end user experience as we'll be
able to link directly to assets and embed them. -->
<loc>http://example.com/bitstream1.mp4</loc>
@mredar
mredar / self signed SSL cert
Last active January 4, 2016 03:38
self signed ssl cert installed to nginx
openssl genrsa -des3 -out server.key 2048
openssl req -new -key server.key -out server.csr
openssl rsa -in server.key -out server.key.nopass
openssl x509 -req -days 1024 -in server.csr -signkey server.key.nopass -out server.crt
This will produce an base64 encoded ascii file (server.crt) that can be used as a .pem file. Use the server.key.nopass as the server key, so you don't have to enter the password on webserver restarts.
vim /etc/nginx/nginx.conf -- point to it
@mredar
mredar / gist:9218800
Created February 25, 2014 22:01
Substring in bash
#!/bin/bash
zone='us-east-1bx'
len=${#zone}-1
region=${zone:0:$len}
echo "REGION $region"
@mredar
mredar / smtpd-run.py
Created May 1, 2014 00:22
Python stdlib smtpd server, for dev envs
import smtpd
import asyncore
d=smtpd.DebuggingServer(('127.0.0.1', 25), None)
try:
asyncore.loop()
except KeyboardInterrupt:
pass
@mredar
mredar / DockerStartLinks
Last active August 29, 2015 14:03
Links for Docker quick start
@mredar
mredar / ansible-ec2-tips
Last active August 29, 2015 14:04
ec2 ansible tips
never use ec2 - exact_count paramter. This TERMINATED all the running instances except for exact_count number. This can have disatirous results, i hammered the whole cdlib dsc archivesspace server setup in AWs with this option. TODO: NEEDS to be noted in the options docs on this exact_count param.
use stete: present to create a new instance
not sure what state: running causes
always disable api termination
set to NOT DELETE on termination on ALL VOULUMES
TODO: REBUILD FROM SCRATCH: FRONT END WITH APACHE PROXY (due to nginx mangling of paths see: apache directive = <TODO: lookup>
@mredar
mredar / aws-tips.rst
Last active August 29, 2015 14:05
AWS Tips

AWS Tips

EC2

To enable NAT function, you must DISABLE Source/Destination Check to let this happen.

Resize EBS volume