Skip to content

Instantly share code, notes, and snippets.

View mlcollard's full-sized avatar

Michael L. Collard mlcollard

View GitHub Profile
@mlcollard
mlcollard / libsrcml_convenience.c
Created October 6, 2014 13:37
srcML - Example of libsrcml convenience functions
/*
libsrcml_convenience.cpp
Demonstrates basic use of libsrcml convenience function srcml()
for converting to and from the srcML format
Error handling removed for clarity
*/
#include <srcml.h>
@mlcollard
mlcollard / libsrcml_create.c
Created October 6, 2014 13:38
srcML - Example of creating a single-unit srcML file with the libsrcml API
/*
libsrcml_create.cpp
Demonstrates use of libsrcml functions for writing
a srcML file
Error handling removed for clarity
*/
#include <srcml.h>
@mlcollard
mlcollard / libsrcml_extract.c
Created October 6, 2014 13:39
srcML - Example of extracting source from a single-unit srcML file using the libsrcml API
/*
libsrcml_extract.cpp
Demonstrates use of libsrcml functions for reading
a srcML file
Error handling removed for clarity
*/
#include <srcml.h>
@mlcollard
mlcollard / WKWebViewURL.swift
Last active May 4, 2018 02:59
iOS: Loading a WKWebView with a web URL
/* Load given URL into web view */
/* Note: For http:, need to setup App Transport Settings to allow:
Key: App Transport Security Settings
Subkey: Allow Arbitrary Loads to YES
Produces:
<key>NSAppTransportSecurity</key>
<dict>
@mlcollard
mlcollard / DateFirstCommit.sh
Last active August 29, 2015 14:09
ISO Date of first commit to a git repository
git rev-list HEAD | tail -n 1 | xargs -I% git log --date=iso % | grep "Date:" | cut -d":" -f2- | cut -c4- | cut -d"+" -f1
@mlcollard
mlcollard / DirGitFirstCommitISO.sh
Created November 14, 2014 16:09
ISO Date of first commit to a repository, for all the files in a directory
ls . | xargs -I^ bash -c 'echo -n ^; echo -en "\t"; cd ^; git rev-list HEAD | tail -n 1 | xargs -I% git log --date=iso % | grep "Date:" | cut -d":" -f2- | cut -c4- | cut -d"+" -f1'
@mlcollard
mlcollard / KeychainAddPassword.swift
Last active March 23, 2018 17:11
iOS: KeyChain: Add item to keychain
/*
Save password in KeyChain
TODO: import Security
*/
// initial password to store
let passwordStr = "0123456789"
print("String Data: \(passwordStr)")
// encoded password
@mlcollard
mlcollard / KeychainUpdatePassword.swift
Last active March 23, 2018 17:47
Security: Update item in the keychain
/*
Update password in KeyChain
TODO: import Security
*/
// string password
let passwordStr = "9876543210"
print("String Data: \(passwordStr)")
// encoded password
@mlcollard
mlcollard / KeychainReadPassword.swift
Last active March 23, 2018 17:32
Security: Get item from the keychain
/*
Read password from KeyChain
TODO: import Security
*/
// setup the keychain request
let getPasswordQuery = [
// NOTE: Pick the correct type of data
kSecClass : kSecClassGenericPassword,
@mlcollard
mlcollard / UIGestureSetup.swift
Last active May 2, 2018 11:22
UIGesture setup
// add tap and gesture
self.view.addGestureRecognizer(UITapGestureRecognizer() {
print("UITapGestureRecognizer")
})
// add pinch gesture
self.view.addGestureRecognizer(UIPinchGestureRecognizer() {
print("UIPinchGestureRecognizer")
})