Skip to content

Instantly share code, notes, and snippets.

View slmcmahon's full-sized avatar

Stephen McMahon slmcmahon

View GitHub Profile
@slmcmahon
slmcmahon / DecodeJWT.sh
Last active September 8, 2019 22:55
Script to decode JWT from paste buffer.
#!/bin/bash
# Dependencies:
# JQ: https://stedolan.github.io/jq/download/
# if Linux, you'll need xclip: sudo apt install xclip.
# if OSX, then pbpaste is already there.
# To use this tool, just save it on your system and make
# it executable. Then, if you have copied a base64 encoded
# JWT, then you can simply execute this from a command prompt
@slmcmahon
slmcmahon / remove-soap.xslt
Last active September 1, 2019 18:52
Remove NameSpaces and SOAP Envelope
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
exclude-result-prefixes="soapenv">
<xsl:strip-space elements="*"/>
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<!-- remove all elements in the soapenv namespace -->
@slmcmahon
slmcmahon / loadmapping.go
Last active August 12, 2019 11:53
Read an excel document, create a JSON message and send it to an Azure function.
package main
import (
"bytes"
"encoding/json"
"fmt"
"github.com/360EntSecGroup-Skylar/excelize"
"io/ioutil"
"net/http"
"os"
@slmcmahon
slmcmahon / jmp.js
Created February 9, 2019 01:25
JIMP example
const Jimp = require("jimp");
let data = "Dev";
if (process.argv.length > 2) {
data = process.argv[2];
}
var fileName = 'ic_launcher.png';
var imageCaption = `[${data}]`;
@slmcmahon
slmcmahon / PIR_LCD.ino
Created November 21, 2018 17:16
Arduino Mini Motion Sensor with LCD
//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Connection details for LCD:
// SDA --> A4
// SCL --> A5
// VCC --> 5V
// lcd is initialized with
@slmcmahon
slmcmahon / bumpversion.sh
Created August 26, 2018 18:49
Appends to or overwrites version in info.plist file.
#!/bin/bash
# the 'defaults' command wants the plist file path, but without the .plist extension
NOEXT=$(echo "$1" | cut -f 1 -d '.')
# extract the current CFBundleVersion value
VERSION=$(defaults read $NOEXT CFBundleVersion)
# get the number of '.' characters in the version
DOTCOUNT=$(echo $VERSION | awk -F"." '{print NF-1}')
@slmcmahon
slmcmahon / SecurityUtils.cs
Created August 9, 2018 20:56
MD5 Hashing
using System;
using System.IO;
using System.Security.Cryptography;
namespace Security
{
public class SecurityUtils
{
public static string ComputeChecksum(string filePath)
{
@slmcmahon
slmcmahon / SerializationUtils.cs
Last active July 29, 2018 19:53
Helper for XML and JSON Serialization / Deserialization
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;
using System.Xml.Serialization;
using System.Xml;
using System.Runtime.Serialization;
@slmcmahon
slmcmahon / UserList.js
Last active November 16, 2017 02:39
Simple Example of Loading Data in React
import React, { Component } from 'react'
export class UserList extends Component {
constructor() {
super();
this.state = {
users: [],
}
};
@slmcmahon
slmcmahon / Person.cs
Last active August 6, 2021 08:59
Azure Table Storage CRUD example
using Microsoft.Azure;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Table;
using System;
using System.Collections.Generic;
using System.Linq;
namespace AzureTableSample
{
public class Person : TableEntity