Skip to content

Instantly share code, notes, and snippets.

View natemcmaster's full-sized avatar

Nate McMaster natemcmaster

View GitHub Profile
@natemcmaster
natemcmaster / web.config
Last active December 19, 2015 08:29
Configuring CakePHP on Azure
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect static resources" stopProcessing="true">
<match url="^(ico|img|css|files|js|font)(.*)$" />
<action type="Rewrite" url="app/webroot/{R:1}{R:2}" appendQueryString="false" />
</rule>
<rule name="Imported Rule 1" stopProcessing="true">
@natemcmaster
natemcmaster / myip_cygwin.sh
Last active December 20, 2015 17:19
Bash command for getting the local machine ip address from ipconfig
ipconfig | grep 'IPv4' | awk -F ': ' '{print $2}'
@natemcmaster
natemcmaster / truncation.cpp
Created September 19, 2013 23:06
Demo of integer math vs. double math
#include <iostream>
using namespace std;
int main(){
int half = 3/2;
cout << half << endl; //Prints 1 because int's throw away the decimal
double intMath= 3 / 2;
cout<<intMath<<endl; //Prints 1, not what we expected
@natemcmaster
natemcmaster / Fruit.cpp
Created September 21, 2013 20:44
Sample of inheritance and vectors.
/*
* Fruit.cpp
*
* Created on: Sep 21, 2013
* Author: nmcmaster
*/
#include "Fruit.h"
using namespace std;
@natemcmaster
natemcmaster / boolean.cpp
Last active December 23, 2015 21:19
Tutoring: sample of various ways to use bool in C++
#include <iostream>
using namespace std;
bool foobar(int f){
return (f==7);
}
int main(){
bool foobarcondition=foobar(7);
@natemcmaster
natemcmaster / pointers.cpp
Created September 25, 2013 16:37
Tutoring: sample of how to various ways use pointers.
#include <iostream>
#include <string>
using namespace std;
void appendAuthorName(string* bookTitle){
*bookTitle = *bookTitle + ": by J.K. Rowling"; // notice how I am modifying bookTitle but not returning anything. I am modifying the string directly
}
@natemcmaster
natemcmaster / scoping.cpp
Created September 25, 2013 16:50
Tutoring: demonstration of variable scope in C++;
#include <iostream>
using namespace std;
void someFunction();
int number = 0; // Scoped globally (everywhere inside this C++ program)
@natemcmaster
natemcmaster / looping.cpp
Created October 1, 2013 18:58
Tutoring: demo of using loops to get user input from cin
#include <iostream>
using namespace std;
int main()
{
double miles;
cout << "Enter miles:" << endl;
@natemcmaster
natemcmaster / queue.cpp
Created October 9, 2013 02:49
Tutoring: example of creating a simple data structure with dynamic memory allocation and avoiding memory leaks
#include <iostream>
#include "queue.hpp"
Queue::Queue():head(NULL),tail(NULL){
}
void Queue::add(int insertValue){
Node* nextItem = new Node();
nextItem->value = insertValue;
@natemcmaster
natemcmaster / nm.zsh-theme
Created December 17, 2013 21:53
ZSH Theme
if [ $UID -eq 0 ]; then NCOLOR="red"; else NCOLOR="yellow"; fi
PROMPT='%{$fg[$NCOLOR]%}%m:%c ➤ %{$reset_color%}'
RPROMPT='%{$fg[$NCOLOR]%}%p $(git_prompt_info)%{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="git:"
ZSH_THEME_GIT_PROMPT_SUFFIX=""
ZSH_THEME_GIT_PROMPT_DIRTY="*"
ZSH_THEME_GIT_PROMPT_CLEAN=""