Rolling Dice in Python

The below rolls dice in python.  I’ve long loved python for dice-rolling―having created a now defunct twitterbot and a mastodon bot―it was nice to write this up briefly as I’m working on re-re-re-learning python.

#!/usr/bin/python3 
from random import randint 
 
total_dice = int(input('How many dice? ')) 
dice_val = int(input("How many sides? ")) 
 
rolls = [] 
high_roll = 0 
low_roll = 0 
 
for i in range(total_dice): 
 roll = randint(1, dice_val) 
 rolls.append(roll) 
 
nums = len(rolls) 
 
print("") 
print("Roll #\tRoll") 
print("------------------") 
 
for i in range(nums): 
 print("#" + str(i+1) + ":\t" + str(rolls[i])) 
 
 
print("------------------") 
print("Highest: " + str(max(rolls))) 
print("Lowest: " + str(min(rolls))) 
print("------------------") 
print("TOTAL: " + str(sum(rolls)))

Output looks like the below:

How many dice? 20 
How many sides? 20

Roll # Roll 
------------------ 
#1: 8 
#2: 6 
#3: 18 
#4: 7 
#5: 14 
#6: 7 
#7: 6 
#8: 12 
#9: 2 
#10: 10 
#11: 2 
#12: 13 
#13: 3 
#14: 10 
#15: 20 
#16: 5 
#17: 6 
#18: 19 
#19: 1 
#20: 15 
------------------ 
Highest: 20 
Lowest: 1 
------------------ 
TOTAL: 184

Wonderful fun.

Bluetooth Keyboard Pairing on Kano OS

Our Logitech K380 keyboard wouldn’t pair to our Raspberry Pi 3 running Kano OS today (I know, very specific). I couldn’t quickly find an answer to this on the greater web, in part because I figured that the Kano folks would have had a helpful guide somewhere―but that turned out to be a faulty assumption. The following will, I hope, assist others querying the great search gods.

So, I recently had an issue with our Raspberry Pi 3 running Kano OS. The issue was that our Logitech K380 bluetooth keyboard was failing to connect. This keyboard has the unique ability to switch between being paired (differently) with up to three different devices. These are paired (and selected) by using the F1, F2, and F3 keys respectively. Hold down to enter pairing mode and―once paired―briefly depress to select that particular pair to interact with the specified device. Very cool!

I’m not certain if holding down the dual pairing/F[1|2|3] key resets whatever pair there was on that key, but that’s what appeared to have happened. Kids press things, it happens, and now they couldn’t type because the pair was broken. Not cool! But it gets even worse.

After trying to re-pair the device to the computer it became clear to me that Kano OS was preserving the device itself (I believe by MAC address) as an already-paired device. So it smartly was not allowing that same device to pair with a new key because, well, it already had agreed upon a key to pair with this specific device and that sounds like a potentially troubling security issue.

The Kano OS GUI interface offered no way to delete the device. Luckily this is Linux, so I knew there was certainly a way once I understood the problem well enough to seek a particular solution. The sad reality was that I needed to borrow a usb keyboard from another machine to type the commands (if anyone can walk me through text-input on a Raspberry Pi 3, Kano OS, with a mouse via command live I’m interested), but a post on “Ask Ubuntu” gave me the commands I was looking for:

Open terminal and type:

bluetoothctl

then you will see the list of devices you have paired with and their corresponding MAC address. To un-pair a device type:

remove aa:bb:cc:dd:ee:ff

replace aa:bb:cc:dd:ee:ff with the MAC address of the device to un-pair.

So after entering that command―which removed the device and previous key pair form the machine―I was able to go back through the GUI of Kano OS and “find” and then pair the keyboard anew with the OS. This was a successful experiment with wonderful results: kids using their computer once more.

Related note: If you have been considering a computer for your kids and have some peripherals and a monitor around, it would be hard to beat a $35 Raspberry Pi3 (and a ~$10 plug and ~$10 case). It’s truly a beautiful learning OS. You’ll need to help them out of course, but there’s a lot there for them to explore on their own. Easily the best purchase of any type I’ve made in years.

new art project: Kyle&

Kyle& This Burning Heart art piece

time off

One of the things I’ve been doing this past week is creating art, initially with Kyle& … nobody. I’d been working on some things for the Fedora project on and off, but nothing was really sticking until I started working with my kids.

My children are very good motivators with respect to artistic output because they’re constantly creating artworks―comic books, sculptures, sketches, oral stories, small performances , and elaborate board games. It’s inspiring to watch them create without burden.

They have helped me come to a realization about myself―I’m happier when I’m collaborating. It could be my background in theatre, my penchant for teaching, or my constant questioning of my own ideas (and appreciation of other voices to move forward). Collaboration is something I’ve always found valuable because it’s been a valuable part of of the art I’m most proud of.

Kyle&

So I’ve decided to call a new project into being. I’m calling it Kyle&. It will be a place (and, mentally, a namespace) where I will collaborate with different people to create something new. I’m hoping it’ll be interesting.

Perhaps these artworks will be accompanied by a brief interview with my collaborator? Maybe they will be available for patronage in one form or another? Perhaps there will be other interesting opportunities. I don’t exactly know―it’s an experiment.

this burning heart

The first of these experiments is with my 5 year old and is called This Burning Heart. She had seen me share things with the internet before and wanted to do so herself. I suggested we work together to create something and this is what we ended up with. She’s proud to have shared something with the internet and I’m happy to have found a new outlet to excite the kids.

We’ve already done some things with my other kids (they were jealous). Will post about those later. Hope you enjoy This Burning Heart.

 

 

 

 

Saying No and Yes―Bill Murray Interview

