Skip to content

Instantly share code, notes, and snippets.

View b-adams's full-sized avatar

Prof. Bryant E Adams b-adams

  • Wells College
  • Aurora NY
View GitHub Profile
@b-adams
b-adams / index.html
Created January 14, 2012 02:27
Starter homepage for Wells CS105 (HTML) class
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>[YOUR NAME HERE]'s Spring2012 CS105 Home Page</title>
<style type="text/css">
.notStarted {
visibility: hidden;
}
.inProgress:before {
@b-adams
b-adams / cs322ch7flowSupplyDemand.dot
Created January 15, 2012 05:02
Wells CS322 HW Ch7b Supply/Demand problem
digraph sd2
{
s1->d1 [label="100"];
s1->d2 [label="100"];
s1->d3 [label="100"];
s1->d4 [label="100"];
s2->d2 [label="100"];
s2->d4 [label="100"];
s3->d3 [label="100"];
s3->d4 [label="100"];
@b-adams
b-adams / gcd.snippet.c
Created January 20, 2012 22:54
GCD functions
//Tiny function to compute the GCD
int gcd(int a, int b) { return ( b == 0 ? a : gcd(b, a % b) ); }
//More readable to return the greatest common divisor of two integers
int gcd(int first, int second)
{
if(first<0) first = -first;
if(second<0) second = -second;
if (first > second)
@b-adams
b-adams / BAdamsKnife.h
Created January 25, 2012 03:51
CS132 Sp12 Acting on an Object
//
// BAdamsKnife.h
// knife_object_intro
//
// Created by Bryant Adams on 1/24/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
@b-adams
b-adams / Fraction.h
Created February 6, 2012 05:11
CS132 Sp12 Program 2 Starter Files
/**
* \file Fraction.h
* \author Prof. Adams
* \brief Contains header information and documentation for Fraction object
* \version 1.0 - 120205
* \version 1.1 - 120209 - Changed at-dox to slash-dox
*/
#import <Foundation/Foundation.h>
@b-adams
b-adams / samplestub.m
Created February 12, 2012 20:53
Smart stub notification
// TODO: Implement method
#warning Method still a stub
-(double) congratulate:(NSString*)whom manyTimes:(int)n
{
NSLog(@"\n\tStatus=<%@> Class=<%@> Selector=<%@>", @"Stub", NSStringFromClass([self class]), NSStringFromSelector(_cmd));
return NAN;
}
// TODO: Implement method
#warning Method still a stub
@b-adams
b-adams / Doxyfile
Created February 17, 2012 17:01
Doxygen file to put in the root of your directory (not in a program_N folder)
# Doxyfile 1.7.4
# This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project
#
# All text after a hash (#) is considered a comment and will be ignored
# The format is:
# TAG = value [value, ...]
# For lists items can also be appended using:
# TAG += value [value, ...]
@b-adams
b-adams / ComplexFraction.m
Created March 5, 2012 04:24
CS132 Program 3 code
/********************************/
/* WARNING! These are snippets */
/* and NOT the entire code! */
/* You'll need to implement the */
/* designated initializer and */
/* most of the arithmetic. */
/********************************/
-(id) initWithReal:(int)reNum
over:(int)reDen
@b-adams
b-adams / doxblox.c
Created March 19, 2012 07:05
Documentation and sample output for Linked List program.
//This documentation should be put with the appropriate class/method/function declarations.
//Remember to add file documentation blocks to all your files!
/**
Entry point for the program. Tests that list operations are working.
*/
/**
Represents a node in a singly linked list
*/
@b-adams
b-adams / connect.php
Created March 26, 2012 21:32
Turning on PHP display_errors
<?php
ini_set('display_errors', 1);
$db_handle = pg_connect("dbname=CS325_astudent user=astudent password=apassword");
$query = "SELECT * FROM schemaname.tablename";
$result = pg_exec($db_handle, $query);
echo "Number of rows: " . pg_numrows($result);
pg_freeresult($result);
pg_close($db_handle);
?>