Teach The Net
Home of the Seanybob
  • Home
  • About Me
  • Links
  • My Portfolio
  • My Programs
  • USURP

Random Post: Do you have belly-button lint?

My Comics No Comments »

Click to enlarge.

True story. Mostly. And Re-curring.


January 16th, 2009 |



Douglas Wilson on Emeth the Calormen

Quotations, Uncategorized 1 Comment »

This is but a short excerpt from the book “Omnibus 1, Biblical and Classical Civilization”.

You can buy the book HERE, among other places.


January 29th, 2010 |



C. S. Lewis on Calvinism

Quotations 1 Comment »

“I take it as a first principle that we must not interpret any one part of Scripture so that it contradicts other parts . . . . The real inter-relation between God’s omnipotence and Man’s freedom is something we can’t find out. Looking at the Sheep & the Goats every man can be quite sure that every kind act he does will be accepted by Christ. Yet, equally, we all do feel sure that all the good in us comes from Grace. We have to leave it at that. I find the best plan is to take the Calvinist view of my own virtues and other people’s vices; and the other view of my own vices and other peoples virtues. But tho’ there is much to be puzzled about, there is nothing to be worried about. It is plain from Scripture that, in whatever sense the Pauline doctrine is true, it is not true in any sense which excludes its (apparent) opposite. You know what Luther said: ‘Do you doubt if you are chosen? Then say your prayers and you may conclude that you are.’” (pp.354-355).


January 21st, 2010 |



Emeth

Quotations, Reflections, Uncategorized No Comments »

“Then I fell at his feet and thought, ‘Surely this is the hour of death, for the Lion (who is worthy of all honour) will know that I have served Tash all my days and not him. Nevertheless, it is better to see the Lion and die than to be Tisroc of the world and live and not to have seen him’. But the Glorious One bent down his golden head and touched my forehead with his tongue and said, ‘Son, thou art welcome.’ But I said, ‘Alas, Lord, I am no son of thine but the servant of Tash.’ He answered, ‘Child, all the service thou hast done to Tash, I account as service done to me.’ Then by reason of my great desire for wisdom and understanding, I overcame my fear and questioned the Glorious One and said, ‘Lord, is it then true, as the Ape said, that thou and Tash are one?’ The Lion growled so that the earth shook (but his wrath was not against me) and said, ‘It is false. Not because he and I are one, but because we are opposites — I take to me the services which thou hast done to him. For I and he are of such different kinds that no service which is vile can be done to me, and none which is not vile can be done to him. Therefore, if any man swear by Tash and keep his oath for the oath’s sake, it is by me that he has truly sworn, though he know it not, and it is I who reward him. And if any man do a cruelty in my name, then, though he says the name Aslan, it is Tash whom he serves and by Tash his deed is accepted. Dost thou understand, Child?’ I said, ‘Lord, thou knowest how much I understand.’ But I said also (for truth constrained me), ‘Yet I have been seeking Tash all my days.’ ‘Beloved,’ said the Glorious One, ‘unless thy desire had been for me thou wouldst not have sought so long and so truly. For all find what they truly seek.’”
–Emeth, the Calormene, describing his encounter with Aslan

To see Douglas Wilson’s response to this, click HERE


January 12th, 2010 |



On the mating season

Reflections No Comments »

Dear Mrs. ____
Thanks for yours of the 16th. Our climatic troubles are just the opposite of yours; one of the coldest and wettest summers I remember. But I’d dislike your heat very much more than our cold. I am so glad you gave me an account of the lovely priest. How little people know who think that holiness is dull. When one meets the real thing (and perhaps, like you, I have met it only once) it is irresistable. If even 10% of the world’s population had it, would not the whole world be converted and happy before a year’s end? Yes, I too think there is lots to be said for being no longer young; and I do most heartily agree that it is just as well to be past the age when one expects or desires to attract the other sex. It’s natural enough in our species, as in others, that the young birds should show off their plumage – in the mating season. But the trouble in the modern world is that there’s a tendency to rush all the birds on to that age as soon as possible and then keep them there as late as possible, thus losing all the real value of the other parts of life in a senseless, pitiful attempt to prolong what, after all, is neither its wisest, its happiest, or most innocent period. I suspect merely commercial motives are behind it all: for it is at the showing-off age that birds of both sexes have least sales-resistance! Naturally I can have no views on a choice between your home town and Washington any more than on one between Omsk and Teheran! but of course you shall have my prayers. Sorry to hear about the fall, they’re nasty things. I must stop now, for I’m dead tired from standing at catalogue-shelves in a library all morning verifying titles of books and editions. I think, like the Irishman in the story “I’d sooner walk 10 miles than stand one”. I go to Ireland on the 11th so don’t be surprised if you don’t hear from me again till the end of September. All blessings.
Yours,
C. S. Lewis


