Skip to content

Instantly share code, notes, and snippets.

View cgddrd's full-sized avatar

Connor Goddard cgddrd

View GitHub Profile
@cgddrd
cgddrd / syntaxlistingformat.tex
Created March 12, 2013 16:59
Syntax highlighting and formatting for source code listings in LaTeX.
\lstdefinestyle{customc++}{
belowcaptionskip=1\baselineskip,
breaklines=true,
frame=L,
language=C++,
showstringspaces=false,
basicstyle=\footnotesize\ttfamily,
keywordstyle=\bfseries\color{OliveGreen},
commentstyle=\itshape\color{black},
identifierstyle=\color{blue},
@cgddrd
cgddrd / Bash_Word_Processing.bash
Last active December 15, 2015 12:09
Two Bash/Terminal commands that are very useful for word processing.
//Return all 8 letter words in a file.
grep '^........$' linuxwords.txt > words8.txt
//Bash to turn all upper case letters/words to lower case.
tr '[:upper:]' '[:lower:]' < words15.txt > words15.dat
\addcontentsline{toc}{section}{References}
\bibliographystyle{plain}
\begin{thebibliography}{1}
\bibitem{notes} {\em ``How to lock files in C/C++ using fopen"} - http://stackoverflow.com/questions/7573282/ 2011: StackOverf low, StackExchange.
\bibitem{notes} P. Prinz, T. Crawford {\em ``C in a Nutshell"} 2008: O'Reilly Media Inc.
\bibitem{notes} R. Lischner {\em ``C++ in a Nutshell"} 2009: O'Reilly Media Inc.
@cgddrd
cgddrd / Repo_Transfer_Git
Created May 3, 2013 13:37
Transferring of entire repository (including history) to new repository in Git.
git clone <git repository B url> /* Clone and enter the new repo. */
cd <git repository B directory>
git remote add repo-A-branch <git repository A url> /* repo-A-branch (e.g. master) (No chevrons required) */
git pull repo-A-branch master
git remote rm repo-A-branch
@cgddrd
cgddrd / opencv_v3.0.0_install_c++_project_.travis.yml
Created February 6, 2015 21:57
Travis CI configuration file to install OpenCV v3.0.0 (beta) for use with C++ projects. Modified for v3.0.0 from original scripts available at: https://github.com/jayrambhia/Install-OpenCV.
language:
- cpp
compiler:
- gcc
before_install:
- sudo apt-get update
install:
@cgddrd
cgddrd / gist:bf174fea3993369777fe
Last active August 29, 2015 14:15
C++ - Compile OpenCV Application (v2.4.9) (g++)
g++ main.cpp -o optical_test -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_video
@cgddrd
cgddrd / module_pattern_init.js
Last active August 29, 2015 14:26 — forked from nathansmith/module_pattern_init.js
Init + Module Pattern JS
// JS Module Pattern:
// http://j.mp/module-pattern
// Redefine: $, window, document, undefined.
var APP = (function($, window, document, undefined) {
// Automatically calls all functions in APP.init
$(document).ready(function() {
APP.go();
});
@cgddrd
cgddrd / Regex_Match_Between_Nth_And_Nth+1_Occurence_Of_Character_Pattern.md
Last active August 29, 2015 14:26
[Regex] This regular expression is designed to work with character-delimited strings, and provides a means to specify the index of delimiter occurrence at which content is extracted.

Regular Expression - Match content contained within nth and nth + 1 occurence of specified character pattern.

This regular expression is designed to work with character-delimited strings, and provides a means to specify the index of delimiter occurrence at which content is extracted.

Parameters

  1. CHARACTER_PATTERN - Delimiter character pattern to search for within target string.
  2. INDEX - Zero-based index specifying the nth occurrence of CHARACTER_PATTERN at which content is to be extracted, up to nth + 1 occurrence.

Regular Expression (Single-line)

@cgddrd
cgddrd / js-abstract-class.js
Last active August 29, 2015 14:27
Javascript - Abstract Class Design Pattern
var testChildClass = new ChildClass(5, "A child class property!");
console.log(testChildClass.basePropertyThree); // '5'
console.log(testChildClass.anotherProperty); // 'A child class property!'
console.log(testChildClass.baseFunction()); // '7'
testChildClass.childFunction('Hello world!'); // 'Hello world!'
public class StochasticUniversalSampling {
/**
*
* @param population - set of individuals' segments. Segment is equal to individual's fitness.
* @param n - number of individuals to choose from population.
* @return set of indexes, pointing to the chosen individuals in the population set
*/
public int[] execute(double[] population, int n) {
// Calculate total fitness of population