mirror of
https://github.com/correl/correl.github.io.git
synced 2025-04-09 17:00:05 -09:00
Initial commit
This commit is contained in:
commit
413e363e43
10 changed files with 333 additions and 0 deletions
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
*~
|
||||
_site/
|
||||
Gemfile.lock
|
2
Gemfile
Normal file
2
Gemfile
Normal file
|
@ -0,0 +1,2 @@
|
|||
source 'https://rubygems.org'
|
||||
gem 'github-pages'
|
6
_config.yml
Normal file
6
_config.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
url: http://wp.phoenixinquis.is-a-geek.org
|
||||
name: correl.phoenixinquis.net
|
||||
description: projects and coding adventures
|
||||
|
||||
markdown: redcarpet
|
||||
excerpt_separator: <!--more-->
|
16
_posts/2011-04-27-26.md
Normal file
16
_posts/2011-04-27-26.md
Normal file
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
title: Potatoes and Portal Guns
|
||||
author: Correl Roush
|
||||
layout: post
|
||||
permalink: /2011/04/27/26/
|
||||
categories:
|
||||
- Games
|
||||
tags:
|
||||
- portal
|
||||
- xbox
|
||||
---
|
||||
[<img src="/images/portal_2_logo-150x150.jpg" alt="Portal 2 Logo" title="Portal 2 Logo" width="150" height="150" style="float: right" />](/images/portal_2_logo.jpg) Got my hands on Portal 2 and finished a run through the single player campaign. Was a *lot* of fun, the characters were bursting with humor and personality. Just like the first game, it was hard to stop playing. *Unlike* the first game, it's got some length, so I stayed up late a couple nights with my eyes glued to the television. I already want to play through it again to find any little things I my tired eyes may have missed.
|
||||
|
||||
I'm itching to give co-op a try, so if you happen to have it on xbox or care to drop by, let me know.
|
||||
|
||||
**Update:** Played some co-op with Jen, had fun navigating puzzles together :)
|
44
_posts/2011-04-27-meh-php.md
Normal file
44
_posts/2011-04-27-meh-php.md
Normal file
|
@ -0,0 +1,44 @@
|
|||
---
|
||||
title: Meh.php
|
||||
author: Correl Roush
|
||||
layout: post
|
||||
permalink: /2011/04/27/meh-php/
|
||||
categories:
|
||||
- Programming
|
||||
tags:
|
||||
- php
|
||||
---
|
||||
|
||||
```php
|
||||
<?php
|
||||
if (!defined('meh')) define('meh', null);
|
||||
|
||||
class Meh {
|
||||
public function __set($name, $value) {
|
||||
}
|
||||
public function __get($name) {
|
||||
return meh;
|
||||
}
|
||||
public function __isset($name) {
|
||||
return true || false;
|
||||
}
|
||||
public function __unset($name) {
|
||||
}
|
||||
public function __call($name, $arguments) {
|
||||
return meh;
|
||||
}
|
||||
public function __callStatic($name, $arguments) {
|
||||
return meh;
|
||||
}
|
||||
}
|
||||
|
||||
$bwuh = new Meh();
|
||||
$bwuh->give_a_shit();
|
||||
echo $bwuh->concerns;
|
||||
|
||||
class SuperDuperBillingProcessor extends Meh {}
|
||||
|
||||
$p = new SuperDuperBillingProcessor();
|
||||
$p->calculateEverything();
|
||||
$p->profit();
|
||||
```
|
125
_posts/2011-04-27-transmission-rss-and-xbmc.md
Normal file
125
_posts/2011-04-27-transmission-rss-and-xbmc.md
Normal file
|
@ -0,0 +1,125 @@
|
|||
---
|
||||
title: Transmission, RSS and XBMC
|
||||
author: Correl Roush
|
||||
layout: post
|
||||
permalink: /2011/04/27/transmission-rss-and-xbmc/
|
||||
categories:
|
||||
- Programming
|
||||
tags:
|
||||
- bittorrent
|
||||
- htpc
|
||||
- linux
|
||||
- python
|
||||
- transmission
|
||||
- xbmc
|
||||
format: standard
|
||||
---
|
||||
I'm a huge fan of [XBMC](http://www.xbmc.org/). My pc (currently running Ubuntu 10.04) has taken root in my
|
||||
living room, piping all my movies and tv shows straight to my HDTV.
|
||||
|
||||
While my pc is set up as a DVR using [MythTV](http://www.mythtv.org) to record shows off my FIOS box, it tends to be a little unreliable, which can suck when it's time to catch up on Daily Show and Colbert episodes.
|
||||
I've had [Transmission](http://www.transmissionbt.com/) set up for a while for all my torrenting needs, and
|
||||
I've even written an [XBMC script to manage torrents](https://github.com/correl/Transmission-XBMC), so I got to looking for
|
||||
tools to track tv show torrent rss feeds.
|
||||
|
||||
<!--more-->
|
||||
|
||||
My first stop was [TED](http://ted.nu/). TED worked well enough, but would occasionally hang.
|
||||
Since it's a GUI java app running in the taskbar, it would require me to dig
|
||||
out my mouse and break out of full screen XBMC to fiddle with it. I eventually
|
||||
got tired of dealing with TED and went back to prodding Myth.
|
||||
|
||||
Recently I've been itching to reliably watch my shows again, so I checked around
|
||||
for a simple command-line utility to track rss feeds and download torrents.
|
||||
Finding none, I loaded up vim and threw together a python script to handle it
|
||||
all for me.
|
||||
|
||||
I also have another, simple script from when I was using TED (or just manually
|
||||
downloading shows) which looks at completed torrents, compares their names with
|
||||
the folders in my TV directory, and moves the shows into them for XBMC to see.
|
||||
|
||||
A couple cron jobs and a few rss feeds later, and I've got all my shows
|
||||
automatically delivered straight to XBMC for my lazy evening viewing pleasure.
|
||||
|
||||
### trss.py
|
||||
[Download](https://github.com/correl/trss/raw/master/trss.py)
|
||||
|
||||
```
|
||||
Usage:
|
||||
trss.py add <rss-url> [<recent-items>]
|
||||
Adds an RSS feed to follow
|
||||
rss-url: Full URL to the RSS feed
|
||||
recent-items: (Optional) number of recent items to queue
|
||||
for downloading
|
||||
trss.py remove <index>
|
||||
Remove an RSS feed
|
||||
index: Numeric index of the feed to remove as
|
||||
reported by the list command
|
||||
trss.py list
|
||||
Displays a list of followed feeds
|
||||
|
||||
trss.py download
|
||||
Fetch all feeds and download new items
|
||||
|
||||
trss.py set [<setting> [<value>]]
|
||||
Set or view configuration settings
|
||||
Call without any arguments to list all settings and their values
|
||||
Call with a setting and no value to see the current value for that setting
|
||||
|
||||
Currently, the only used setting is 'download_dir', which allows you to set
|
||||
a directory to store all retrieved torrents, such as a directory your
|
||||
torrent application watches for new downloads. If 'download_dir' is not set,
|
||||
the current directory will be used.
|
||||
```
|
||||
|
||||
### transmission-tv.py
|
||||
```python
|
||||
#!/usr/bin/python
|
||||
import os
|
||||
import re
|
||||
|
||||
import transmissionrpc
|
||||
|
||||
TV_PATH = '/media/Gaia/Video/TV/'
|
||||
|
||||
class TVShowCollection:
|
||||
def __init__(self, path):
|
||||
self.path = path
|
||||
self.shows = os.listdir(path)
|
||||
self.patterns = [[s.lower().replace(' ', '.?'), s] for s in sorted(self.shows, key=len, reverse=True)]
|
||||
def match(self, filename):
|
||||
for pattern, show in self.patterns:
|
||||
if re.findall(pattern, filename.lower()):
|
||||
return show
|
||||
return None
|
||||
|
||||
def move(self, ids, location):
|
||||
"""Move torrent data to the new location."""
|
||||
self._rpc_version_warning(6)
|
||||
args = {'location': location, 'move': True}
|
||||
self._request('torrent-set-location', args, ids, True)
|
||||
|
||||
if float(transmissionrpc.__version__) < 0.4:
|
||||
# The move function is not present in versions 0.3 and older
|
||||
transmissionrpc.Client.move = move
|
||||
|
||||
collection = TVShowCollection(TV_PATH)
|
||||
client = transmissionrpc.Client()
|
||||
|
||||
torrents = client.info()
|
||||
for i, torrent in torrents.iteritems():
|
||||
status = torrent.status
|
||||
if status not in ['seeding', 'stopped']:
|
||||
continue
|
||||
show = collection.match(torrent.name)
|
||||
if show is None:
|
||||
continue
|
||||
path = '{0}{1}/'.format(TV_PATH, show)
|
||||
if torrent.downloadDir.startswith(path):
|
||||
continue
|
||||
print 'Found {0} torrent \'{1}\' in show \'{2}\', moving...'.format(status, torrent.name, show)
|
||||
result = client.move(i, path)
|
||||
if status == 'seeding':
|
||||
print 'Re-starting torrent to continue seeding'
|
||||
client.start(i)
|
||||
```
|
119
_posts/2012-04-09-learning-functional-programming-part-one.md
Normal file
119
_posts/2012-04-09-learning-functional-programming-part-one.md
Normal file
|
@ -0,0 +1,119 @@
|
|||
---
|
||||
title: Learning Functional Programming, Part One
|
||||
author: Correl Roush
|
||||
layout: post
|
||||
permalink: /2012/04/09/learning-functional-programming-part-one/
|
||||
categories:
|
||||
- Programming
|
||||
tags:
|
||||
- functional
|
||||
- python
|
||||
---
|
||||
|
||||
# Part One: Lambdas? In my Python?
|
||||
|
||||
Over the past few months, I've decided to take a stab at learning some
|
||||
functional programming. I'd been doing python for a few years (and
|
||||
completely falling in love with it), and so I'd been exposed to a few
|
||||
functional concepts it offers - primarily higher-order functions and list
|
||||
comprehensions, both of which allow for very clear, concise and powerful code.
|
||||
Since that's where I started my journey, that's where my post will begin as
|
||||
well.
|
||||
|
||||
<!--more-->
|
||||
|
||||
## Functions are objects, too
|
||||
|
||||
Having graduated to python from PHP and C/C++, perhaps the biggest new thing to
|
||||
wrap my head around (besides readable code, whitespace-as-syntax,
|
||||
[programming being fun again](http://xkcd.com/353/), and all that), is that in
|
||||
python, functions (and classes!) are objects, just like anything else. They
|
||||
can still be defined in the usual way, but they can also be assigned, passed
|
||||
as arguments, even modified and replaced like any other value or object in your
|
||||
program.
|
||||
|
||||
```python
|
||||
def do_a():
|
||||
print "Doing something"
|
||||
|
||||
do_b = do_a
|
||||
|
||||
do_b()
|
||||
|
||||
# Prints "Doing something"
|
||||
```
|
||||
|
||||
Functions themselves no longer require formal definitions, either, they can be
|
||||
created *[anonymously](http://en.wikipedia.org/wiki/Anonymous_function)*:
|
||||
|
||||
```python
|
||||
my_send = lambda person, thing: send(person.upper(), thing, subject="Check this out!")
|
||||
ucase_people = map(lambda name: name.upper(), ["Joe", "Mary", "Zach"])
|
||||
```
|
||||
|
||||
|
||||
## Abstracting behaviour
|
||||
|
||||
You'll find you can now start abstracting away common idioms. For
|
||||
example, you probably very often find yourself looping over some list of items,
|
||||
performing some set of actions on them, or passing them to some other function
|
||||
or method:
|
||||
|
||||
```python
|
||||
people = ["Joe", "Chris", "Matt", "Jennifer"]
|
||||
for person in people:
|
||||
u_person = person.upper()
|
||||
send(person, super_fun_thing)
|
||||
```
|
||||
|
||||
Instead of that, you could have a function that takes a list as one argument,
|
||||
and a function to apply to each item in it as another:
|
||||
|
||||
```python
|
||||
def dostuff(action, things):
|
||||
result = []
|
||||
for thing in things:
|
||||
result.append(action(thing))
|
||||
return result
|
||||
|
||||
dostuff(send, people)
|
||||
```
|
||||
|
||||
The above example is actually just a simple definition of one of the most
|
||||
common higher-order functions,
|
||||
[map](http://docs.python.org/library/functions.html#map), which python already
|
||||
provides for you. Another particularly useful higher-order function is
|
||||
[filter](http://docs.python.org/library/functions.html#filter) which, given a
|
||||
function that returns true of false if its criteria are met by the passed item,
|
||||
will return the subset of the passed list that satisfy the filtering function:
|
||||
|
||||
```python
|
||||
stuff = ["My notes.txt", "Matt's notes.txt", "My music.pls"]
|
||||
my_stuff = filter(lambda s: s.startswith("My "), stuff)
|
||||
|
||||
# my_stuff = ["My notes.txt", "My music.pls"]
|
||||
```
|
||||
|
||||
[List comprehensions](http://docs.python.org/tutorial/datastructures.html#list-comprehensions)
|
||||
provide a cleaner, easier to read way to perform mapping and/or filtering on a
|
||||
list:
|
||||
|
||||
```python
|
||||
stuff = ["My notes.txt", "Matt's notes.txt", "My music.pls"]
|
||||
|
||||
my_stuff = [file for file in stuff if file.startswith("My ")]
|
||||
# ["My notes.txt", "My music.pls"]
|
||||
|
||||
upper_stuff = [file.upper() for file in stuff]
|
||||
# ["MY NOTES.TXT", "MATT'S NOTES.TXT", "MY MUSIC.PLS"]
|
||||
|
||||
music = [file.upper() for file in stuff if file.endswith(".pls")]
|
||||
# ["MY MUSIC.PLS"]
|
||||
```
|
||||
|
||||
|
||||
## Tip of the iceberg
|
||||
|
||||
This is just a very small taste of functional programming concepts. Later, I'll
|
||||
introduce a couple of functional languages, and explain what sets them apart
|
||||
from object-oriented and imperative programming languages.
|
BIN
images/portal_2_logo-150x150.jpg
Executable file
BIN
images/portal_2_logo-150x150.jpg
Executable file
Binary file not shown.
After ![]() (image error) Size: 4.8 KiB |
BIN
images/portal_2_logo.jpg
Executable file
BIN
images/portal_2_logo.jpg
Executable file
Binary file not shown.
After ![]() (image error) Size: 51 KiB |
18
index.html
Normal file
18
index.html
Normal file
|
@ -0,0 +1,18 @@
|
|||
---
|
||||
layout: default
|
||||
title: correl.phoenixinquis.net
|
||||
---
|
||||
|
||||
<h1>Posts</h1>
|
||||
|
||||
{% for post in site.posts %}
|
||||
<article>
|
||||
<h1><a href="{{post.url }}">{{ post.title }}</a></h1>
|
||||
|
||||
{{ post.excerpt }}
|
||||
|
||||
<footer>
|
||||
<a href="{{ post.url }}">Read more …</a>
|
||||
</footer>
|
||||
</article>
|
||||
{% endfor %}
|
Loading…
Add table
Reference in a new issue