SR: A lot of folks worry that if they aren’t available or don’t say yes, they’ll stop getting asked.

BM: If you keep saying yes, they’ll stop asking you, too. That’s a much more likely event. I think we’re all sort of imprisoned by — or at least bound to — the choices we make, and I think everyone in the acting business wants to make the right choices. You want to say no at the right time and you want to say yes more sparingly. I came out of the old Second City in Chicago. Chicago actors are more hard-nosed. They’re tough on themselves and their fellow actors. They’re self-demanding. Saying no was very important. Integrity is probably too grand a word, but if you’re not the voice of Mr. Kool-Aid, then you’re still free. You’re not roped in.

This reminds me a little bit of a book called essentialism which talks about saying no to things. It doesn’t quite match up, as Murray sways into type casting, but the impetus is similar.

http://esquire.com/entertainment/interviews/a14156/bill-murray-interview-0612/

asterisks

The project preview

I’ve been working on a project. I believe it’s a good one.

I have arranged some asterisks―

asterisks

―and also borrowed and modified a line―

line

―then I borrowed some cruft (dusted off from something pretty good, if a little old)―

stuff

―at the end of it all I have some words.

Cryptic Outro―apologies

So really, its just a long-time project that began over two years ago that I think still has a place in the conversation about rights, dignity, and human values. I’m hoping to have this out by years’ end, but I’m also wanting to ensure that I’m not missing an opportunity to incorporate some other elements into the work from recent events.

Perfect is the enemy of good enough.

 

Squeak

I contributed to the most recent Fedora Linux release’s wallpaper. It’s interesting to have seen it pop up everywhere I normally read about Linux as a featured image touting the new releases arrival.

At any rate, this is a squeak from me. It’s been a while since I’ve posted here (I was off playing with static site generators and custom Emacs scripts), but I’m quite happy to be back. I may migrate the writing I did elsewhere to this blog in time.

At the moment I’m working to add some portfolio content to this site. My 3×5 artwork series for a local coffee shop finally gave way to heavily manipulated photography series I’m currently in the middle of completing. This return to pixels from vectors is a long time coming. We’ll see how long it lasts.

Excited to share with you all.

Squeak! — A-Hem

a quick drawing

instead of hand-drawing the stripes I’ve matched them up with a digital tool after the original hand-drawn outline. not certain I like this (in fact―pretty certain I don’t) but it’s clear that I’m going to move somewhere here to progress. we’ll see what happens there. At any rate―behold something new.

 

draw-coffin

Tutorials?

I’m thinking about doing some tutorial-type things revolving around some of the free-software tools I use to create visual art. Predominantly I’d focus on inkscape (at least at the moment) since I’ve been enamored with vector graphics on that program for a while. I’m also interested in doing something for inkscape as it was a program I avoided for a long time and there was no reason for the delay. If I can assist anyone out there in picking it up faster the world would truly be a better place.

I’d have to talk about other tools I tend to use like gpick, GIMP, digikam, darktable, and others I’m likely forgetting. Looking back and trying to think about writing out my process for any of these things becomes daunting quickly―I forget how many little processes I’ve enacted over the years that otherwise complicate the explanation of what I’m doing.

For instance, I’ll often prepare images in GIMP (using the G’MIC plugin) prior to vectorizing in inkscape. That single step for me is just a given, but in the context of a tutorial it would require explaining a whole other program and a separate plugin for that program. *Alas!*

bunny-01

But I think others could learn… so I’ll probably do it.

White keyboard layout

This is a pretty amazing use of programming and personal data to create a custom keyboard layout for yourself. Great read.

This scoring method is then evaluated on a collection of text that is representative of all text I’ve typed in the last five years, which produces a number representing the objective function. Specifically, I take all of my code, IMs, emails, and articles over that time period, remove any non-ASCII characters, and create a long word frequency list to be used in scoring layouts. Lastly I throw out any words that were not used more than 20 times over 5 years, for the sake of efficiency.

Link

I can’t recommend strongly enough that you take the time to read the entirety of APPLE INC.’S REPLY TO GOVERNMENT’S OPPOSITION TO APPLE INC.’S MOTION TO VACATE ORDER COMPELLING APPLE INC. TO ASSIST AGENTS IN SEARCH. Some gems below:

The government attempts to rewrite history by portraying the [All Writs] Act as an all-powerful magic wand rather than the limited procedural tool it is. […] Thus, according to the government, short of kidnapping or breaking an express law, the courts can order private parties to do virtually anything the Justice Department and FBI can dream up. The Founders would be appalled.
This case arises in a difficult context after a terrible tragedy. But it is in just such highly-charged and emotional cases that the courts must zealously guard civil liberties and the rule of law and reject government overreaching.
Indeed, it is telling that the government fails even to confront the hypotheticals posed to it (e.g., compelling a pharmaceutical company to manufacture lethal injection drugs, Dkt. 16 (“Mot.”) at 26), or explain how there is any conceivable daylight between GovtOS today, and LocationTrackingOS and EavesdropOS tomorrow.
The government also implicitly threatens that if Apple does not acquiesce, the government will seek to compel Apple to turn over its source code and private electronic signature. Opp. 22 n.9. The catastrophic security implications of that threat only highlight the government’s fundamental misunderstanding or reckless disregard of the technology at issue and the security risks implicated by its suggestion.

The government’s position has sweeping implications. Under the government’s view, the state could force an artist to paint a poster, a singer to perform a song, or an author to write a book, so long as its purpose was to achieve some permissible end, whether increasing military enrollment or promoting public health. […] The First Amendment does not permit such a wholesale derogation of Americans’ right not to speak.