Skip to content

Instantly share code, notes, and snippets.

View dingus9's full-sized avatar

Nick Shobe dingus9

  • Rackspace
  • San Antonio
View GitHub Profile
@dingus9
dingus9 / util.sh
Created July 25, 2018 23:45
Bash util functions
pathadd() {
# Add a bin to path if it isn't there already
if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]];
then
if [ "$2" == "pre" ];
then
PATH="$1:$PATH";
else
PATH="${PATH:+"$PATH:"}$1";
fi
@dingus9
dingus9 / sudo.bat
Created September 25, 2016 18:47
sudo for windows and mintty
@echo off
:: BatchGotAdmin
:-------------------------------------
REM --> Check for permissions
IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" (
>nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system"
) ELSE (
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
)
import csv
with open('other_list.txt', 'r') as other_list:
sublist_something = other_list.readlines()
complete_list = {}
with open('master_list.txt', 'r') as master_list:
for account_id in master_list.readlines():
complet_list[account_id] = {}
if account_id in sublist_something:
@dingus9
dingus9 / samlparser.py
Created June 1, 2015 04:03
Python SAML parser and validator
from base64 import b64decode
from defusedxml.lxml import fromstring
from signxml import xmldsig
class SAMLParser(object):
def __init__(self, rawresp):
self.b64 = rawresp
@dingus9
dingus9 / gist:11259354
Created April 24, 2014 15:43
Overridable implementation of an attrdict type
# Why cls_state... cls_state is a portable attrdict
class EncoreClsDict(dict):
"""This is an attrdict implementation that provides:
* property access for dict elements
* overrides for properties
*
* Override getitem, setitem, getattr, and setattr to provide the following behaviors:
@property decorators take precidence over dict items... and are always called.
@prop.setter decorators take precidence and can call self['key'] to set dict vals.
self.cls_properties['key'] to prevent key from being auto saved self['key']
curl -iXPUT -H "X-Auth-Token: <REDACTED - valid customer auth token>" -H "Content-Type: application/json" https://monitoring.api.rackspacecloud.com/v1.0/500694/entities/enbm7RGWHg -d '{"label": "piranha01"}'
HTTP/1.1 400 Bad Request
Date: Fri, 25 Oct 2013 08:53:45 GMT
Content-Type: application/json; charset=UTF-8
X-RateLimit-Limit: 50000
X-RateLimit-Remaining: 49507
X-RateLimit-Window: 24 hours
X-RateLimit-Type: global
X-Response-Id: .rh-pnCO.h-ord1-maas-prod-api1.r-gKVCgFlG.c-1488591.ts-1382691225421.v-ad1fc41
X-LB: ord1-maas-prod-api1