--- /dev/null
+notes/*
+!notes/index.php
+!notes/notes.php
ErrorDocument 404 /404.php
+RewriteEngine on
+RewriteRule ^notes/page/([1-9]+)/?$ notes/index.php?page=$1 [L]
+RewriteRule ^note/([^/\.]+)/?$ notes/index.php?note=$1 [L]
+php_flag display_errors on
+php_value error_reporting 7
#contact_me {
margin-top:100px;
+ font-family:sans-serif;
}
/* reprap */
#notes h2 {
margin-bottom:10px;
+ font-family:sans-serif;
}
.note {
.note p {
margin-bottom:5px;
}
+
+pre {
+ margin-top:10px;
+}
"http://tempositions.com">tempositions.com</a></li>
<li>
- <h3>my github repo:</h3>
+ <h3>my repositories:</h3>
</li>
<li><a href=
- "http://github.com/nospampleasemam">github@github.com:nospampleasemam</a></li>
+ "git">git://dylanstestserver.com</a></li>
<li>
- <h3>my repo:</h3>
+ <h3>some notes:</h3>
</li>
<li><a href=
- "git">git://dylanstestserver.com</a></li>
+ "notes">here</a></li>
<li>
<h1 id="contact_me"><a href=
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<title>dylanstestserver</title>
- <link href="../includes/style.css" rel="stylesheet" type="text/css">
- <link rel="icon" href="../favicon.ico" type="image/png">
+ <link href="includes/style.css" rel="stylesheet" type="text/css">
+ <link rel="icon" href="favicon.ico" type="image/png">
</head>
<body>
<div id="banner">
<a href=
"http://dylanstestserver.com/">
- <img src="../images/dylanstestserver.png" alt="dylanstestserver"
+ <img src="images/dylanstestserver.png" alt="dylanstestserver"
border="0"></a>
</div>
<div id="content">
<div id="notes">
- <div class="note">
- <h2>Amazon EC2 PTR/reverse DNS record/2/15/10</h2>
- <p><a href="https://aws-portal.amazon.com/gp/aws/html-forms-controller/contactus/ec2-email-limit-rdns-request">Here</a> is the form to request a custom PTR record for an Amazon EC2 Elastic IP. It's listed, of course, under <u>Request to Remove Email Sending Limitations</u>, and took me an unfortunate amount of time to locate.</p>
- <p>This is good when setting up a mail server in Amazon's cloud, since email providers (like gmail) flag mail whose reverse DNS does not match the MX record. Without this request, the reverse DNS lookup will return the default PTR record that will look something like <a href="ec2-50-16-219-8.compute-1.amazonaws.com">ec2-50-16-219-8.compute-1.amazonaws.com</a></p>
- </div>
- <div class="note">
- <h2>init/2/15/10</h2>
- <p>Every other day I manage to get something working with help from a blog I find with google that just-so-happens to include a detail the manual spares. These notes are in the hope of helping in the same way. I don't plan on writing often, and there will be no order to the notes; in this way these notes are meant more for spiders than humans.</p>
- </div>
- <h1 id="contact_me" style="margin-top:60px;"><a href=
- "mailto:dylan@psu.edu">dylan</a></h1><a href=
- "mailto:dylan@psu.edu">@psu.edu</a>
+ <?php require('notes.php') ?>
+ <h1 id="contact_me" style="margin-top:60px;"><a href=
+ "mailto:dylan@psu.edu">dylan</a></h1><a href=
+ "mailto:dylan@psu.edu">@psu.edu</a>
</div>
</div>
</div>
--- /dev/null
+<?php
+ mysql_connect('localhost', 'dylan', 'password') or die(mysql_error());
+ mysql_select_db('dylanstestserver') or die(mysql_error());
+ $sql = "SELECT COUNT(*) FROM notes";
+ $result = mysql_query($sql);
+ $result = mysql_fetch_row($result);
+ $number_of_notes = $result[0];
+ $notes_per_page = 4;
+ $total_number_of_pages = ceil($number_of_notes/$notes_per_page);
+ if (isset($_GET['note'])) {
+ $note = mysql_real_escape_string($_GET['note']);
+ $sql = "SELECT title, date_posted, text
+ FROM notes WHERE url=\"$note\"";
+ $result = mysql_query($sql) or die(mysql_error());
+ while($note = mysql_fetch_array($result)) {
+ echo "<div class=\"note\">";
+ $title = $note['title'];
+ $date_posted = explode("-", $note['date_posted']);
+ $year_posted = $date_posted[0];
+ $month_posted = $date_posted[1];
+ $day_posted = $date_posted[2];
+ echo "<h2><span style=\"color:grey;\">$year_posted/$month_posted/$day_posted/</span>$title</h2>";
+ echo $note['text'];
+ echo "</div>";
+ }
+ } else {
+ if (isset($_GET['page']) && is_numeric($_GET['page'])) {
+ $page = (int) $_GET['page'];
+ } else {
+ $page = 1;
+ }
+ if ($page < 1) {
+ $page = 1;
+ } else if ($page > $total_number_of_pages) {
+ $page = $total_number_of_pages;
+ }
+ $page_offset = ($page - 1) * $notes_per_page;
+ $notes = mysql_query("SELECT title, date_posted, text, url
+ FROM notes ORDER BY date_posted DESC
+ LIMIT $page_offset, $notes_per_page");
+ while($note = mysql_fetch_array($notes)) {
+ echo "<div class=\"note\">";
+ $title = $note['title'];
+ $date_posted = explode("-", $note['date_posted']);
+ $year_posted = $date_posted[0];
+ $month_posted = $date_posted[1];
+ $day_posted = $date_posted[2];
+ $url = $note['url'];
+ echo "<h2><span style=\"color:grey;\">$year_posted/$month_posted/$day_posted/</span><a href=\"note/$url\">$title</a></h2>";
+ echo $note['text'];
+ echo "</div>";
+ }
+ echo "<h2>";
+ if($page != 1){
+ if(!$page == 2 && $total_number_of_pages == 2)
+ echo "<a href=\"{$_SERVER['PHP_SELF']}/page/1\">first</a> / ";
+ $previous_page = $page - 1;
+ echo "<a href=\"notes/page/$previous_page\">prev</a>";
+ }
+ if($page < $total_number_of_pages) {
+ $forward_page = $page + 1;
+ echo "<a href=\"notes/page/$forward_page\">next</a>";
+ }
+ if($page != $total_number_of_pages && (!$page == 1 && $total_number_of_pages == 2)){
+ echo " / <a href=\"notes/page/$total_number_of_pages\">last</a>";
+ }
+ echo "</h2>";
+ }
+?>
--- /dev/null
+#!/usr/bin/python
+
+import os
+import time
+import MySQLdb
+
+db = MySQLdb.connect('localhost','dylan','password', 'dylanstestserver')
+cursor = db.cursor()
+
+notes = os.listdir('notes')
+
+sql = "SELECT title FROM notes"
+cursor.execute(sql)
+results = cursor.fetchall()
+existing_titles = []
+for row in results:
+ existing_titles.append(row[0])
+
+for note in notes:
+ if note == 'index.php' or note == 'notes.php': continue
+ url = note[:note.index('.')]
+ f = open(os.path.join('notes', note))
+ title = str(f.readline()[:-1])
+ text = ''.join(f.readlines()) #converts list to single string
+ if title in existing_titles: continue
+ mtime = time.localtime(os.path.getmtime(os.path.join('notes', note)))
+ date_posted = "%s-%s-%s" % (str(mtime.tm_year)[2:], mtime.tm_mon, mtime.tm_mday)
+ sql = "INSERT INTO notes (date_posted, url, title, text)\
+ VALUES(\"%s\", \"%s\", \"%s\", \"%s\")"\
+ % (date_posted, url, title, MySQLdb.escape_string(text))
+
+ #print sql
+ cursor.execute(sql)