January 3rd, 2010 |



CSUSB – CSCI201 – Lab 10

c++, csci 201 No Comments »


input.txt
y
Susy
100
y
Bob
90
y
Frank
80
y
Jen
40
y
Russel
99
n
Bob
Frank
100

——————————————————————————————–
/**************************

gbVector.h
gradebook class header file
**************************/

#include <iostream>
#include <vector>

using namespace std;

class GradeBook {
public:
GradeBook();
GradeBook(string c);
string getCourseName();
void setCourseName(string c);
void display();
void enterGrade();
float average();
void displayRecord(string name);
bool changeGrade(string name, int newGrade);

private:
int search(string name);
string courseName;
vector names;
vector grades;
}; // GradeBook

——————————————————————————————–
/**************************

gbVector.cpp
contains functions of gradebook class
**************************/

#include <iostream>
#include <iomanip>

#include "gbVector.h"

using namespace std;

GradeBook::GradeBook()
{
courseName = "CS201";
}
GradeBook::GradeBook(string c)
{
courseName = c;
}
string GradeBook::getCourseName()
{
return courseName;
}
void GradeBook::setCourseName(string c)
{
courseName = c;
}
void GradeBook::display()
{
cout << "Course: " << courseName << endl;
for (int i = 0; i < names.size(); i++)
cout << setw(10) << left << names[i] << setw(4) << right << grades[i] << endl;
}

void GradeBook::enterGrade()
{
string name;
int grade;
cout << "Enter a student name and grade: ";
cin >> name >> grade;
names.push_back(name);
grades.push_back(grade);
}
float GradeBook::average()
{
float sum = 0;
float avg = 0;
for (int i = 0; i < grades.size(); i++)
sum += grades[i];
//sum/grades.size()
if(grades.size() > 0)
return avg;
else
return -1;
}
void GradeBook::displayRecord(string name)
{
int index = search(name);
if(index == -1)
cout << "Student not found" << endl;
else
cout << setw(10) << left << names[index] << setw(4) << right << grades[index] << endl;
}
bool GradeBook::changeGrade(string name, int newGrade)
{
int index = search(name);
if(index == -1)
return false;
else
{
grades[index] = newGrade;
return true;
}
}
int GradeBook::search(string name)
{
int retValue = -1;
for(int i = 0; i < names.size(); i++)
{
if(names[i]==name)
{
retValue = i;
}
}
return retValue;
}

——————————————————————————————–

/**************************

gbVectorMain.cpp
main file implementing gradebook class
**************************/

#include <iostream>
#include "gbVector.h"

using namespace std;

main()
{
GradeBook gb("CS 201");
string answer;
string name;
int grade;

cout << "Do you want to add a student name and grade? ";
cin >> answer;
while (answer == "yes" or answer == "y") {
gb.enterGrade();
cout << "Do you want to continue? ";
cin >> answer;
}

gb.display();
cout << "Average = " << gb.average() << endl;

cout << "Enter a student's name to display their record: " << endl;
cin >> name;
gb.displayRecord(name);

cout << "Enter a student's name to change their grade: " << endl;
cin >> name;
cout << "Enter " << name << "'s new grade: " << endl;
cin >> grade;
gb.changeGrade(name, grade);
gb.displayRecord(name);

} // main


November 14th, 2009 |



CSUSB – CSCI201 – Lab 9

c++, csci 201 No Comments »

Numbers.txt
12
34
45
65
43
18
18
18
18
18
18
18
18
45
76
87
34
10000
-40
30

——————————————————————————————–

/**************************

vectors.cpp
inputs vector from user, sorts in descending order (removing duplicates) and outputs vector with frequency of numbers in original input.
**************************/

#include <iostream>
#include <vector>

using namespace std;

void insertion_sort(vector & a)
{
for (int next = 1; next < a.size(); next++) {
int insert = a[next];
int moveItem = next;

while (moveItem > 0 and a[moveItem - 1] < insert) {
a[moveItem] = a[moveItem - 1];
moveItem--;
}

a[moveItem] = insert;
}
}

