tag:blogger.com,1999:blog-360193032024-02-07T07:47:21.722-05:00The World According To PTKAll kinds of stuff you wish you knew, and maybe you already did. Or not.Peter Klipsteinhttp://www.blogger.com/profile/13446282130353691495noreply@blogger.comBlogger46125tag:blogger.com,1999:blog-36019303.post-67936599644435552402018-08-30T18:38:00.001-04:002018-09-05T22:28:25.260-04:00Scraping Baseball-Reference.com with Python BeautifulSoup and pandas<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
This handy little program scrapes batting statistics data from an HTML table on the Boston Red Sox page at <a href="http://www.baseball-reference.com/">www.baseball-reference.com</a>. It converts that into a pandas DataFrame, then does various cleanup to the data set. And then the data is inserted into a PostgreSQL table.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://www.blogger.com/blogger.g?blogID=36019303" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"></a></div>
# -*- coding: utf-8 -*-<br />"""<br />Get Red Sox batting statistics from baseball-reference.com.<br />Turn it into a pandas DataFrame.<br />Insert the data into PostgreSQL.<br /><br />"""<br />import requests<br />from bs4 import BeautifulSoup<br />import lxml<br />import pandas as pd<br />import os<br />from sqlalchemy import create_engine<br />import psycopg2 <br />import io<br /><br />DATABASE_URL=os.environ['DATABASE_URL']<br /><br />def red_sox_batting_stats():<br /> # Get a page from the web<br /> url = 'https://www.baseball-reference.com/teams/BOS/2018.shtml'<br /><br /> response = requests.get(url)<br /><br /> # Process page from the web.<br /> soup = BeautifulSoup(response.text, 'lxml')<br /><br /> # Find the batting stats table.<br /> table = soup.find('table', id='team_batting')<br /><br /> # Create a matrix:<br /> # For each row, get the text from each cell.<br /> # The table has empty cells which must be replaced by something,<br /> # e.g. 'null', in order to preserve row length.<br /> outer_list = []<br /> for row in table.find_all('tr'):<br /> inner_list = []<br /> for cell in row.find_all('td'):<br /> text = cell.text<br /> inner_list.append(''.join(text) if text else 'null')<br /> outer_list.append(inner_list)<br /><br /> # Create a pandas DataFrame from the matrix. <br /> df = pd.DataFrame(outer_list)<br /> df.columns = ['Pos', 'Name', 'Age', 'G', 'PA', 'AB', 'R', 'H', '2B', \<br /> '3B', 'HR', 'RBI', 'SB', 'CS', 'BB', 'SO', 'BA', 'OBP', 'SLG', 'OPS', \<br /> 'OPS+', 'TB', 'GDP', 'HBP', 'SH', 'SF', 'IBB']<br /><br /> # Drop rows that do not contain stats.<br /> df = df[~df['Pos'].isin(['null'])]<br /> df = df.dropna()<br /> # Replace 'null' with 0. Replace (strings in parentheses) with nothing.<br /> # Replace '*' with nothing. Replace '#' with nothing.<br /> df = df.replace('null', 0).replace(r'\(.*\)', '', regex=True) \<br /> .replace(r'\*', '', regex=True).replace(r'\#', '', regex=True)<br /> <br /> # print(df.to_string()) # Print the DataFrame to the screen.<br /><br /> # Insert the DataFrame into PostgreSQL<br /> engine = create_engine(DATABASE_URL)<br /> conn = engine.raw_connection()<br /> cur = conn.cursor()<br /> output = io.StringIO()<br /> df.to_csv(output, sep='\t', header=False, index=True)<br /> output.seek(0)<br /> cur.copy_from(output, 'batting_stats_current_season')<br /> conn.commit()<br /><br />if __name__ == '__main__':<br /> red_sox_batting_stats()<br /><br />
<br />
<br />
<br />
<a href="https://www.blogger.com/blogger.g?blogID=36019303" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></a><a href="https://www.blogger.com/blogger.g?blogID=36019303" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></a><br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"><br /></span></span>
<span style="font-size: x-small;"><span style="font-family: "courier new" , "courier" , monospace;"><br /></span></span></div>
Peter Klipsteinhttp://www.blogger.com/profile/13446282130353691495noreply@blogger.com0tag:blogger.com,1999:blog-36019303.post-34908427501760200262018-08-29T14:02:00.002-04:002018-08-29T14:06:01.129-04:00Remote GUI Access from Windows to Linux<div dir="ltr" style="text-align: left;" trbidi="on">
<b id="docs-internal-guid-7f6f79ad-7fff-64e7-4e5e-3eb1914e5604" style="font-weight: normal;"></b><br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
</div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<b id="docs-internal-guid-7f6f79ad-7fff-64e7-4e5e-3eb1914e5604" style="font-weight: normal;"><span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;"><b id="docs-internal-guid-7f6f79ad-7fff-64e7-4e5e-3eb1914e5604" style="font-weight: normal;"><span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"><img height="339" src="https://lh6.googleusercontent.com/6i3kk686F-0IdeXhwDTkzKyS6unSh58PB9OdhHkLby6LhyhDZyrI8ZpqRn0ob7O_mlw2m9L0sBFqomg1wLBTbJpA4X79_A5BWnlS4zzbNhEmDBUyJJpDULOVFfjGar_yDIj8ptGA" style="border: medium none; transform: rotate(0rad);" width="624" /></span></b> </span></b></div>
<b id="docs-internal-guid-7f6f79ad-7fff-64e7-4e5e-3eb1914e5604" style="font-weight: normal;"></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<br />
<b id="docs-internal-guid-7f6f79ad-7fff-64e7-4e5e-3eb1914e5604" style="font-weight: normal;"><span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">Set up remote GUI access to a Linux host from a Windows host with VNC </span><span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"><b id="docs-internal-guid-7f6f79ad-7fff-64e7-4e5e-3eb1914e5604" style="font-weight: normal;"><span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">(Virtual Network Computing)</span></b>.</span></b><br />
<b id="docs-internal-guid-7f6f79ad-7fff-64e7-4e5e-3eb1914e5604" style="font-weight: normal;"><span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">It's easy and takes only a few minutes. It took me way longer to document it than to do it, and I had not</span></b><br />
<b id="docs-internal-guid-7f6f79ad-7fff-64e7-4e5e-3eb1914e5604" style="font-weight: normal;"><span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">done it for a few years, so that included time to research.</span></b></div>
<b id="docs-internal-guid-7f6f79ad-7fff-64e7-4e5e-3eb1914e5604" style="font-weight: normal;">
</b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<b id="docs-internal-guid-7f6f79ad-7fff-64e7-4e5e-3eb1914e5604" style="font-weight: normal;"><span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">When using virtual machines, GUI access can be very clunky even when the VM is hosted on your</span></b><br />
<b id="docs-internal-guid-7f6f79ad-7fff-64e7-4e5e-3eb1914e5604" style="font-weight: normal;"><span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">own fast, powerful, local machine. VNC provides a much faster and better experience.</span></b></div>
<b id="docs-internal-guid-7f6f79ad-7fff-64e7-4e5e-3eb1914e5604" style="font-weight: normal;">
</b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<b id="docs-internal-guid-7f6f79ad-7fff-64e7-4e5e-3eb1914e5604" style="font-weight: normal;"><span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">Description:</span></b></div>
<b id="docs-internal-guid-7f6f79ad-7fff-64e7-4e5e-3eb1914e5604" style="font-weight: normal;">
</b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<b id="docs-internal-guid-7f6f79ad-7fff-64e7-4e5e-3eb1914e5604" style="font-weight: normal;"><span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">vncserver is used to start a VNC desktop. vncserver is a Perl script which simplifies the process of</span></b><br />
<b id="docs-internal-guid-7f6f79ad-7fff-64e7-4e5e-3eb1914e5604" style="font-weight: normal;"><span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">starting an Xvnc server. It runs Xvnc with appropriate options and starts a window manager on the</span></b><br />
<b id="docs-internal-guid-7f6f79ad-7fff-64e7-4e5e-3eb1914e5604" style="font-weight: normal;"><span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">VNC desktop.</span></b></div>
<b id="docs-internal-guid-7f6f79ad-7fff-64e7-4e5e-3eb1914e5604" style="font-weight: normal;">
</b><br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<b id="docs-internal-guid-7f6f79ad-7fff-64e7-4e5e-3eb1914e5604" style="font-weight: normal;"><span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">Here is a good implementation of VNC: TigerVNC</span></b></div>
<b id="docs-internal-guid-7f6f79ad-7fff-64e7-4e5e-3eb1914e5604" style="font-weight: normal;">
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<a href="http://tigervnc.org/" style="text-decoration: none;"><span style="background-color: transparent; color: #1155cc; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: underline; vertical-align: baseline; white-space: pre;">http://tigervnc.org/</span></a></div>
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">Install the server software on the Linux host.</span></div>
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">Install the server on the Linux host. I use CentOS 7. I did this as root. You can use sudo if it makes you</span><br />
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">happy.</span></div>
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "courier new"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">yum install tigervnc-server.x86_64</span></div>
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">View documentation:</span></div>
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "courier new"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">man vncserver</span></div>
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">Create a VNC desktop with the vncserver command. You can name it what you like. I chose vnc1:</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<br /></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "courier new"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">vncserver -name vnc1</span></div>
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "courier new"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">New 'vnc1' desktop is node01:1</span></div>
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">node01 is the hostname in my case. You will see your hostname.</span></div>
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">The output tells you where the startup, config and log files live:</span></div>
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "courier new"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">Creating default startup script /root/.vnc/xstartup</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "courier new"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">Creating default config /root/.vnc/config</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "courier new"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">Starting applications specified in /root/.vnc/xstartup</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "courier new"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">Log file is /root/.vnc/node01:1.log</span></div>
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">You need to open a port in the firewall to allow remote access.</span></div>
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">First, find out what port is in use. It's 5901 for this VNC server desktop:</span></div>
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "courier new"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">ps a | grep vnc</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<br /></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "courier new"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> 2623 pts/0 S 0:00 /usr/bin/Xvnc :1 -auth /root/.Xauthority</span><br />
<span style="background-color: transparent; color: black; font-family: "courier new"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">-desktop vnc1 -fp catalogue:/etc/X11/fontpath.d -geometry 1024x768</span><br />
<span style="background-color: transparent; color: black; font-family: "courier new"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">-pn -rfbauth /root/.vnc/passwd -rfbport </span><span style="background-color: transparent; color: black; font-family: "courier new"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">5901</span><span style="background-color: transparent; color: black; font-family: "courier new"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"> -rfbwait 30000</span></div>
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">Open the port:</span></div>
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "courier new"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">firewall-cmd --permanent --add-port=<b>5901</b>/tcp</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "courier new"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">success</span></div>
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">View open ports:</span></div>
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "courier new"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">firewall-cmd --list-ports</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "courier new"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">80/tcp </span><span style="background-color: transparent; color: black; font-family: "courier new"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre;">5901</span><span style="background-color: transparent; color: black; font-family: "courier new"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">/tcp</span></div>
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">Download the Windows client binary. All binaries are here:</span></div>
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<a href="https://bintray.com/tigervnc/stable/tigervnc/1.9.0" style="text-decoration: none;"><span style="background-color: transparent; color: #1155cc; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: underline; vertical-align: baseline; white-space: pre;">https://bintray.com/tigervnc/stable/tigervnc/1.9.0</span></a></div>
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">I chose this one, the 64-bit client:</span></div>
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<a href="https://bintray.com/tigervnc/stable/download_file?file_path=tigervnc64-1.9.0.exe" style="text-decoration: none;"><span style="background-color: transparent; color: #1155cc; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: underline; vertical-align: baseline; white-space: pre;">https://bintray.com/tigervnc/stable/download_file?file_path=tigervnc64-1.9.0.exe</span></a></div>
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">The client does not require install. Put it wherever is convenient on your machine.</span></div>
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">Open it and enter the hostname and IP, and the port.</span></div>
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">Example:</span></div>
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "courier new"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"><img height="187" src="https://lh4.googleusercontent.com/40BKpaLQzidnUy3VgoHjSB29yc2umHvXmxOxY9BXbCGTRpnfeBO9WGdTkgE4yhKtyzemHcuqEdum1_4Wjxbl30eVgMBByxKq70V0J524DbMt9YXQDXBfBeIXkS3jZXi1ed0OxNUe" style="-webkit-transform: rotate(0.00rad); border: none; transform: rotate(0.00rad);" width="452" /></span></div>
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">Choose Connect and enter the password when prompted, and in a moment your desktop is ready</span><br />
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;">to go.</span></div>
<br /><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: "arial"; font-size: 11pt; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre;"><img height="339" src="https://lh6.googleusercontent.com/6i3kk686F-0IdeXhwDTkzKyS6unSh58PB9OdhHkLby6LhyhDZyrI8ZpqRn0ob7O_mlw2m9L0sBFqomg1wLBTbJpA4X79_A5BWnlS4zzbNhEmDBUyJJpDULOVFfjGar_yDIj8ptGA" style="border: medium none; transform: rotate(0rad);" width="624" /></span></div>
</b></div>
Peter Klipsteinhttp://www.blogger.com/profile/13446282130353691495noreply@blogger.com0tag:blogger.com,1999:blog-36019303.post-40904601011698616722018-07-21T17:46:00.001-04:002018-07-21T17:46:15.596-04:00The View from Here and There<div dir="ltr" style="text-align: left;" trbidi="on">
I wrote and recorded a new song today, called The View from Here and There.<br />
<br />
You can hear it <a href="https://www.youtube.com/watch?v=hFLwzHkVlHE" target="_blank">here</a>.</div>
Peter Klipsteinhttp://www.blogger.com/profile/13446282130353691495noreply@blogger.com0tag:blogger.com,1999:blog-36019303.post-55330562665803018712018-05-19T10:36:00.000-04:002018-05-19T10:38:55.112-04:00Date Dimension Table Definition<div dir="ltr" style="text-align: left;" trbidi="on">
A few weeks ago I found this <a href="https://gist.github.com/duffn/38449526e00abb47f4ec292f0491313d" target="_blank">definition</a> of a date dimension table, created by a smart person named <a href="https://www.linkedin.com/in/nicholasduffy/" target="_blank">Nicholas Duffy</a>. I'm placing it here so I can find it easily.
<pre>
DROP TABLE IF EXISTS dim_date;
CREATE TABLE dim_date
(
date_dim_id INT NOT NULL,
date_actual DATE NOT NULL,
epoch BIGINT NOT NULL,
day_suffix VARCHAR(4) NOT NULL,
day_name VARCHAR(9) NOT NULL,
day_of_week INT NOT NULL,
day_of_month INT NOT NULL,
day_of_quarter INT NOT NULL,
day_of_year INT NOT NULL,
week_of_month INT NOT NULL,
week_of_year INT NOT NULL,
week_of_year_iso CHAR(10) NOT NULL,
month_actual INT NOT NULL,
month_name VARCHAR(9) NOT NULL,
month_name_abbreviated CHAR(3) NOT NULL,
quarter_actual INT NOT NULL,
quarter_name VARCHAR(9) NOT NULL,
year_actual INT NOT NULL,
first_day_of_week DATE NOT NULL,
last_day_of_week DATE NOT NULL,
first_day_of_month DATE NOT NULL,
last_day_of_month DATE NOT NULL,
first_day_of_quarter DATE NOT NULL,
last_day_of_quarter DATE NOT NULL,
first_day_of_year DATE NOT NULL,
last_day_of_year DATE NOT NULL,
mmyyyy CHAR(6) NOT NULL,
mmddyyyy CHAR(10) NOT NULL,
weekend_indr BOOLEAN NOT NULL
);
ALTER TABLE dw.dim_date ADD CONSTRAINT dim_date_date_dim_id_pk PRIMARY KEY (date_dim_id);
CREATE INDEX dim_date_date_actual_idx
ON dim_date(date_actual);
INSERT INTO dim_date
SELECT TO_CHAR(datum,'yyyymmdd')::INT AS date_dim_id,
datum AS date_actual,
EXTRACT(epoch FROM datum) AS epoch,
TO_CHAR(datum,'fmDDth') AS day_suffix,
TO_CHAR(datum,'Day') AS day_name,
EXTRACT(isodow FROM datum) AS day_of_week,
EXTRACT(DAY FROM datum) AS day_of_month,
datum - DATE_TRUNC('quarter',datum)::DATE + 1 AS day_of_quarter,
EXTRACT(doy FROM datum) AS day_of_year,
TO_CHAR(datum,'W')::INT AS week_of_month,
EXTRACT(week FROM datum) AS week_of_year,
TO_CHAR(datum,'YYYY"-W"IW-') || EXTRACT(isodow FROM datum) AS week_of_year_iso,
EXTRACT(MONTH FROM datum) AS month_actual,
TO_CHAR(datum,'Month') AS month_name,
TO_CHAR(datum,'Mon') AS month_name_abbreviated,
EXTRACT(quarter FROM datum) AS quarter_actual,
CASE
WHEN EXTRACT(quarter FROM datum) = 1 THEN 'First'
WHEN EXTRACT(quarter FROM datum) = 2 THEN 'Second'
WHEN EXTRACT(quarter FROM datum) = 3 THEN 'Third'
WHEN EXTRACT(quarter FROM datum) = 4 THEN 'Fourth'
END AS quarter_name,
EXTRACT(isoyear FROM datum) AS year_actual,
datum + (1 -EXTRACT(isodow FROM datum))::INT AS first_day_of_week,
datum + (7 -EXTRACT(isodow FROM datum))::INT AS last_day_of_week,
datum + (1 -EXTRACT(DAY FROM datum))::INT AS first_day_of_month,
(DATE_TRUNC('MONTH',datum) + INTERVAL '1 MONTH - 1 day')::DATE AS last_day_of_month,
DATE_TRUNC('quarter',datum)::DATE AS first_day_of_quarter,
(DATE_TRUNC('quarter',datum) + INTERVAL '3 MONTH - 1 day')::DATE AS last_day_of_quarter,
TO_DATE(EXTRACT(isoyear FROM datum) || '-01-01','YYYY-MM-DD') AS first_day_of_year,
TO_DATE(EXTRACT(isoyear FROM datum) || '-12-31','YYYY-MM-DD') AS last_day_of_year,
TO_CHAR(datum,'mmyyyy') AS mmyyyy,
TO_CHAR(datum,'mmddyyyy') AS mmddyyyy,
CASE
WHEN EXTRACT(isodow FROM datum) IN (6,7) THEN TRUE
ELSE FALSE
END AS weekend_indr
FROM (SELECT '1970-01-01'::DATE + SEQUENCE.DAY AS datum
FROM GENERATE_SERIES (0,29219) AS SEQUENCE (DAY)
GROUP BY SEQUENCE.DAY) DQ
ORDER BY 1;
</pre>
<br /></div>
Peter Klipsteinhttp://www.blogger.com/profile/13446282130353691495noreply@blogger.com1tag:blogger.com,1999:blog-36019303.post-84084168069553698932018-04-16T09:11:00.002-04:002018-04-16T09:18:37.641-04:00Kingsville, Ontario Lies to the South of Uxbridge, Massachusetts, and West<div dir="ltr" style="text-align: left;" trbidi="on">
While looking at Google Maps for the umpteenth time, I finally noticed that Canada comes very far south near Detroit. It appeared to lie further south than my town, Uxbridge, Massachusetts, which is on the border between Massachusetts and Rhode Island, which is not an island. I looked it up. Sure enough, it's true. The uninhabited Pelee Island in Lake Erie, not far north of Sandusky, Ohio is, as I learned, the southernmost point in Canada. Leaving that aside, though, <a href="https://www.google.com/maps/place/Kingsville,+ON,+Canada/" target="_blank">one can see on a map</a> that Kingsville, Ontario is the southernmost town in Canada, at 42° 2' 10.68" N 82° 44' 20.4" W. The location of Uxbridge is 42° 4' 37.92" N 71° 37' 49.08" W.<br />
<br />
That puts Uxbridge 2 minutes, 27 seconds north of the southernmost town in Canada. That means I can get in my car and head southwest to Canada. And I might.</div>
Peter Klipsteinhttp://www.blogger.com/profile/13446282130353691495noreply@blogger.com0Uxbridge, MA 01569, USA42.0499476 -71.643602841.955636600000005 -71.8049643 42.1442586 -71.4822413tag:blogger.com,1999:blog-36019303.post-56099759898800247852018-04-15T21:26:00.001-04:002018-04-16T09:17:11.220-04:00tomoptamist<div dir="ltr" style="text-align: left;" trbidi="on">
to-mop-ta-mist \ tǝ-'mäp-tǝ-mǝst \ <i>n</i> [fr. tomato + optimist] : one who is optimistic about tomatoes - to-mop-ta-mis-tic <i>adj</i> - to-mop-ta-mis-ti-cal <i>adj</i> - to-mop-ta-mis-ti-cal-ly <i>adv</i><br />
<br />
Sample usage:<br />
<br />
1. <i>Of some leftover tomato</i>: "I'll leave it on the counter for now. Someone might want it. I'm a tomoptamist.'<br />
<br />
2. <i>Of a tomato of unknown quality</i>: I'll just try it. I like to think tomoptamistically.'<br />
<br />
Origin: I just made it up.</div>
Peter Klipsteinhttp://www.blogger.com/profile/13446282130353691495noreply@blogger.com0Uxbridge, MA 01569, USA42.0499476 -71.643602841.955636600000005 -71.8049643 42.1442586 -71.4822413tag:blogger.com,1999:blog-36019303.post-24588124450926616842018-04-10T22:44:00.005-04:002018-04-16T12:59:14.732-04:00Creating a PostgreSQL Database, the Use of Database Templates, and Simple Command Line Tool Commands<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: "trebuchet ms" , sans-serif;">A PostgreSQL server installation includes database templates. These are used when creating new databases.</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "trebuchet ms" , sans-serif;">By default, template1<b> </b>is copied when you create a new database. This makes it easy to create copies of a customized database design. You can customize template1, and then easily make as many copies as you like, and they will all start out with the same objects, such as tables, languages, etc.</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "trebuchet ms" , sans-serif;">Specify template0 to create a standard, out-of-the-box database with no custom additions that may have been added to your server installation. Make sure that you do not make any changes to template0.</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "trebuchet ms" , sans-serif;"><b>Create a database using template0, from a command line</b></span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "trebuchet ms" , sans-serif;">A database can be created in various ways. Here we will create one from the command line, using the tool PostgreSQL createdb.</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "trebuchet ms" , sans-serif;">By default, the logged in user will be the owner of a newly created database.</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "trebuchet ms" , sans-serif;">While logged in as user postgres, from a command line, create a database named exampledb, using template0:</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">bash-4.2$ createdb -e --template=template0 exampledb</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">SELECT pg_catalog.set_config('search_path', '', false)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">CREATE DATABASE exampledb TEMPLATE template0;</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "trebuchet ms" , sans-serif;">Start psql, the command line tool:</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">bash-4.2$ psql</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">psql (10.3)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">Type "help" for help.</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "trebuchet ms" , sans-serif;"><b>List the databases, and see that the new database, exampledb, has been added</b></span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">postgres=# \l</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> List of databases</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> Name | Owner | Encoding | Collate | Ctype | Access privileges</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">-----------+----------+----------+-------------+-------------+-----------------------</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> exampledb | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> | | | | | postgres=CTc/postgres</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> | | | | | postgres=CTc/postgres</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">(4 rows)</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "trebuchet ms" , sans-serif;"><b>Connect to exampledb</b></span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">postgres=# \c exampledb</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">You are now connected to database "exampledb" as user "postgres".</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "trebuchet ms" , sans-serif;"><b>Create a table</b></span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">exampledb=# create table t1 (</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">col1 varchar(50)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">);</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">CREATE TABLE</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "trebuchet ms" , sans-serif;"><b>View details about the new table</b></span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">exampledb=# \dS t1</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> Table "public.t1"</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> Column | Type | Collation | Nullable | Default</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">--------+-----------------------+-----------+----------+---------</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> col1 | character varying(50) | | |</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "trebuchet ms" , sans-serif;">psql, the Postgresql command line tool, features a long list of commands that are cryptic, even by command line tool standards. It is easy to look up the commands, though.</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "trebuchet ms" , sans-serif;"><b>Start psql</b></span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">bash-4.2$ psql</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">psql (10.3)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">Type "help" for help.</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "trebuchet ms" , sans-serif;"><b>View help</b></span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "trebuchet ms" , sans-serif;">Now type </span><b><span style="font-family: "courier new" , "courier" , monospace;">\?</span></b><span style="font-family: "trebuchet ms" , sans-serif;"> to view a long list of commands to interact with the database.</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "trebuchet ms" , sans-serif;">Type </span><b><span style="font-family: "courier new" , "courier" , monospace;">\h</span></b><span style="font-family: "trebuchet ms" , sans-serif;"> to view another long list of commands to create, alter, and drop database objects such as tables and views, etc.</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "trebuchet ms" , sans-serif;"><b>Quit psql</b></span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "trebuchet ms" , sans-serif;">Type </span><b><span style="font-family: "courier new" , "courier" , monospace;">\q</span></b><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span></div>
Peter Klipsteinhttp://www.blogger.com/profile/13446282130353691495noreply@blogger.com0Uxbridge, MA 01569, USA42.0499476 -71.643602841.955636600000005 -71.8049643 42.1442586 -71.4822413tag:blogger.com,1999:blog-36019303.post-37565423501751774132018-04-09T08:23:00.000-04:002018-04-16T12:58:06.666-04:00Python and PostgreSQL: Create a PostgreSQL Database Connection Using a Config File<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: "trebuchet ms" , sans-serif;">This technique can easily be applied to other databases.</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "trebuchet ms" , sans-serif;">1. pip install two packages if you do not already have them in your Python environment.</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "trebuchet ms" , sans-serif;">(Search the internet for ‘python pip install’ if you need help.)</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "trebuchet ms" , sans-serif;">A. psycopg2: To interact with PostgreSQL databases</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "trebuchet ms" , sans-serif;">B. configparser: To interact with config files</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "trebuchet ms" , sans-serif;">2. Create a config file named config.ini. Paste in the text below:</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "trebuchet ms" , sans-serif;">[</span><span style="font-family: "courier new" , "courier" , monospace;">default]</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">host = localhost</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">db_name = your_database_name</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">postgres_user = postgres_username</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">postgres_password = your_password</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "trebuchet ms" , sans-serif;">Edit the details to match your environment.</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "trebuchet ms" , sans-serif;">3. Create a Python file named main.py. Paste in the text below:</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">from configparser import SafeConfigParser</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">import psycopg2</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">parser = SafeConfigParser()</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">parser.read('config.ini')</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">host = parser.get('default', 'host')</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">db_name = parser.get('default', 'db_name')</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">postgres_user = parser.get('default', 'postgres_user')</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">postgres_password = parser.get('default', 'postgres_password')</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">print('Python program: Connect to a PostgeSQL database.\n')</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">conn_string = "host='%s' dbname='%s' user='%s' password='%s'" % (host, db_name, postgres_user, \</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> postgres_password)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">conn = psycopg2.connect(conn_string)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">cursor = conn.cursor() # Required to interact with the database.</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">sql = """</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">SELECT current_database();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">"""</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">print("Query sent to the database:")</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">print(sql)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">cursor.execute(sql)</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"># Note: If inserting data, Commit after executing the cursor, or nothing will happen.</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">#conn.commit()</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"># Building an output string:</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">sql_output = ''</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">for record in cursor:</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> sql_output += str(record) + '\n'</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;"># Write the output from the database:</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">print(sql_output)</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "trebuchet ms" , sans-serif;">4. Test the program. Run this command at a command prompt:</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">python main.py</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "trebuchet ms" , sans-serif;">Program output:</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">Python program: Connect to a PostgeSQL database.</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">Query sent to the database:</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">SELECT current_database();</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">('your_database_name',)</span><br />
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span>
<span style="font-family: "trebuchet ms" , sans-serif;"><span id="docs-internal-guid-bb61203b-aa5a-896c-06b6-534eebb4b3fa" style="font-weight: normal;"></span>
</span>
<span style="font-family: "trebuchet ms" , sans-serif;">Your output will look slightly different, unless your database is named ‘your_database_name’.</span><br />
<div dir="ltr" style="line-height: 1.656; margin-bottom: 0pt; margin-top: 0pt;">
<span style="font-family: "trebuchet ms" , sans-serif;"><br /></span></div>
<br /></div>
Peter Klipsteinhttp://www.blogger.com/profile/13446282130353691495noreply@blogger.com0Uxbridge, MA 01569, USA42.0499476 -71.643602841.955636600000005 -71.8049643 42.1442586 -71.4822413tag:blogger.com,1999:blog-36019303.post-77229588296285640712018-04-07T15:50:00.001-04:002018-04-07T22:58:41.016-04:00Convert a wav file to mp3 with FFmpeg, pydub, and three lines of Python<div dir="ltr" style="text-align: left;" trbidi="on">
Ten minutes ago I played <a href="https://www.youtube.com/watch?v=KQa3RPTt7ag" target="_blank">a song</a> I had not heard before and said, that was a good song! I should send it to Sam. But it's in WAV format so it's really big.<br />
<br />
Wouldn't it be nice if Python could convert it to mp3 to make it smaller?<br />
<br />
Ten minutes later it was done. Amazing.<br />
<br />
Here are the easy steps to follow if you would like to try it.<br />
<br />
1. Search the internet for 'python convert wav mp3'.<br />
<br />
2. Download FFmpeg and add it to your system path:<br />
<br />
<a href="http://adaptivesamples.com/how-to-install-ffmpeg-on-windows/">http://adaptivesamples.com/how-to-install-ffmpeg-on-windows/</a><br />
<br />
3. 'pip install pydub', then copy some sample code from here and make slight adjustments to match your file paths and song file name:<br />
<br />
<a href="https://github.com/jiaaro/pydub">https://github.com/jiaaro/pydub</a><br />
<br />
4. Run the script:<br />
<br />
from pydub import AudioSegment<br />
song = AudioSegment.from_wav("G:/Music/Rock/The I Don't Cares/Wild Stab/Sorry for Tomorrow Night.wav")<br />
song.export("Sorry for Tomorrow Night.mp3", format="mp3")<br />
<br />
5. Email the mp3 file to Sam.<br />
<br />
And done in less than ten minutes.<br />
<br />
Thank you, programmers and documenters of the internet.<br />
<br />
The Song: Sorry for Tomorrow Night (<a href="https://en.wikipedia.org/wiki/Paul_Westerberg" target="_blank">Westerberg</a>) - The I Don't Cares</div>
Peter Klipsteinhttp://www.blogger.com/profile/13446282130353691495noreply@blogger.com0Uxbridge, MA 01569, USA42.0499476 -71.643602841.955636600000005 -71.8049643 42.1442586 -71.4822413tag:blogger.com,1999:blog-36019303.post-33795102309312146342018-03-15T01:36:00.000-04:002018-04-05T19:16:30.595-04:00The Use of Views Has No Impact on Query Performance in PostgreSQL<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="background-color: white; font-family: "arial" , "helvetica" , sans-serif;">More evidence that PostgreSQL is the best database. The documentation supports one of my strongest beliefs about database design:</span><br />
<blockquote class="tr_bq" style="background-color: white; line-height: 1.5em; margin: 1.2em 0em; text-align: left;">
<blockquote class="tr_bq">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Making liberal use of views is a key aspect of good SQL database design. Views allow you to encapsulate the details of the structure of your tables, which might change as your application evolves, behind consistent interfaces.</span></blockquote>
<blockquote>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Views can be used in almost any place a real table can be used. Building views upon other views is not uncommon.</span></blockquote>
</blockquote>
<div style="background-color: white; line-height: 1.5em; margin: 1.2em 0em; text-align: left;">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Source: <a href="https://www.postgresql.org/docs/10/static/tutorial-views.html">https://www.postgresql.org/docs/10/static/tutorial-views.html</a></span></div>
<div style="background-color: white; line-height: 1.5em; margin: 1.2em 0em; text-align: left;">
<span style="background-color: transparent;"><span style="font-family: "arial" , "helvetica" , sans-serif;">In answer to a question about the impact of views on query performance, veteran PostgreSQL core developer Bruce Momjian gave the following answer: They have no impact whatsoever.</span></span></div>
<div style="background-color: white; line-height: 1.5em; margin: 1.2em 0em; text-align: left;">
</div>
<blockquote class="tr_bq">
<span style="font-family: "arial" , "helvetica" , sans-serif;">The parser thinks the view is a real table. The query structure gets passed to the re-writer and the re-writer wipes out the view and substitutes the underlying tables. And that re-write is what gets passed to the query optimizer. The optimizer doesn't see the view; it's optimizing the whole thing.</span></blockquote>
<blockquote class="tr_bq">
<span style="font-family: "arial" , "helvetica" , sans-serif;">Some other systems have a problem optimizing views. We don't because by the time the views gets through the re-writer it's been wiped away and you get a fresh optimization of the underlying tables, and the view has disappeared because now that view is not a black box. We can join and use whatever indexes we want because we see the underlying data by the time we get to the optimizer, and that's why we have to do the re-writing before we get to the optimizer.</span></blockquote>
<span style="font-family: "arial" , "helvetica" , sans-serif;">I worked at a job not long ago where I arrived in my new position, started creating views, and then the CTO saw what I was I was doing and <i>disallowed the use of views</i>.</span><span style="font-family: "arial" , "helvetica" , sans-serif;">Things quickly went downhill from there.</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><br /></span>
<span style="font-family: "arial" , "helvetica" , sans-serif;">Source of Bruce Momjian's quote:</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">"Tutorial Presented by Bruce Momjian of EnterpriseDB at PGConf Silicon Valley 2015"</span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;"><a href="https://www.youtube.com/watch?v=JFh22atXTRQ">https://www.youtube.com/watch?v=JFh22atXTRQ</a></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">Presentation URL: <a href="http://momjian.us/main/writings/pgsql/internalpics.pdf" target="_blank">http://momjian.us/main/writings/pgsql/internalpics.pdf</a></span><br />
<span style="font-family: "arial" , "helvetica" , sans-serif;">Quoted from time starting at 1:00:57</span><br />
<blockquote class="tr_bq" style="text-align: left;">
</blockquote>
</div>
Peter Klipsteinhttp://www.blogger.com/profile/13446282130353691495noreply@blogger.com0Uxbridge, MA 01569, USA42.0499476 -71.643602841.955636600000005 -71.8049643 42.1442586 -71.4822413tag:blogger.com,1999:blog-36019303.post-84252865638372685652018-02-02T13:32:00.000-05:002018-04-16T12:56:47.181-04:00The Internet Can Be Useful If Used Properly<div dir="ltr" style="text-align: left;" trbidi="on">
This post is here because I had not added one for two-and-a-half years.
In the interim, the world has not suffered from the lack of my posting.
(It has suffered for other reasons, but let's not get into that. The
idea here is not to be depressing, no, far from it.)<br />
<br />
Nonetheless,
I feel compelled to put something here, if only to be able to say to
myself, "Good job, Pete. You have done it. Let this be a start, and soon
you will add many fabulous things to your blog. It will be part of a
personal Renaissance. Let many flowers bloom." Or something along those
lines. Something very positive and good. <br />
<br />
Anyway, music continues to be really good. You only need to look for it. One of the best ways is via YouTube. Being a reasonably intelligent person, I find a visit to the front page of YouTube demoralizing. I really don't want to even know what is popular. Knowing about popular things is a great way for me to get really discouraged.<br />
<br />
However, if you search for something good on YouTube, whether a band, director, author -- something that you already know or suspect is good -- and then start digging from there, then oh boy will you find a lot of good and interesting stuff. (You probably already know this, but why not remind you of something really good.) This also holds very true for Wikipedia and IMDb. The thing is start digging and keep digging. Also, <a href="https://archive.org/details/texts/" target="_blank">Internet Archive Texts</a> is amazing. You want to read a first person account about someone traveling through the Middle East in 1905? Which one of several hundred would you prefer? That's just a semi-made up example that illustrates well what they have in that archive. Also, <a href="https://translate.google.com/" target="_blank">Google Translate</a> does its job very well. Plus, <a href="http://www.uxbridgelibrary.org/" target="_blank">your library</a> lets you borrow stuff for free, and they will get stuff from all over your state and have it shipped to your local branch down the street. And if you use their services, then they won't go away, leaving another possible location for a new, hastily constructed T-Mobile store or something equally dispiriting.<br />
<br />
Here's my latest example on profitably digging, from what was five minutes ago until I started typing and editing endlessly: I looked up <a href="https://en.wikipedia.org/wiki/Matthew_Caws" target="_blank">the main guy</a> from the band Nada Surf because he did some nice solo stuff on KEXP, then recognized the name of <a href="https://en.wikipedia.org/wiki/Doug_Gillard" target="_blank">another guy in that band</a>, found out that the reason I recognized his name is that he played in the band Guided by Voices, and in the process found out about <a href="https://en.wikipedia.org/wiki/Mist_King_Urth" target="_blank">yet another project</a> that Robert Pollard of Guided By Voices did, with that guy, then looked up one of their albums on YouTube, because of course it was there, because (almost) everything is on YouTube, then listened to it and liked it a lot. Here is a link to <a href="https://www.youtube.com/playlist?list=PLjX8m3AnGzmWW1VTKzRACdfbpTu3lZhV-" target="_blank">a playlist</a> that includes most of the tracks from the album. If you are the sort of person who likes rock and roll made with guitars, then you will like it.<br />
<br />
I decided to buy it, so I looked on Amazon, where I check first to see if an album is available, hopefully used, not because it pleases me to help Amazon wipe out every single other business on the planet, but because I like the convenience. However, the album is like fifty bucks used on Amazon, so I remembered to check <a href="http://discogs.com/" target="_blank">Discogs.com</a>, which is amazing, and lists approximately five zillion albums and links them to people selling them. (<a href="http://allmusic.com/" target="_blank">Allmusic.com</a> is also amazing, even though it has an uninspiring corporate design and front page that you'll want to ignore, because it is like the IMDb of music, in that the majority of the bands and albums on Earth are listed and everything is highly searchable and linked to everything else, allowing for endless exploration.) On Discogs it was only seven dollars -- four for the disc and three for shipping. So I highly recommend Discogs, both for researching recordings and for buying them.<br />
<br />
To wrap up, the main guy from Nada Surf is named Matthew Caws. <a href="https://www.youtube.com/watch?v=iMcn3_67anM" target="_blank">This song he performed solo on KEXP</a> is tremendous. You might even want to listen to it all over again as soon as he gets to the end. For me, it's one of those tunes. Also, the album referenced above, Mist King Urth, by Lifeguards, is definitely good enough to listen to in its entirely at least twice in a row, even or especially at moderate to high volume. I just proved it.<br />
<br /></div>
Peter Klipsteinhttp://www.blogger.com/profile/13446282130353691495noreply@blogger.com0tag:blogger.com,1999:blog-36019303.post-67910702916871344502015-08-22T09:31:00.001-04:002018-04-07T23:00:23.446-04:00The Three Acts of the Mind<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
The acts of the mind, wherein it exerts its power over simple ideas,
are chiefly these three:<br />
<br />
1. Combining several simple ideas into one
compound one, and thus all complex ideas are made.<br />
<br />
2. The second is
bringing two ideas, whether simple or complex, together, and setting
them by one another so as to take a view of them at once, without
uniting them into one, by which it gets all its ideas of relations.<br />
<br />
3. The third is separating them from all other ideas that accompany
them in their real existence: this is called abstraction, and thus all
its general ideas are made.<br />
<br />
<a href="https://www.blogger.com/null" name="%_idx_6"></a>-- John Locke, <i>An Essay Concerning Human Understanding</i>
(1690)</div>
Peter Klipsteinhttp://www.blogger.com/profile/13446282130353691495noreply@blogger.com0Uxbridge, MA 01569, USA42.0499476 -71.643602841.955636600000005 -71.8049643 42.1442586 -71.4822413tag:blogger.com,1999:blog-36019303.post-89556726340012744842015-06-25T23:20:00.002-04:002018-04-05T18:43:45.872-04:0097 Things Every Programmer Should Know<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="firstHeading" style="text-align: left;">
This collection of short articles about <a href="http://programmer.97things.oreilly.com/wiki/index.php/Contributions_Appearing_in_the_Book" target="_blank">programming best practices</a> is well worth perusing. Courtesy of O'Reilly Media.</div>
<div class="firstHeading" style="text-align: left;">
<br /></div>
<div class="firstHeading" style="text-align: left;">
<br /></div>
<div class="firstHeading" style="text-align: left;">
<br /></div>
</div>
Peter Klipsteinhttp://www.blogger.com/profile/13446282130353691495noreply@blogger.com0tag:blogger.com,1999:blog-36019303.post-27383867778023483592015-06-24T21:21:00.002-04:002018-02-09T08:05:27.564-05:00In Appreciation of Procedural Programming<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="bio">
</div>
<div class="bio">
I think the lack of reusability comes in object-oriented languages.... [T]he problem with object-oriented languages is they've got all this
implicit environment that they carry around with them. You wanted a
banana but what you got was a gorilla holding the banana and the entire
jungle.</div>
<div class="bio">
<br />
-- Joe Armstrong</div>
</div>
Peter Klipsteinhttp://www.blogger.com/profile/13446282130353691495noreply@blogger.com0tag:blogger.com,1999:blog-36019303.post-82577789741550674882014-04-10T14:48:00.001-04:002018-04-16T12:57:20.206-04:00Beatiful Day, Sox @ Yankees Tonight<div dir="ltr" style="text-align: left;" trbidi="on">
Beautiful day today, and the Sox play their first game of the 2014 season against the Yankees tonight in the Bronx. Birds are chirping outside, and I can hear the last touches being put on a new bridge over the creek down the hill. An excellent day indeed.</div>
Peter Klipsteinhttp://www.blogger.com/profile/13446282130353691495noreply@blogger.com0tag:blogger.com,1999:blog-36019303.post-84200651119009855892014-01-24T12:42:00.001-05:002018-04-07T23:00:51.974-04:00Your Opinion May Not Be Helping Things<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
Science is not designed to support your opinion. Instead, it is designed to reveal facts derived from empirical evidence.<br />
<br />
It is not the responsibility of facts to agree with what you might think. If you have placed yourself in a position to be bereft of them, facts do not care. They have no ability to care. They are only facts.<br />
<br />
If facts make you uncomfortable, try to figure out why this is so.<br />
<br />
This may not be your fault. Indeed, it is most likely that you have been misled about the illuminating qualities of facts. Perhaps your father did not embrace reason. That would be discouraging. Perhaps your mother didn't know how to show that she loved you. She did. It's okay.<br />
<br />
You can do better. You can start to learn about the way things work in the actual universe. There is much data available. And if you can read, you need only start reading.<br />
<br />
I wish you the best of luck.</div>
Peter Klipsteinhttp://www.blogger.com/profile/13446282130353691495noreply@blogger.com0Uxbridge, MA 01569, USA42.0499476 -71.643602841.955636600000005 -71.8049643 42.1442586 -71.4822413tag:blogger.com,1999:blog-36019303.post-17082685758229682252013-10-20T20:20:00.001-04:002018-04-07T22:59:23.500-04:00Install the JDK Development Version on CentOS<div dir="ltr" style="text-align: left;" trbidi="on">
If you want access to Java tools like jar and javac, install the development version of the JDK.<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;"># yum install java-1.7.0-openjdk-devel </span><br />
<br />
Add the bin directory to your PATH so you can run the Java programs from anywhere.<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;"># PATH=$PATH:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.25.x86_64/bin</span><br />
<br />
View the classes in a jar file.<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;"># jar tvf dt.jar </span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> 0 Mon Jul 01 09:51:04 EDT 2013 META-INF/</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> 71 Mon Jul 01 09:51:04 EDT 2013 META-INF/MANIFEST.MF</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> 0 Mon Jul 01 09:51:00 EDT 2013 javax/</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> 0 Mon Jul 01 09:51:04 EDT 2013 javax/swing/</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> 4486 Mon Jul 01 09:51:04 EDT 2013 javax/swing/JSliderBeanInfo.class</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> 3342 Mon Jul 01 09:51:04 EDT 2013 javax/swing/JFormattedTextFieldBeanInfo.class</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> 3025 Mon Jul 01 09:51:04 EDT 2013 javax/swing/JMenuBarBeanInfo.class</span></div>
Peter Klipsteinhttp://www.blogger.com/profile/13446282130353691495noreply@blogger.com0tag:blogger.com,1999:blog-36019303.post-44561780488375742512011-08-24T20:38:00.000-04:002018-04-07T23:02:19.383-04:00Climate-Gate Scientist Cleared Over and Over Again<div dir="ltr" style="text-align: left;" trbidi="on">
James Fallows, who is an excellent veteran writer for <i>The Atlantic</i>, <a href="http://www.theatlantic.com/technology/archive/2011/08/michael-mann-cleared-again/244051/">published a post</a> today about "climate-gate" scientist Michael Mann being cleared of all wrongdoing yet again, this time by the National Science Foundation. As is often the case, Mr. Fallows raises a lot of good points using a small number of words, and provides some nice links. One of the points is the amazing and disturbing rejection of well-established science by nearly the entire Republican party. As I once heard Chris Matthews say to Pat Buchanan, these guys "would have been great in the Dark Ages." What would Abe Lincoln be thinking right now if he could see this?</div>
Peter Klipsteinhttp://www.blogger.com/profile/13446282130353691495noreply@blogger.com0Uxbridge, MA 01569, USA42.0499476 -71.643602841.955636600000005 -71.8049643 42.1442586 -71.4822413tag:blogger.com,1999:blog-36019303.post-11719841396065848522011-08-23T20:00:00.001-04:002011-08-23T20:00:58.150-04:00Tripoli Falls to Rebels, Earthquake in Virgina<div dir="ltr" style="text-align: left;" trbidi="on">After months of fighting to end Qaddafi's forty years of lunatic despotic rule in Libya, rebel fighters now control most of Tripoli, the capitol city, and today breached the walls of the presidential compound, where thousands celebrated and carried off booty and weapons. And on the same day, I felt my tenth floor cubicle in South Boston begin to sway at around two this afternoon, the result of a 5.8 earthquake all the way down in Virginia.</div>Peter Klipsteinhttp://www.blogger.com/profile/13446282130353691495noreply@blogger.com0tag:blogger.com,1999:blog-36019303.post-14304221316671030262011-08-21T11:52:00.001-04:002018-04-07T23:02:59.626-04:00Economic Stimulus and the English Language<div dir="ltr" style="text-align: left;" trbidi="on">
I just heard Orioles Hall of Famer Cal Ripken mispronounce the word "peripheral" as "periphial" on the MLB Network. This is one of the most commonly bungled English words, in my experience.<br />
<br />
A small way to stimulate the economy while improving English usage would be to create signs that teach proper spelling, pronunciation and usage of commonly botched words, and place them in public spaces.</div>
Peter Klipsteinhttp://www.blogger.com/profile/13446282130353691495noreply@blogger.com0Uxbridge, MA 01569, USA42.0499476 -71.643602841.955636600000005 -71.8049643 42.1442586 -71.4822413tag:blogger.com,1999:blog-36019303.post-46040585636617130992011-08-17T14:24:00.001-04:002018-04-07T23:02:33.974-04:00Grizzly Bear's "While You Wait For The Others" on KCRW<div dir="ltr" style="text-align: left;" trbidi="on">
This <a href="http://www.youtube.com/watch?v=CxinSS5KJNg" target="new">2008 performance</a> of "While You Wait For The Others," by the band Grizzly Bear, is mellow and trippy, with a muddy, popping guitar sound, a pleasing melody, sweet harmonies, and a rhythm section featuring nice snare work, quiet organ, interesting bass fills, and I say that this is a doggone pretty song. Recorded live for the show Morning Becomes Eclectic in the studios of KCRW, my old beloved Santa Monica Community College radio station. I drove many a mile around Southern California soaking up the musical and spoken sounds of this fine outlet. Long live KCRW.</div>
Peter Klipsteinhttp://www.blogger.com/profile/13446282130353691495noreply@blogger.com0tag:blogger.com,1999:blog-36019303.post-91896160869569050062011-08-12T20:56:00.002-04:002018-04-07T23:20:55.708-04:00How Algorithms Shape Our World<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
Check out <a href="http://www.ted.com/talks/kevin_slavin_how_algorithms_shape_our_world.html">this video</a> by Kevin Slavin at a recent TED talk.</div>
Peter Klipsteinhttp://www.blogger.com/profile/13446282130353691495noreply@blogger.com0Uxbridge, MA 01569, USA42.0499476 -71.643602841.955636600000005 -71.8049643 42.1442586 -71.4822413tag:blogger.com,1999:blog-36019303.post-31684560258571086882011-08-10T22:01:00.000-04:002018-04-07T23:21:24.443-04:00What Ails the Field of Economics, by Mark_BC<div dir="ltr" style="text-align: left;" trbidi="on">
I'm mighty impressed by this explanation of what ails the field of economics. It's not what you expect, whatever it is that you expect. This is very good:<br />
<br />
<a href="http://www.amazon.com/review/R1FRA5LD2PG6HT/">http://www.amazon.com/review/R1FRA5LD2PG6HT/</a><br />
<br />
So now I'm going to read this at his blog:<br />
<br />
<a href="http://markbc.wordpress.com/thermodynamics-for-economists/%20">http://markbc.wordpress.com/thermodynamics-for-economists/ </a><br />
<br />
Do what I did and read the first thing first, though. It's well worth it.<br />
<br />
<br /></div>
Peter Klipsteinhttp://www.blogger.com/profile/13446282130353691495noreply@blogger.com0Uxbridge, MA 01569, USA42.0499476 -71.643602841.955636600000005 -71.8049643 42.1442586 -71.4822413tag:blogger.com,1999:blog-36019303.post-14472980074840186442011-08-08T18:27:00.001-04:002018-04-07T23:21:54.825-04:00Sox Win in Ten, Take Series Against Yanks, 2-1<div dir="ltr" style="text-align: left;" trbidi="on">
Last night the Red Sox returned to first place in the standings, when they beat the Yankees on a tenth-inning walk-off single by rookie right fielder Josh Reddick, after they had tied it in the ninth against the great Mariano Rivera. That gives Rivera fourteen blown saves against the Red Sox in his career. No other team in baseball has gotten to him more than eight times. <br />
<br />
Tonight Tim Wakefield will start the first game of a three-game set in Minnesota. This will be his third try at career win number 200.<br />
<br />
<br /></div>
Peter Klipsteinhttp://www.blogger.com/profile/13446282130353691495noreply@blogger.com0Uxbridge, MA 01569, USA42.0499476 -71.643602841.955636600000005 -71.8049643 42.1442586 -71.4822413tag:blogger.com,1999:blog-36019303.post-51967292023479086932011-08-07T12:47:00.000-04:002018-04-07T23:22:39.231-04:00Growth, or the Lack Thereof<div dir="ltr" style="text-align: left;" trbidi="on">
Who thinks the US will experience economic growth sufficient to lower the unemployment rate below 6% any time in the next eight to ten years in the absence of major government stimulus?</div>
Peter Klipsteinhttp://www.blogger.com/profile/13446282130353691495noreply@blogger.com0Uxbridge, MA 01569, USA42.0499476 -71.643602841.955636600000005 -71.8049643 42.1442586 -71.4822413