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 / 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 / 0_reuse_code.js
Created April 20, 2017 12:02
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@mlcollard
mlcollard / Makefile
Last active July 25, 2017 18:55
Using SWIG to generate python bindings for libsrcml
all:
swig -Wall -python srcml.i
gcc -fPIC -Wall -Wextra -shared srcml_wrap.c -o _srcml.so -L/usr/local/lib/ -lsrcml -I/usr/include/python2.7/ -lpython2.7
clean:
rm -f srcml_wrap.c _srcml.so srcml.py srcml_wrap.c
@mlcollard
mlcollard / ClassStructTiming.swift
Last active January 29, 2018 13:00
iOS: Compare class and struct timing
//
// ClassStructTiming.swift
//
// Compare class and struct timing
//
// Derived from https://github.com/knguyen2708/StructVsClassPerformance
import Foundation
class IntClass {
@mlcollard
mlcollard / UsingUITextFieldDelegate.swift
Last active January 31, 2018 18:37
iOS: Make a text keyboard disappear. Used to show UIViewController as delegate for text field.
//
// Setup for UITextFieldDelegate
//
// Note: Comments with this label are to explain semantics of iOS
// Do not use comments like these in your projects
import UIKit
class ViewController: UIViewController, UITextFieldDelegate {
@mlcollard
mlcollard / ActiveViewControllerClosure.swift
Created January 31, 2018 17:01
iOS: Active view controller with a closure
//
// Moving keyboard for item
//
// Note: Comments with this label are to explain semantics of iOS
// Do not use comments like these in your projects
import UIKit
class ViewController: UIViewController, UITextFieldDelegate {