main()
{
int t;
vector data;

while (cin >> t)
data.push_back(t);

insertion_sort(data);

//remove duplicate values
vector test;
vector frequency;
int freqOfNum;
bool flag;
for (int i = 0; i < data.size(); i++)
{
flag = false;
freqOfNum = 0;
for (int j = i + 1; j < data.size(); j++)
{
if(data[i]==data[j])
{
flag = true;
}
}
if(!flag)
{
test.push_back(data[i]);
for (int l = 1; l < data.size(); l++)
{
if(data[l]==data[i])
{
freqOfNum++;
}
}
frequency.push_back(freqOfNum);
}
}
//end remove duplicate values

for (int i = 0; i < test.size(); i++)
cout << test[i] << endl;
}


--------------------------------------------------------------------------------------------
/**************************

array.cpp
inputs array from user, sorts in descending order (removing duplicates) and outputs array with frequency of numbers in original input.
**************************/

#include <iostream>

using namespace std;

void insertion_sort(int a[], int frequency[], int length)
{
for (int next = 1; next < length; next++)
{
int insert = a[next];
int moveItem = next;

while (moveItem > 0 and a[moveItem - 1] < insert)
{
a[moveItem] = a[moveItem - 1];
moveItem--;
}

a[moveItem] = insert;
}
}

void print_arrays(int a[], int length, int b[])
{
for (int i = 0; i < length; i++)
{
cout << a[i] << " - " << b[i] << endl;
}
}

main()
{
int t, i, n;
int dataSize = 100;
int data[dataSize];
int frequency[dataSize];
int newLength = 0; //stores length of array after duplicates removed

i = 0;
while (cin >> t)
{
data[i] = t;
frequency[i] = 0;
i++;
}
n = i;

insertion_sort(data, frequency, n);

//remove duplicate values
int test[dataSize];
int freqOfNum;
bool flag;
for (int i = 0; i < n; i++)
{
flag = false;
freqOfNum = 0;
for (int j = i + 1; j < n; j++)
{
if(data[i]==data[j])
{
flag = true;
}
}
if(!flag)
{
test[newLength] = data[i];
for (int l = 0; l < n; l++)
{
if(data[l]==data[i])
{
freqOfNum++;
}
}
frequency[newLength] = freqOfNum;
newLength++;
}
}
//end remove duplicate values

print_arrays(test, newLength, frequency);
}


November 14th, 2009 |



CSUSB – CSCI201 – Lab 7

c++, csci 201 No Comments »

An example of object oriented programming in c++, with the creation of a clock you can set.


/**************************
time.h
**************************/

#include <iostream>
#include <iomanip>

using namespace std;

class Time
{
public:
Time();
Time(int h, int m, int s);
void setSeconds(int s);
void setMinutes(int m);
void setHours(int h);
int getSeconds();
int getMinutes();
int getHours();
void addSeconds(int s);
void correctTime();
void displayTime();
private:
int seconds;
int hours;
int minutes;
};

——————————————————————————————–

/**************************

time.cpp
**************************/

#include <iostream>
#include <iomanip>
#include "time.h"

using namespace std;

Time::Time()
{
seconds = 30;
hours = 12;
minutes = 30;
}
Time::Time(int h, int m, int s)
{
if(s < 0)
s = 0;
if(s > 59)
s = 59;
if(m < 0)
m = 0;
if(m > 59)
m = 59;
if(h < 0)
h = 0;
if(h > 23)
h = 23;
seconds = s;
hours = h;
minutes = m;
}
void Time::setSeconds(int s)
{
if(s < 0)
s = 0;
if(s > 59)
s = 59;
seconds = s;
}
void Time::setMinutes(int m)
{
if(m < 0)
m = 0;
if(m > 59)
m = 59;
minutes = m;
}
void Time::setHours(int h)
{
if(h < 0)
h = 0;
if(h > 23)
h = 23;
hours = h;
}
int Time::getSeconds()
{
return seconds;
}
int Time::getMinutes()
{
return minutes;
}
int Time::getHours()
{
return hours;
}
void Time::addSeconds(int s)
{
seconds += s;
correctTime();
}
void Time::correctTime()
{
while(seconds / 60 > 0) //because seconds is an integer, it truncates
{
seconds = seconds - 60;
minutes += 1;
}
while(minutes / 60 > 0)
{
minutes = minutes - 60;
hours += 1;
}
while(hours / 24 > 0)
{
hours = hours - 24;
//days += 1; - For now, just truncate full days
}
}
void Time::displayTime()
{
cout << setw ( 2 ) << hours << " hours : " << setw ( 2 ) << minutes << " minutes : " << setw ( 2 ) << seconds << " seconds" << endl;
}

--------------------------------------------------------------------------------------------

/**************************

main.cpp
**************************/

#include <iostream>
#include <iomanip>
#include "time.h"

using namespace std;

int main()
{
Time t1, t2(4, 20, 80000);
t1.displayTime();
t2.displayTime();
t2.addSeconds(90);
t2.displayTime();
t1.setSeconds(1);
t1.setHours(1);
t1.setMinutes(1);
t1.displayTime();
return 0;
}


November 14th, 2009 |



Tip: Get Wordpress Functions in Standalone Plugin Scripts

Uncategorized No Comments »

This week for work, I’ve been creating a Wordpress plugin to generate a contact form and send the e-mail via an AJAX call to a standalone script. However, because the script is standalone (i.e., not being used within the context of being called by Wordpress itself) to get some of the information that the user configures in the plugin options, I need to include Wordpress functionality.

The quick way to do this is to just include the wp-config.php file that is in the root directory of your Wordpress installation. However, you have to include it in the main body of the standalone script – i.e., you can’t include it in a function or class (it will fail if you do this).

TL;DR: Just include this line at the very top of your standalone PHP script:

require_once(“../../../wp-config.php”);

This assumes that your plugin has its own directory within wp-content/plugins/. If you’re just using a single file in the plugins folder, take out the extra ../ at the beginning:

require_once(“../../wp-config.php”);


November 13th, 2009 |



Hosting – Virtual Private Servers (vps)

Random (Other) No Comments »

Just wanted to share a new service I’ve been trying out.

Wiredtree.com has some excellent vps deals. They have the standard prices for the industry, but have some crazy coupons (google for them, I found one that cut my first month bill in half and gave me an extra 50% free RAM on my server).

Beyond that though, they have the best customer service I’ve EVER seen, anywhere in life. I actually enjoy going to them with my problems. Normally, I hate customer service lines, and will avoid them at all costs – not so with wiredtree.

I encourage you to check them out if you need a vps server.


November 12th, 2009 |



Converting CSV to MYSQL / SQL

-Programming/Coding, Php No Comments »

Excellent website that allows you to upload a csv file and outputs it into sql. Saved me quite a bit of time.

http://www.sqldbu.com/eng/sections/tips/mysqlimport.html


November 4th, 2009 |



Previous Entries
  • Categories

    • -Personal (77)
      • My Comics (23)
      • Programs I Use (1)
      • Quotations (27)
      • Random (personal) (9)
      • Reflections (20)
    • -Programming/Coding (74)
      • AutoIt v3 (3)
      • c++ (7)
      • Call of duty (3)
      • CSS (2)
      • Design (1)
      • HTML (2)
      • Javascript (6)
      • LISP (1)
      • My Programs (31)
      • Php (19)
      • Robotics (9)
      • Visual Basic (24)
    • CSUSB (3)
      • csci 201 (3)
    • Electrical and Computer Engineering Cal Poly (2)
      • C for Engineers (1)
      • Circuit Analysis (1)
    • Other (36)
      • Easter Eggs (4)
      • Funny Stuff (16)
      • Hacks/Tricks (12)
      • Random (Other) (3)
      • Roll Towards Me (Band) (1)
    • Uncategorized (3)
    • USURP (3)
  • Archives

    • January 2010
    • November 2009
    • October 2009
    • September 2009
    • August 2009
    • June 2009
    • May 2009
    • April 2009
    • March 2009
    • February 2009
    • January 2009
    • December 2008
    • November 2008
    • October 2008
  • Recent Posts

    • Random Post: What are you thinking?
    • Douglas Wilson on Emeth the Calormen
    • C. S. Lewis on Calvinism
    • Emeth
    • On the mating season
    • CSUSB – CSCI201 – Lab 10
    • CSUSB – CSCI201 – Lab 9
    • CSUSB – CSCI201 – Lab 7
    • Tip: Get Wordpress Functions in Standalone Plugin Scripts
    • Hosting – Virtual Private Servers (vps)
    • Converting CSV to MYSQL / SQL

Copyright © 2010 Teach The Net All Rights Reserved
RSS XHTML CSS Log in
Wp Theme by n Graphic Design
Powered by Wordpress