Skip to content

Instantly share code, notes, and snippets.

@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
@slmcmahon
slmcmahon / ServerResponse.cs
Created August 5, 2017 12:48
Generic server response wrapper
using System;
namespace AzureDemo.Models
{
public class ServerResponse
{
public ServerResponse()
{
Success = true;
}
@slmcmahon
slmcmahon / chron_most_popular.py
Created October 28, 2016 04:17
Show a listing of links to the most popular Houston, TX stories in the Houston Chronicle.
@slmcmahon
slmcmahon / FindExtendedASCIIChars
Created September 23, 2014 16:33
Reports the index of any characters in a string where the ASCII value is greater than 127
declare
@test nvarchar(500),
@idx int,
@c nchar(1)
set @idx = 1
set @test = 'Nå er tiden for alle gode menn til å komme til unnsetning for landet sitt.'
while @idx < LEN(@test)
begin
@slmcmahon
slmcmahon / gist:a263ffe2d51324d4f275
Last active August 29, 2015 14:04
Check System.DirectoryServices.SearchResult for byte[] or string
private string GetDataFromResults(SearchResult result, string propertyName)
{
if (!result.Properties.Contains(propertyName) || result.Properties[propertyName].Count == 0)
{
return null;
}
var prop = result.Properties[propertyName][0];
var data = prop.GetType() == typeof (byte[])
? Encoding.UTF8.GetString((byte[]) prop)
@slmcmahon
slmcmahon / gist:10564234
Created April 13, 2014 01:03
keybase.md
### Keybase proof
I hereby claim:
* I am slmcmahon on github.
* I am slmcmahon (https://keybase.io/slmcmahon) on keybase.
* I have a public key whose fingerprint is 5EDF 98DD DF62 2F0A D425 6173 93DA CB79 C1F8 E531
To claim this, I am signing this object: