Skip to content

Instantly share code, notes, and snippets.

View AlainODea's full-sized avatar

Alain O'Dea AlainODea

View GitHub Profile
@AlainODea
AlainODea / parse-metadata
Last active June 16, 2017 14:47
Parse SAML 2.0 Federation Metadata with Bash and XPath to get IdP Issuer URI, IdP SSO URL, and IdP Signature Certificate (as a DER-formatted file called idpSigCert.der)
#!/bin/bash
fileOption="$1"
metadataFile="${fileOption:=FederationMetadata.xml}"
idpIssuerId=$(xpath "${metadataFile}" "/*[local-name()='EntityDescriptor']/@entityID" 2>/dev/null)
idpSsoUrl=$(xpath "${metadataFile}" "/*[local-name()='EntityDescriptor']/*[local-name()='IDPSSODescriptor']/*[local-name()='SingleSignOnService' and @Binding='urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST']/@Location" 2>/dev/null)
xpath "${metadataFile}" "/*[local-name()='EntityDescriptor']/*[local-name()='IDPSSODescriptor']/*[local-name()='KeyDescriptor' and @use='signing']/*[local-name()='KeyInfo']/*[local-name()='X509Data']/*[local-name()='X509Certificate']/text()" | base64 --decode > idpSigCert.der 2> /dev/null
cat <<EOF
SAML Protocol Configuration
idpIssuerId=${idpIssuerId}
idpSsoUrl=${idpSsoUrl}
@AlainODea
AlainODea / refToSalesforceLink.hs
Last active July 11, 2016 13:27
Haskell interactive (GHCi/Intero) example of obtaining a Salesforce.com link from an email subject line ref
@AlainODea
AlainODea / poly-aeson.hs
Created May 20, 2016 18:21
SSCCE of using Aeson to decode polymorphic JSON
#!/usr/bin/env stack
-- stack --install-ghc --resolver lts-5.13 runghc --package aeson
{-# LANGUAGE OverloadedStrings #-}
import Data.Aeson
import Data.Aeson.Types
import qualified Data.Text as T
main :: IO ()

Keybase proof

I hereby claim:

  • I am alainodea on github.
  • I am alainodea (https://keybase.io/alainodea) on keybase.
  • I have a public key ASCi9K4NyAy0TWik3h0UX8e3lDtFB_VH68t6IkswitByDgo

To claim this, I am signing this object:

@AlainODea
AlainODea / cabal-macros.h
Created January 10, 2016 17:26
GHC 7.10.3 build fails with cpphs
/* DO NOT EDIT: This file is automatically generated by Cabal */
/* package rts-1.0 */
#define VERSION_rts "1.0"
#define MIN_VERSION_rts(major1,major2,minor) (\
(major1) < 1 || \
(major1) == 1 && (major2) < 0 || \
(major1) == 1 && (major2) == 0 && (minor) <= 0)
/* package ghc-prim-0.4.0.0 */
@AlainODea
AlainODea / cabal-macros.h
Last active January 11, 2016 03:58
GHC 7.10.3 Test Failures on SmartOS
/* DO NOT EDIT: This file is automatically generated by Cabal */
/* package rts-1.0 */
#define VERSION_rts "1.0"
#define MIN_VERSION_rts(major1,major2,minor) (\
(major1) < 1 || \
(major1) == 1 && (major2) < 0 || \
(major1) == 1 && (major2) == 0 && (minor) <= 0)
/* package ghc-prim-0.4.0.0 */
@AlainODea
AlainODea / iam-tag-all-the-things-policy.json
Last active August 12, 2018 16:52
AWS IAM Policy to tag all* the things (*that exist right now)
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"autoscaling:*Tags*",
"codedeploy:*Tags*",
"datapipeline:*Tags*",
"ec2:*Tags*",
@AlainODea
AlainODea / getmac_arp.c
Created June 20, 2014 21:16
@rmustacc's ARP-based retrieval of MAC addresses. Should work on any UNIX-like.
/*
* Test getifaddrs behavior.
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <ifaddrs.h>
#include <stdio.h>
#include <net/if.h>
#include <unistd.h>
@AlainODea
AlainODea / network-unix.c
Last active May 26, 2018 01:21
WIP: MAC-based implementation of maccopy network-unix.c in network-info Haskell package
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include <sys/types.h>
#include <ifaddrs.h>
#include <netdb.h>
#ifdef __linux__
@AlainODea
AlainODea / init.el
Created June 15, 2014 03:24
My Emacs Prelude customizations for haskell-mode
;; put this in ~/.emacs.d/init.el after Emacs Prelude
(autoload 'ghc-init "ghc" nil t)
(add-hook 'haskell-mode-hook (lambda () (ghc-init)))
(add-hook 'haskell-mode-hook `turn-on-haskell-decl-scan-mode)
(add-hook 'haskell-mode-hook `turn-on-haskell-doc)
(add-hook 'haskell-mode-hook `turn-on-haskell-simple-indent)
(custom-set-variables
'(haskell-tags-on-save t)