tag:blogger.com,1999:blog-87629469166973926152024-02-08T10:24:20.358-07:00Six Impossible ThingsA. R. Diederichhttp://www.blogger.com/profile/02126469823641089850noreply@blogger.comBlogger19125tag:blogger.com,1999:blog-8762946916697392615.post-55761077315952985722021-09-06T18:29:00.002-06:002021-09-06T18:29:26.959-06:00CUPS and POP!_OS<p>Ok, sometimes I use this blog so I can find stuff later. So, Andrew, if you find you can't add a printer in <a href="https://system76.com/">System76</a>'s <a href="https://pop.system76.com/">Pop!_OS</a> because your login and password don't let you log into CUPS, try:</p><pre style="border-radius: 6px; box-sizing: border-box; color: #24292f; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 11.9px; line-height: 1.45; margin-bottom: 16px; margin-top: 0px; overflow-wrap: normal; overflow: auto; padding: 16px;"><code style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 6px; border: 0px; box-sizing: border-box; display: inline; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 11.9px; line-height: inherit; margin: 0px; overflow-wrap: normal; overflow: visible; padding: 0px; word-break: normal;">sudo usermod -aG lpadmin $USER</code></pre>Courtesy of <a href="https://github.com/pop-os/pop/issues/1262">https://github.com/pop-os/pop/issues/1262</a>.A. R. Diederichhttp://www.blogger.com/profile/02126469823641089850noreply@blogger.com0tag:blogger.com,1999:blog-8762946916697392615.post-30576453398959910522020-05-31T21:06:00.001-06:002020-05-31T21:06:29.802-06:00Dual Booting with EFI, The Joy ofFor several years I've purchased my laptops from <a href="https://system76.com">System 76</a>. They're good, and I'm on my third laptop. Many moons ago I needed a hardware swap-out while I was on a 2-week R&R from an Iraq deployment, and they hooked me right up. (I also live 30 minutes from where their HQ was at the time.) I learned the hard way that I needed Windows to control the booting of Windows and Linux (usually SUSE), or Windows patches would never work quite right.<div><br /></div><div>EFI is great. I'd not realized that you dual-boot with the EFI bootloader, not with EasyBCD, boot.ini files, or the other stuff I'd used over the years. I did have to delete some fonts to clear out a little space in the /boot/efi partition, but worse things happen at sea, you know. I'm really pleased how easy it was. Hit ESC when booting and one-time boot your OS. Beautiful.</div>A. R. Diederichhttp://www.blogger.com/profile/02126469823641089850noreply@blogger.com0tag:blogger.com,1999:blog-8762946916697392615.post-35988355162119634512020-05-31T21:00:00.001-06:002020-05-31T21:00:33.156-06:00Lethality: The PodcastI recorded two podcasts while at the <a href="https://www.armywarcollege.edu/" target="_blank">U.S. Army War College</a>. The second was on Lethality. In DoD terms, lethality means "good." It's the new hotness--all the rage. As an artilleryman, I approve.<br />
<br />
But there's another side to these things. I've also studied a lot of economics, and it may just be easier to lose the peace as to lose the war. In that vein, I offer <a href="https://warroom.armywarcollege.edu/podcasts/more-than-lethality/" target="_blank">There's More to Life than Lethality</a>. (Though the Space Force #pewpew article was more fun.)A. R. Diederichhttp://www.blogger.com/profile/02126469823641089850noreply@blogger.com0tag:blogger.com,1999:blog-8762946916697392615.post-39272472550200578332019-08-03T17:35:00.001-06:002019-08-03T17:35:32.130-06:00Podcasting at the U.S. Army War CollegeI was able to be on two podcasts while a student at the <a href="https://www.armywarcollege.edu/" target="_blank">U.S. Army War College</a> (USAWC) over the last year. The first was aimed at a civilian academic audience. Basically, "What in the world is it like to be a military grad student at a 'War College'?" Yes, there are such things, and the things are a bit different in a professional military education (PME) setting than at a regular university. For example, the military is a direct consumer of its own product, so there is a very tight feedback loop, analyzing the output.<br />
<br />
It was actually <a href="http://www.lawyersgunsmoneyblog.com/2019/06/lgm-podcast-life-at-the-usawc-part-ii" target="_blank">Part II</a> of a two part series. <a href="http://www.lawyersgunsmoneyblog.com/2019/06/lgm-podcast-faculty-life-at-the-army-war-college" target="_blank">Part I</a> was an interview of Prof. <a href="https://twitter.com/notabattlechick" target="_blank">Jacqueline Whitt</a>, a professor at USAWC. She's also taught at the <a href="https://www.airuniversity.af.edu/" target="_blank">U.S. Air War College</a> and at <a href="https://westpoint.edu/" target="_blank">West Point</a>. Those two interviews were conducted by Prof. <a href="https://twitter.com/drfarls" target="_blank">Robert Farley</a> of the <a href="http://www.uky.edu/" target="_blank">University of Kentucky</a>, who was a visiting professor last year at Carlisle Barracks.<br />
<br />
The second one was way nerdier than the first, and a ton of fun. Who wants to talk Space Force? #pewpew The discussions between the Space Force, Space Corps, <a href="https://en.wikipedia.org/wiki/United_States_Space_Command" target="_blank">U.S. Space Command</a>, and <a href="https://www.afspc.af.mil/" target="_blank">A.F. Space Command</a> get really confusing, so Prof. Whitt and I talked about that in "<a href="https://warroom.armywarcollege.edu/podcasts/u-s-space-force/" target="_blank">What should a U.S. Space Force Look Like?</a>" The short version: It's too soon, just have the Air Force work it out for now.A. R. Diederichhttp://www.blogger.com/profile/02126469823641089850noreply@blogger.com0tag:blogger.com,1999:blog-8762946916697392615.post-50020597321527556342017-06-27T19:16:00.002-06:002019-03-18T15:37:08.862-06:00Python argparse with defaults -- in-script and importableI've tried using argparse (and optparse before that) and have had trouble finding a workflow that made me happy. This one is pretty close. It allows you to make defaults for when you call a script on the command line and makes those same defaults available if you import the module. It works like this:<br />
<ol>
<li>Make a dictionary with the defaults you want.</li>
<li>In the function you write that parses the arguments, use the dictionary values as the defaults.</li>
<li>Merge the defaults dictionary and the arguments dictionary together.</li>
<li>Return the merged dictionary.</li>
</ol>
The Gist version is available <a href="https://gist.github.com/andrewdied/007d1681785f95526cacb5454ff4cead" target="_blank">here,</a> or you can see it below, too.<br />
<br />
#######################################<br />
<br />
#!/usr/bin/python3<br />
'''<br />
> python3 args_example.py -h<br />
usage: args_example.py [-h] [-f FIRST_OPTION] [-s SECOND_OPTION]<br />
mandatory_argument<br />
<br />
Example argument parser with default values.<br />
<br />
positional arguments:<br />
mandatory_argument Not everything can have a default value. This is a<br />
mandatory argument.<br />
<br />
optional arguments:<br />
-h, --help show this help message and exit<br />
-f FIRST_OPTION, --first_option FIRST_OPTION<br />
This is the first option. Default:<br />
first_default_value.<br />
-s SECOND_OPTION, --second_option SECOND_OPTION<br />
This is the second option. (Default:<br />
second_default_value)<br />
-t THIRD_OPTION, --third_option THIRD_OPTION<br />
This is the third option. (Default:<br />
third_default_value)<br />
<br />
> python3 args_example.py -f "non-default first value" --second_option 'non-default second value' "this is mandatory" <br />
{'first_option': 'non-default first value',<br />
'mandatory_argument': 'this is mandatory',<br />
'second_option': 'non-default second value',<br />
'third_option': 'third_default_value'}<br />
<br />
Of course, https://pymotw.com/2/argparse/ is still excellent.<br />
'''<br />
<br />
<br />
import argparse<br />
import pprint<br />
<br />
<br />
default_settings = {'first_option': 'first_default_value',<br />
'second_option': 'second_default_value',<br />
'third_option': 'third_default_value'}<br />
<br />
<br />
def get_args(settings=default_settings):<br />
'''Reads from sys.stdin. Use stdin to get new options, and return options<br />
merged with the default options. Settings is a dictionary. We'll have an<br />
argument (no, you came here for an argument), set two options, and default<br />
one.<br />
'''<br />
<br />
parser = argparse.ArgumentParser(description='Example argument parser with default values.')<br />
parser.add_argument('mandatory_argument', help='Not everything can have a default value. This is a mandatory argument.')<br />
parser.add_argument('-f', '--first_option', help='This is the first option. Default: %(default)s.',<br />
default=settings['first_option'])<br />
parser.add_argument('-s', '--second_option', help='This is the second option. (Default: %(default)s)',<br />
default=settings['second_option'])<br />
parser.add_argument('-t', '--third_option', help='This is the third option. (Default: %(default)s)',<br />
default=settings['third_option'])<br />
args = parser.parse_args()<br />
args_settings = vars(args) # everything is easier with a dictionary<br />
<br />
#python3.5+<br />
merged_settings_3 = {**settings, **args_settings}<br />
<br />
#python2<br />
merged_settings_2 = default_settings.copy()<br />
merged_settings_2.update(args_settings)<br />
<br />
merged_settings_brute_force = '''<br />
if args.first_option:<br />
settings['first_option'] = args.first_option<br />
if args.second_option:<br />
settings['second_option'] = args.second_option<br />
if args.third_option:<br />
settings['third_option'] = args.third_option<br />
settings['mandatory_argument'] = args.mandatory_argument<br />
return merged_settings_brute_force<br />
'''<br />
<br />
return merged_settings_3<br />
<br />
<br />
def main():<br />
settings = get_args()<br />
pprint.pprint(settings)<br />
<br />
<br />
if __name__ == '__main__':<br />
main()A. R. Diederichhttp://www.blogger.com/profile/02126469823641089850noreply@blogger.com0tag:blogger.com,1999:blog-8762946916697392615.post-68008462070804919432017-06-10T19:45:00.001-06:002017-06-10T19:45:39.066-06:00Cat facts & pythonI'd not actually used anything with json before, but (unsurprisingly) the requests library came through.<br />
<br />
>>> import requests<br />>>> url = 'http://catfacts-api.appspot.com/api/facts?number=1'<br />>>> print(requests.get(url).json()['facts'][0])<br />Cat families usually play best in even numbers. Cats and kittens should be acquired in pairs whenever possible.<br />
<br />
While that gets you the answer, when did you ever really just want the answer? That's pretty uninteresting. Let's get there in stages.<br />
<br />
This is straightforward (yes, I'm assuming you have requests installed already):<br />
<br />
>>> import requests<br />>>> url = 'http://catfacts-api.appspot.com/api/facts?number=1'<br />
<br />
Then we can get the cat fact:<br />
>>> cat_fact = requests.get(url)<br />
<br />
Which looks like this:<br />
>>> cat_fact.text<br />'{"facts": ["A cat\'s whiskers are thought to be a kind of radar, which helps a cat gauge the space it intends to walk through."], "success": "true"}'<br />
<br />
Well, we really just want the string of the dictionary item in the string. The json() method makes it a dictionary, not a string.<br />
>>> cat_fact.json()<br />
{'facts': ["A cat's whiskers are thought to be a kind of radar, which helps a cat gauge the space it intends to walk through."], 'success': 'true'}<br />
<br />
<br />
<br />
<br />
<br />
And we can use the dictionary key ('facts')...<br />
>>> print(cat_fact.json()['facts'])<br />["A cat's whiskers are thought to be a kind of radar, which helps a cat gauge the space it intends to walk through."]<br />
<br />
But we don't want a list, we want the string. So take the first item in the list.<br />
>>> print(cat_fact.json()['facts'][0])<br />A cat's whiskers are thought to be a kind of radar, which helps a cat gauge the space it intends to walk through.<br />
<br />
We could also iterate through a number of cat facts, including a spurious use of f-string formatting.<br />
>>> number = 3<br />>>> url_number = f'http://catfacts-api.appspot.com/api/facts?number={number}'<br />>>> catfact = requests.get(url_number).json()<br />
>>> catfact<br />{'facts': ['Not every cat gets "high" from catnip. Whether or not a cat responds to it depends upon a recessive gene: no gene, no joy.', 'Cats have an average of 24 whiskers, arranged in four horizontal rows on each side.', 'The strongest climber among the big cats, a leopard can carry prey twice its weight up a tree.'], 'success': 'true'}<br />
<br />
>>> for fact in catfact['facts']:<br />... print(fact)<br />... <br />Not every cat gets "high" from catnip. Whether or not a cat responds to it depends upon a recessive gene: no gene, no joy.<br />Cats have an average of 24 whiskers, arranged in four horizontal rows on each side.<br />The strongest climber among the big cats, a leopard can carry prey twice its weight up a tree.<br />
<br />
Which I think is quite enough about cat facts.<br />
<br />A. R. Diederichhttp://www.blogger.com/profile/02126469823641089850noreply@blogger.com0tag:blogger.com,1999:blog-8762946916697392615.post-21433051999714241042016-03-04T19:28:00.003-07:002017-06-10T19:55:03.672-06:00Free laws!This is something I've been looking for for a long time. Colorado is now letting you have a complete copy of the law for free! <a href="http://coloradofoic.org/colorado-statutes-database-should-be-free-lawmakers-decide/">http://coloradofoic.org/colorado-statutes-database-should-be-free-lawmakers-decide/</a> has more information about it. Years ago I'd made a fancy <a href="https://docs.google.com/file/d/0B3uQej9IfYnbVkNHaUNLQmluM2s/edit?usp=sharing" target="_blank">pdf </a>of the Colorado Constitution with <a href="https://docs.google.com/file/d/0B3uQej9IfYnbMjU3ZjIzNDQtOTM2NS00Zjc3LWIxZmMtOTY1NjZmM2RjYzRm/edit?usp=sharing" target="_blank">LaTeX</a>, but this has the amazing benefit that I don't have to do it. You can download your very own Colorado Constitution from <a href="http://tornado.state.co.us/gov_dir/leg_dir/olls/2015titles.htm">http://tornado.state.co.us/gov_dir/leg_dir/olls/2015titles.htm</a>. Slightly strange: the constitution download is under the Colorado Revised Statutes. The link for the constitution is a web only copy.<br />
<br />
Update: The link moved. <a href="https://leg.colorado.gov/agencies/office-legislative-legal-services/2015-crs-titles-download" target="_blank">https://leg.colorado.gov/agencies/office-legislative-legal-services/2015-crs-titles-download </a>A. R. Diederichhttp://www.blogger.com/profile/02126469823641089850noreply@blogger.com4tag:blogger.com,1999:blog-8762946916697392615.post-43976757759369496642015-09-03T22:25:00.002-06:002016-03-04T19:29:09.099-07:00CSV reader examples for python 3Among other things, I like <a href="http://www.python.org/" target="_blank">python</a>. I quite like the <a href="http://talkpython.fm/" target="_blank">Talk Python to Me</a> podcast, done by Michael Kennedy. He is, among other things, a python trainer. Among his online python training videos is one on <a href="https://www.youtube.com/all_comments?v=qajONCIvhEc" target="_blank">parsing csv</a> (comma separated value) files. His example didn't actually use the python csv module, so I whipped up a couple of examples that used csv.reader and csv.DictReader.<br />
<br />
These use python 3.4.<br />
<br />
<span style="background-color: white; font-family: "roboto" , "arial" , sans-serif; font-size: 13px; line-height: 17px; white-space: pre-wrap;">===================
csv.reader example:
</span><span style="font-family: "courier new" , "courier" , monospace;"><span style="background-color: white; font-size: 13px; line-height: 17px; white-space: pre-wrap;">#!c:\\anaconda3\\python.exe
'''taken from </span><a class="yt-uix-sessionlink " data-sessionlink="ei=NP7mVYz7G9K7ugLBhbmICg" href="https://www.youtube.com/watch?v=qajONCIvhEc" style="background: rgb(255, 255, 255); border: 0px; color: #167ac6; cursor: pointer; font-size: 13px; line-height: 17px; margin: 0px; padding: 0px; text-decoration: none; white-space: pre-wrap;">https://www.youtube.com/watch?v=qajONCIvhEc</a><span style="background-color: white; font-size: 13px; line-height: 17px; white-space: pre-wrap;">
</span><a class="yt-uix-sessionlink " data-sessionlink="ei=NP7mVYz7G9K7ugLBhbmICg" href="https://support.spatialkey.com/spatialkey-sample-csv-data/" style="background: rgb(255, 255, 255); border: 0px; color: #167ac6; cursor: pointer; font-size: 13px; line-height: 17px; margin: 0px; padding: 0px; text-decoration: none; white-space: pre-wrap;">https://support.spatialkey.com/spatialkey-sample-csv-data/</a><span style="background-color: white; font-size: 13px; line-height: 17px; white-space: pre-wrap;">
</span><a class="yt-uix-sessionlink " data-sessionlink="ei=NP7mVYz7G9K7ugLBhbmICg" href="http://samplecsvs.s3.amazonaws.com/Sacramentorealestatetransactions.csv" style="background: rgb(255, 255, 255); border: 0px; color: #167ac6; cursor: pointer; font-size: 13px; line-height: 17px; margin: 0px; padding: 0px; text-decoration: none; white-space: pre-wrap;">http://samplecsvs.s3.amazonaws.com/Sacramentorealestatetransactions.csv</a><span style="background-color: white; font-size: 13px; line-height: 17px; white-space: pre-wrap;">
'''
import csv
import os
def main():
print("Hello File I/O minicast using csv.reader")
filename = os.path.abspath(os.path.join("data", "Sacramentorealestatetransactions.csv"))
print(filename)
with open(filename, 'r') as csvfile:
fin = csv.reader(csvfile, delimiter=',')
header = next(fin)
print(header)
# ['street', 'city', 'zip', 'state', 'beds', 'baths', 'sq__ft', 'type', 'sale_date', 'price', 'latitude', 'longitude']
entries = []
for line in fin:
# lines look like
# ['3526 HIGH ST', 'SACRAMENTO', '95838', 'CA', '2', '1', '836', 'Residential', 'Wed May 21 </span><a class="yt-uix-sessionlink " data-sessionlink="ei=NP7mVYz7G9K7ugLBhbmICg" href="http://www.youtube.com/watch?v=qajONCIvhEc&t=00h00m00s" style="background: rgb(255, 255, 255); border: 0px; color: #167ac6; cursor: pointer; font-size: 13px; line-height: 17px; margin: 0px; padding: 0px; text-decoration: none; white-space: pre-wrap;">00:00:00</a><span style="background-color: white; font-size: 13px; line-height: 17px; white-space: pre-wrap;"> EDT 2008', '59222', '38.631913', '-121.434879']
row = dict()
for i, h in enumerate(header):
row[h] = line[i]
entries.append(row)
entries.sort(key= lambda r: -1*int(r['price']))
# Entries are a list of dicts. Each line looks like:
# {'street': '9401 BARREL RACER CT', 'state': 'CA', 'sq__ft': '4400', 'city': 'WILTON', 'beds': '4', 'baths': '3', 'sale_date': 'Fri May 16 </span><a class="yt-uix-sessionlink " data-sessionlink="ei=NP7mVYz7G9K7ugLBhbmICg" href="http://www.youtube.com/watch?v=qajONCIvhEc&t=00h00m00s" style="background: rgb(255, 255, 255); border: 0px; color: #167ac6; cursor: pointer; font-size: 13px; line-height: 17px; margin: 0px; padding: 0px; text-decoration: none; white-space: pre-wrap;">00:00:00</a><span style="background-color: white; font-size: 13px; line-height: 17px; white-space: pre-wrap;"> EDT 2008', 'price': '884790', 'longitude': '-121.194858', 'latitude': '38.415298', 'zip': '95693', 'type': 'Residential'}
for e in entries[:5]:
print("{0} beds, {1} baths sold for ${2:,}".format(
e['beds'], e['baths'], int(e['price'])
))
if </span><i style="background: rgb(255, 255, 255); border: 0px; font-size: 13px; line-height: 17px; margin: 0px; padding: 0px; white-space: pre-wrap;">_name_</i><span style="background-color: white; font-size: 13px; line-height: 17px; white-space: pre-wrap;"> == '__main__':
main()</span></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span style="background-color: white; font-size: 13px; line-height: 17px; white-space: pre-wrap;"><br /></span></span>
<span style="background-color: white; font-family: "roboto" , "arial" , sans-serif; font-size: 13px; line-height: 17px; white-space: pre-wrap;">=======================
csv.DictReader example:</span><br />
<span style="background-color: white; font-family: "roboto" , "arial" , sans-serif; font-size: 13px; line-height: 17px; white-space: pre-wrap;">
</span><span style="font-family: "courier new" , "courier" , monospace;"><span style="background-color: white; font-size: 13px; line-height: 17px; white-space: pre-wrap;">#!c:\\anaconda3\\python.exe
'''taken from </span><a class="yt-uix-sessionlink " data-sessionlink="ei=NP7mVYz7G9K7ugLBhbmICg" href="https://www.youtube.com/watch?v=qajONCIvhEc" style="background: rgb(255, 255, 255); border: 0px; color: #167ac6; cursor: pointer; font-size: 13px; line-height: 17px; margin: 0px; padding: 0px; text-decoration: none; white-space: pre-wrap;">https://www.youtube.com/watch?v=qajONCIvhEc</a><span style="background-color: white; font-size: 13px; line-height: 17px; white-space: pre-wrap;">
</span><a class="yt-uix-sessionlink " data-sessionlink="ei=NP7mVYz7G9K7ugLBhbmICg" href="https://support.spatialkey.com/spatialkey-sample-csv-data/" style="background: rgb(255, 255, 255); border: 0px; color: #167ac6; cursor: pointer; font-size: 13px; line-height: 17px; margin: 0px; padding: 0px; text-decoration: none; white-space: pre-wrap;">https://support.spatialkey.com/spatialkey-sample-csv-data/</a><span style="background-color: white; font-size: 13px; line-height: 17px; white-space: pre-wrap;">
</span><a class="yt-uix-sessionlink " data-sessionlink="ei=NP7mVYz7G9K7ugLBhbmICg" href="http://samplecsvs.s3.amazonaws.com/Sacramentorealestatetransactions.csv" style="background: rgb(255, 255, 255); border: 0px; color: #167ac6; cursor: pointer; font-size: 13px; line-height: 17px; margin: 0px; padding: 0px; text-decoration: none; white-space: pre-wrap;">http://samplecsvs.s3.amazonaws.com/Sacramentorealestatetransactions.csv</a><span style="background-color: white; font-size: 13px; line-height: 17px; white-space: pre-wrap;">
'''
import csv
import os
def main():
print("Hello File I/O minicast using csv.DictReader")
filename = os.path.abspath(os.path.join("data", "Sacramentorealestatetransactions.csv"))
print(filename)
with open(filename, 'r') as csvfile:
fin = csv.DictReader(csvfile, delimiter=',')
print(fin.fieldnames)
# ['street', 'city', 'zip', 'state', 'beds', 'baths', 'sq__ft', 'type', 'sale_date', 'price', 'latitude', 'longitude']
entries = list(fin)
# lines/rows in fin look like
# {'street': '3882 YELLOWSTONE LN', 'state': 'CA', 'sq__ft': '1362', 'city': 'EL DORADO HILLS', 'beds': '3', 'baths': '2', 'sale_date': 'Thu May 15 </span><a class="yt-uix-sessionlink " data-sessionlink="ei=NP7mVYz7G9K7ugLBhbmICg" href="http://www.youtube.com/watch?v=qajONCIvhEc&t=00h00m00s" style="background: rgb(255, 255, 255); border: 0px; color: #167ac6; cursor: pointer; font-size: 13px; line-height: 17px; margin: 0px; padding: 0px; text-decoration: none; white-space: pre-wrap;">00:00:00</a><span style="background-color: white; font-size: 13px; line-height: 17px; white-space: pre-wrap;"> EDT 2008', 'price': '235738', 'longitude': '-121.075915', 'latitude': '38.655245', 'zip': '95762', 'type': 'Residential'}
entries.sort(key= lambda r: -1*int(r['price']))
for e in entries[:5]:
print("{0} beds, {1} baths sold for ${2:,}".format(
e['beds'], e['baths'], int(e['price'])
))
if </span><i style="background: rgb(255, 255, 255); border: 0px; font-size: 13px; line-height: 17px; margin: 0px; padding: 0px; white-space: pre-wrap;">_name_</i><span style="background-color: white; font-size: 13px; line-height: 17px; white-space: pre-wrap;"> == '__main__':
main()</span></span>A. R. Diederichhttp://www.blogger.com/profile/02126469823641089850noreply@blogger.com0tag:blogger.com,1999:blog-8762946916697392615.post-46132555077877411252015-03-26T19:18:00.002-06:002015-03-26T19:18:20.930-06:00Fixing Linux Firefox DEE (mail.mil)It's a constant battle to be able to receive my Defense Enterprise Email on linux. (Heck, it's not that far off on Windows, either.) I had it working, then it stopped, and militarycac.com came to the rescue. It turns out that you need to renegotiate the SSL session while authenticating, which is a security hole. <a href="https://militarycac.com/firefox.htm">https://militarycac.com/firefox.htm</a> had the right info for me:<br />
<br />
<blockquote class="tr_bq">
You'll need to enable SSL renegotiation, do this by
pointing your browser to <em>about:config</em>. After confirming that you
know what you are doing, you need to start typing in:
<br />
<blockquote class="style8" style="outline: 0;">
<div class="style7">
<em>
security.ssl.allow_unrestricted_renego_everywhere__temporarily_available_pref</em></div>
</blockquote>
<div class="style7">
set it to true (by double clicking it). After this you
should be able to access the site.</div>
</blockquote>
I didn't even need to restart firefox! Now I can be in linux more often, and not just when I think I won't need to check email. DoD is moving to an all-in-one outlook web access (OWA) client, and it is much finickier than normal CAC (smart card) enabled web sites.A. R. Diederichhttp://www.blogger.com/profile/02126469823641089850noreply@blogger.com0tag:blogger.com,1999:blog-8762946916697392615.post-88789456132804241582015-03-16T21:47:00.000-06:002015-03-16T21:47:07.729-06:00Renaming files in WindowsSometimes the small things are the most helpful. I needed to rename a couple dozen jpg files to "...small.jpg". Through the joys of Internet searching, I pretty quickly came to a solution from <a href="http://www.howtogeek.com/111859/how-to-batch-rename-files-in-windows-4-ways-to-rename-multiple-files">http://www.howtogeek.com/111859/how-to-batch-rename-files-in-windows-4-ways-to-rename-multiple-files</a>/ using Windows PowerShell. So with a quick:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">PS > dir | Rename-Item -NewName {$_.name -replace ".jpg","Small.jpg"}</span><br />
<br />
<span style="font-family: Courier New, Courier, monospace;">FirstPicture.jpg</span> became <span style="font-family: Courier New, Courier, monospace;">FirstPictureSmall.jpg</span>. I hadn't installed The Gimp yet on this laptop, but I found through a YouTube video (<a href="http://www.youtube.com/watch?v=19GbI6oFrW0">http://www.youtube.com/watch?v=19GbI6oFrW0</a>) that you can use Right Click > Send To > Mail Recipient, and Outlook (assuming it's installed) will offer to change the size for you.A. R. Diederichhttp://www.blogger.com/profile/02126469823641089850noreply@blogger.com0tag:blogger.com,1999:blog-8762946916697392615.post-1086706049187425752014-06-14T12:33:00.002-06:002014-06-14T12:33:30.916-06:00Destinations vs CapabilitiesBrian Enke has <a href="http://www.examiner.com/article/nasa-s-new-proving-ground-has-much-to-prove?CID=examiner_alerts_article" target="_blank">another good article</a>, this time on how NASA is treating things around the Mars mission. I've never been a fan of the plan to go to an asteroid. Yes, it's technically difficult, but unless they're going to figure out how to mine it by going there, just go to Mars or the Moon. The latest twist on the Mars mission is to test out things in Lunar orbit.<br /><br />What I liked about the article was the discussion on Capabilities vs Destinations, since for years I've been trained to talk about what capability is needed, rather than the solutions asked for. For example, don't say that you need five people to clean up an abandoned parking lot that's been used for a dump, say that you need the capability of moving x tons of trash in y amount of time, and repaving a parking lot of z size. While this is a little different from a "Destination" I wanted to see what he said.<br /><br />And the answer is ... destinations are cheaper than capabilities. I think this is true because you can pool your trade space when you're looking at the destination, goal, or end state. When you list out a bunch of individual capabilities, the tendency is to over-engineer each one, they aren't exactly made to interface with each other, and you still need the destination at the end, because a rocket, habitat, and a life support system through space don't magically come together for the mission.A. R. Diederichhttp://www.blogger.com/profile/02126469823641089850noreply@blogger.com0tag:blogger.com,1999:blog-8762946916697392615.post-15646811069238269982013-11-29T14:12:00.001-07:002016-03-04T19:29:29.870-07:00Cheyenne Mountain scifi<span style="background-color: white; color: #404040; font-family: "roboto" , "arial" , sans-serif; font-size: 13px; line-height: 18px;">I just spent a few days in Cheyenne Mountain Air Force Station (CMAFS). The exercise was a good one, and the mountain is much drier than it was right after all the heavy rains and floods.</span><br />
<br style="background-color: white; color: #404040; font-family: Roboto, arial, sans-serif; font-size: 13px; line-height: 18px;" />
<span style="background-color: white; color: #404040; font-family: "roboto" , "arial" , sans-serif; font-size: 13px; line-height: 18px;">And, since it seemed like the right thing to do, I brought my copy of </span><i style="background-color: white; color: #404040; font-family: Roboto, arial, sans-serif; font-size: 13px; line-height: 18px;"><a href="http://www.librarything.com/work/16493/book/61878529" target="_blank">Footfall</a></i><span style="color: #404040; font-family: "roboto" , "arial" , sans-serif; font-size: x-small;"><span style="line-height: 18px;"> </span></span><span style="background-color: white; color: #404040; font-family: "roboto" , "arial" , sans-serif; font-size: 13px; line-height: 18px;">and re-read the bits where the hard science fiction authors went Inside as US threat team in case the space aliens turned out to be bad guys. (Non-spoiler: they invade.)</span><br />
<br style="background-color: white; color: #404040; font-family: Roboto, arial, sans-serif; font-size: 13px; line-height: 18px;" />
<span style="background-color: white; color: #404040; font-family: "roboto" , "arial" , sans-serif; font-size: 13px; line-height: 18px;">I was also reading </span><i style="background-color: white; color: #404040; font-family: Roboto, arial, sans-serif; font-size: 13px; line-height: 18px;"><a href="http://www.librarything.com/work/13492637/book/103394470" target="_blank">Mission to Mars</a></i><span style="background-color: white; color: #404040; font-family: "roboto" , "arial" , sans-serif; font-size: 13px; line-height: 18px;"> by Buzz Aldrin</span><span style="background-color: white; color: #404040; font-family: "roboto" , "arial" , sans-serif; font-size: 13px; line-height: 18px;"> so it got a trip Inside, too.</span>A. R. Diederichhttp://www.blogger.com/profile/02126469823641089850noreply@blogger.com0tag:blogger.com,1999:blog-8762946916697392615.post-11208628790146461702013-11-24T14:11:00.002-07:002013-11-24T14:11:21.164-07:00Windows 7 Save As... customizationIt's a small thing, but I've found it frustrating that some dialog boxes show my favorites, such as Google Drive and Downloads, and others will not. To boot, most of those "others" are in C:\Users\<mylogin>, but that directory isn't in the default list.<br />
<br />
<a href="http://www.howtogeek.com/97824/">http://www.howtogeek.com/97824/</a> has a nice HOWTO to edit your registry to change that dialog box. The one thing I missed was that it doesn't add to the Save As... list, it replaces what's there.A. R. Diederichhttp://www.blogger.com/profile/02126469823641089850noreply@blogger.com1tag:blogger.com,1999:blog-8762946916697392615.post-29895952466019616062013-09-03T20:48:00.002-06:002013-09-03T20:48:53.438-06:00301 redirects and google sitesI'd forgotten I'd tried to set this up once, but I got an update notification today from <a href="https://code.google.com/p/google-sites-issues/issues/detail?id=73">https://code.google.com/p/google-sites-issues/issues/detail?id=73</a>. The issue is that google sites doesn't support 301 redirects.<br />
<br />
How does that effect us? What it means is if you're porting an existing web site to google sites, you're about guaranteed to have things break. If anyone's linked to an index.html page of yours, or default.htm, you're stuck with a 404 report forever. You can't even load a blank page with an embedded redirect because google sites changes the document type so your browser won't read it correctly.<br />
<br />
The funny thing is google <a href="https://support.google.com/webmasters/answer/93633?hl=en" target="_blank">likes 301 redirects</a>. They even made a video to show you how cool they are. But since it's been a year since good old issue #73 was logged and there's no update, my guess is google sites will just never support this feature. Which probably means google's going to abandon the product.<br />
<br />
I can't imagine anyone recommending moving an existing site to google sites, or even starting a new one from scratch with it.A. R. Diederichhttp://www.blogger.com/profile/02126469823641089850noreply@blogger.com0tag:blogger.com,1999:blog-8762946916697392615.post-58999485046971576182013-08-11T21:09:00.003-06:002013-08-11T21:09:40.919-06:00KDE screen saversIt's just a small thing, but had annoyed me for a while. The "Screen Locker", from Iguana > Configure Desktop > Display and Monitor > Screen Locker, has a slide show option. Gnome seemed to have dumped this, so I was happy to see it in kde.<br />
<br />
I'm not big on fancy transitions, anyway, and the random ones here were impossibly slow. Why transition every five seconds to a new picture if it takes 30 seconds to paint a new screen? <a href="https://bugs.kde.org/show_bug.cgi?id=182104">https://bugs.kde.org/show_bug.cgi?id=182104</a> is the reported bug, and the fix still works. Edit <span style="font-family: Courier New, Courier, monospace;">~/kde4/share/config/kslideshow.kssrc</span>, and add "<span style="font-family: Courier New, Courier, monospace;">EffectsEnabled=false</span>" after the last line.A. R. Diederichhttp://www.blogger.com/profile/02126469823641089850noreply@blogger.com1tag:blogger.com,1999:blog-8762946916697392615.post-26130605076608560212013-07-15T07:27:00.000-06:002013-07-15T07:27:13.853-06:00UDPSeen on the CLUE (Colorado Linux Users and Enthusiasts) mail list:<br />
<blockquote class="tr_bq">
I'd tell you a UDP joke but you might not get it.</blockquote>
A. R. Diederichhttp://www.blogger.com/profile/02126469823641089850noreply@blogger.com0tag:blogger.com,1999:blog-8762946916697392615.post-57604396621725028562013-05-27T19:07:00.001-06:002013-05-27T19:07:38.384-06:00Colorado Constitution updated for 2013I've finished updating the Colorado Constitution with Amendment S (State Personnel System), which wraps up the changes approved by the electorate in 2012. You can get the <a href="https://docs.google.com/file/d/0B3uQej9IfYnbVkNHaUNLQmluM2s/edit?usp=sharing" target="_blank">pdf</a> or the <a href="https://docs.google.com/file/d/0B3uQej9IfYnbMjU3ZjIzNDQtOTM2NS00Zjc3LWIxZmMtOTY1NjZmM2RjYzRm/edit?usp=sharing" target="_blank">LaTeX</a> files. It runs 122 pages, and is best printed dual sided (duplexed).<br />
<br />
The next step is to figure out how to output in other formats, like text, mobi, and epub. I'm going to give <a href="http://johnmacfarlane.net/pandoc/" target="_blank">pandoc</a> a try.A. R. Diederichhttp://www.blogger.com/profile/02126469823641089850noreply@blogger.com0tag:blogger.com,1999:blog-8762946916697392615.post-7726615778523631162013-05-12T18:53:00.001-06:002013-05-12T18:53:37.075-06:00Amendment 65 added to LaTeXIt turns out that the entire constitutional change of Amendment 65 (Colorado Congressional Delegation to Support Campaign Finance Limits) is two words. It changes "... encouraging voluntary campaign spending limits ..." to "... establishing campaign spending limits ...". This doesn't match up very well with the ballot title.<br />
<br />
Ah, that's because the majority of the changes are in Colorado Revised Statues, not the constitution. I hadn't realized that a constitutional amendment could change law. Sure, it can force changes in law, but the other was new to me. Of course, the ballot title does start "Shall there be amendments to the Colorado constitution and the Colorado revised statutes ...", so I suppose both could be amended at the same time. I wonder if editing two things at once violates the single ballot rule?<br />
<br />
The real meat is in the CRS, 1-45-103.7 (9)(a).<br />
<blockquote class="tr_bq">
The voters instruct the Colorado congressional delegation to propose and support, and the Colorado state legislature to ratify, an amendment to the United States Constitution that allows Congress and the states to limit campaign contributions and spending, to ensure that all citizens, regardless of wealth, can express their views to one another and their government on a level playing field.</blockquote>
I suspect that, like the US Congress, no law can force a future Colorado legislature to an action, so the whole effort means about nothing.A. R. Diederichhttp://www.blogger.com/profile/02126469823641089850noreply@blogger.com0tag:blogger.com,1999:blog-8762946916697392615.post-3416564077864183822013-04-07T21:07:00.000-06:002013-04-07T21:07:49.900-06:00LaTeX and the Colorado Constition<br />
With the three amendments to the Colorado Constitution passed in 2012, it was time to update my pdf of the Colorado Constitution. The three amendments were Amendment 64 (Use and Regulation of Marijuana), Amendment 65 (Colorado Congressional Delegation to Support Campaign Finance Limits), and Amendment S (State Personnel System).<br />
<br />
Strangely, there is no official version of the constitution on the state website, http://www.colorado.gov. There is a scan of the original <a href="http://www.colorado.gov/dpa/doit/archives/constitution/1876.pdf" target="_blank">1876 constitution</a>, but that doesn't do us immediate good for today. Scott Gessler, the Secretary of State, does have a combined <a href="http://www.sos.state.co.us/pubs/elections/LawsRules/files/Colorado_US_Constitutions.pdf" target="_blank">US and Colorado Constitution</a>. It hasn't been updated with the 2012 amendments, and has a host of citations and notes from the LexisNexis website, the official provider of the Colorado Constitution.<br />
<br />
That's the really weird thing. The official version of the Colorado Constitution is only on the LexisNexis website. To even view it you have to agree to a 4,579 word terms and conditions document. It's at least not a pay-wall, but I shouldn't have to read about the Digital Millennium Copyright Act just to get to the state Constitution.<br />
<br />
Which brings me to my little project. I've taken all the text, minus the cites and other legal work that could really be LexisNexis property, and turned it into a <a href="https://docs.google.com/file/d/0B3uQej9IfYnbNWYwYmI5MGQtM2M3MC00Y2Q2LThhYzUtZWRjNjUyYTY1M2My/edit?usp=sharing" target="_blank">pdf</a> . Why not a word doc? Well, I wanted to use LaTeX so pdf is the way to go. It's nicely formatted in the general flavor of the original 1876 Constitution.<br />
<br />
You're welcome to the <a href="https://docs.google.com/file/d/0B3uQej9IfYnbMjU3ZjIzNDQtOTM2NS00Zjc3LWIxZmMtOTY1NjZmM2RjYzRm/edit?usp=sharing" target="_blank">LaTeX</a> file, too. These are still the 2010 versions -- I haven't finished copying in the 2012 amendments yet. I got Amendment 64 in today, hopefully the rest will come soon.<br />
A. R. Diederichhttp://www.blogger.com/profile/02126469823641089850noreply@blogger.com0