I’m one of those terrible people that still haven’t switched over to using Python3 …just yet. But one thing that pleasantly surprised me recently was learning of the “new” starred expression catch-all that can be used when unpacking iterables. This lets you use up to one starred expression to receive the rest of the items of an iterable during an unpacking assignment.
full_name = "Steven W J Brown"
#python2
names = full_name.split() # ['Steven', 'W', 'J', 'Brown']
first, last = names[0], names[-1] # 2.A: ignore middle names
first, mids, last = names[0], names[1:-1], names[-1] # 2.B: store middle names
#python3,
first, *_, last = full_name.split() # 3.A: ignore middle names
first, *mids, last = full_name.split() # 3.B: store middle names
It’s easy to read, eliminates the need for an intermediary variable and makes the code cleaner. And it can be used in loops. More details here: PEP 3132. Love it.
I really have to start re-configuring my environments for python3….
(Or just run it in your scratch buffer to try it out for your current session.)
The first line sets the org-indirect-buffer-display variable to new-frame. Now when you call org-tree-to-indirect-buffer or org-agenda-tree-to-indirect-buffer (C-c C-x b) from an Org buffer or an Org agenda item, Emacs will create a new frame narrowed to that Org sub-tree. I find this much more useful than the default other-window as I usually operate with one frame vertically split with two windows, and like to maintain manual control over the contents of the windows.
Similarly, I like a frame-focused behaviour when editing literal source blocks, which is what the second line sets. While in an Org source block, calling org-edit-special (C-c ' ) will open a new frame narrowed to the current source block and in the appropriate major mode (python-mode, for example). The variable for this setting is org-src-window-setup.
To see the documentation for either variables, use the Emacs help system! (C-h v variable-name)
Well this is odd. I’ve returned to a text editor I was introduced to in university, but wasn’t really taken with until just recently. The editor is Emacs and the reason is org-mode. Apparently, my story is not all that uncommon and org-mode (with evil mode) has even converted many Vim users.
Emacs has been around since 1976. (Nineteen-seventy-six! And it’s still actively developed! That’s insane!) Org-mode is an Emacs extension (major-mode) that has been in development since 2003 and included in Emacs core since 2006. Org-mode is basically an everything-mode; it allows for really intuitive outlines and section management, source code blocks, inline evaluation of those blocks and literal programming, comprehensive exporting, intra- and inter-document hyperlinking, tables/spreadsheets, presentations, ….the list goes on, and on, and on. And on.
The Boston Emacs Meetup has quite a few good Emacs videos with live demonstrations, and I really enjoyed this one, by Harry Schwartz:
As I continue to migrate all-the-things over to Emacs and Org-mode, it made me think about why I didn’t put more time into learning Emacs before.
When I was introduced to Emacs in university (somewhere around 2002 or 2003), org-mode was not included in Emacs and relatively young. At that time, Java was being promoted heavily in education, and for programming Java, it makes the most sense to use a Java IDE such as Eclipse or NetBeans which make the verbose language far more tolerable. So that’s generally what I did. But for my C or C++ programming, and general text file editing, I usually chose Emacs over Vi(m) due to it being more similar to what I was used to – but that’s it. I could move about in Emacs without leaving home-row, and I could make a few basic changes in VIM, save, and quit without panicking1. I could have been using Notepad++ and would have been just as happy. I was not taking advantage of either Emacs or Vim.
I never learned about org-mode until roughly 2 years ago (somewhere between June and August, 2016). Since then, I’ve gradually migrated as-much-as-I-fucking-can to these wonderful plain text files. I manage my work projects and todo lists. My agenda. My emacs config file. My blog(s); this post (via org2blog). I write documentation that can be exported into a variety of formats. And I keep learning new things; both for Emacs and for org-mode. Just recently, the org-mode time tracking finally clicked for me. I now schedule my days better and try to track where my time goes. This is extremely useful in evaluating what’s eating up my time, and estimating how long tasks will take so I can plan better.
The draw of org-mode has also made me appreciate Emacs, of course. I connect to Jupyter notebooks via ein and work on them with conveniences not offered in the browser interface2. I’ve heavily customized my environment, picked up a bit of elisp, and I’ve started tweeking my own theme. I recently moved from primarily using Linux to primarily using Windows, which has presented a few challenges with Emacs’ setup, but it’s helped me develop a consistent environment between work and home.
Both Emacs and org-mode are powerful but take a significant time investment to configure and use effectively. Spacemacs, a distribution of Emacs that comes heavily pre-configured and tries to combine the best of Emacs and Vim, offers a simple way to see what an advanced setup could look like. It’s not how I started, and some consider it too bloated, but it’s very well put together and certainly worth looking at.
Anyway, I’ll probably be reviving this blog with the odd org-mode or Emacs post, as that is what I’m playing with, these days. But in addition to the video above, a good intro would be Carsten Dominik (org-mode’s creator) presentation at Google:
I want to investigate moving my Jupyter notebook products to org-mode files under Git, only exporting them to notebooks, when needed… but that’s probably a separate post.
Initially, I wrote this script to give me frequent feedback on the signal strength. This is useful when adjusting antennas to that sweet spot that give stronger signals; especially if you’re testing some homemade tinfoil parabolic reflectors! 😉 If you have a portable wireless device, like a netbook, you can ssh into your (wireless) desktop and run wireless-strength to get realtime feedback on adjustments to the access point’s antenna… assuming the connection doesn’t break. 😛 And, of course, you can just walk around running it on your mobile device to create a kind of wireless heatmap.
If you have gnuplot, you can also generate graphs from the data with ws-plot. This is me walking around my house with my notebook:
I started in my room (40% 🙁 ), which is where the first peak is – near the window. Left my room, back to 40%, peak near window again, then bathroom… 40%. The climb from 40-80% is me walking towards the TV room (PS3 lives in a solid 80% zone, at least!). Walked upstairs, got 100% in most areas (that’s where the Access Point is) – tried a bedroom, dropped to 40%.
This script originated years back, but I recently tried using it on my laptop and it didn’t work! Unacceptable! The original parsed the output of iwconfig. But what showed up as “Quality=30/70” on my desktop, would show up as “Quality:4” on my laptop. COMPLETELY DIFFERENT. Even the character after “Quality” was different! o.O The output of iwconfig is driver dependent, which is why I looked to network-manager. I figured there’s probably a nice dbus command I can send to network-manager for that purpose – but I got tired of looking and decided to just parse output again. :/ Luckily, network-manager includes nm-tool. It’s certainly not a clean solution, but it works for now.
I also used updating rewriting the script as an excuse to get better acquainted with git – which I’m really liking.
Every time I do a bash script, I vow to do the next script in Python. I like Python and I don’t like Bash… but there’s a certain… nativeness or dependency-free elegance to bash scripts. Still, I hate writing them, and the next script’s in Python! 😛
added jetpack subscriptions module and some css to handle it
gave page a max width so it doesn’t look ridiculous on wide screen monitors.
sidebar: removed dotted borders added white space, toned down colours – reduced noise
Removed grey post-meta-content (categories, tags) boxes. Put all post meta data in TOP, with comments repeated at bottom. (Similar to when I started this theme!)
Added hover highlight to gallery images (now consistent with image links not in a gallery). Cleaned up some of the code (to not generate HTML comments) and random fixes here and there.
Removed lots of black. Too harsh.
You might have to click refresh. And you might not even notice any changes. 😛
Feel free to leave a comment or use Markup to make suggestions. Markup’s a pretty cool tool.
It’s interesting to compare the progression of my themes. Well, interesting for me, at least. 🙂
I think the next time I decide to work on a theme, I will start from scratch. Clean slate. Make it more consistent with my root page.
On a related note, the latest version of WordPress, 3.3.2, is really nice.
Curiosity gets the best of me sometimes. Okay, most of the time. Did you know GNOME’s text editor, gedit, has a plethora of extensions which can basically transform it into an IDE? Something I’ve always wanted is intellisense-style autocompletion. The closest thing I’ve found for gedit is GDP Completions Plugin in the gedit-developer-plugins package in Ubuntu.
sudo aptitude install gedit-developer-plugins
However, there’s a bug in that package and the popup menu doesn’t actually work. Ctrl + Space is supposed to bring it up. So you want to add the Gedit Developer Plugins PPA and upgrade to the more recent version.
If you try to run gedit now, you’ll notice it won’t… run, that is. Great. I know, right? The problem is that the bzr plugin (also included in the gedit-developer-plugins package) is trying to use the gtk2 version of bzr-gtk, but that doesn’t work in the gtk3 gedit. Anyway, you can pull a copy of the gtk3 bazaar plugin into your local bzr plugins directory. (I found this info here). Create ~/.bazaar/plugins/ if it doesn’t exist.
mkdir ~/.bazaar/plugins
cd ~/.bazaar/plugins
bzr branch lp:bzr-gtk/gtk3 gtk
The gedit-developer-plugins package and gedit should work after that! An alternative to the above would be to add a PPA that includes bzr-gtk 3. Not sure if one exists at the moment, but that would be a cleaner solution. And you thought it would be simple. I know I did. 😛
It’s not as polished or featured as other implementations, but it’s a good start. Here’s a screenshot after I type os. then hit Ctrl + Space:
GNOME 3.0 is due for release April 16 and I’m pretty excited by it. So I finally decided to check out first-hand how it’s progressing. My perspective is that of a GNOME 2.X user, but like many people, I was a little skeptical of the changes in 3.0. I tried the 0.0.6 image from the GNOME3 website and ran it off the USB key.
High quality and scalable graphics and interface – tried it on both a 10″ netbook and a 23″ monitor with success. Large title bars and close buttons – easy to hit.
All the updated core GNOME programs! I especially like the progress with Nautilus, the file manager. Instead of using a status bar, it uses a floating alt-type yellow info box to display info. Plus it seems much faster.
Single stroke exposé-like effect that reveals all windows, scaled and tiled. This is bound to the Windows (Super) key, which actually makes it more appropriately named for GNOME3 than any version of Windows. Note: It can also be reached by clicking Activities in the top-left corner. From here, you can use your mouse to switch to a window or quickly close windows, launch/switch-to a program from the left sidebar, or you can start typing a substring of a program to run, or a string to search using wikipedia or google (these options appear after you type something… OR you can browse applications by clicking Applications. Additionally, on the right, you can manage workspaces. With the smart launcher and window manager functionality tied to a single key, I found myself actually starting to heart the windows key and its prime keyboard real estate.
Don’t worry, you can still alt-tab! 🙂 And it’s improved, with mouse input, and grouping instances of the same program.
Modal windows are now attached to their parent window (by default, this can be changed).
Slick animations with meaning. Like the modal windows that slide out of the parent window’s title bar. I think OSX does something like this….
Yelp, the Help browser is about a billion times faster. Seriously. This is largely due to the shift from gecko to webkit, I believe.
No more minimize/maximize buttons. At first, I wasn’t sure about this and thought I wouldn’t like it, but the way the new desktop is designed, I don’t miss them. You can add them back, if it’s a concern. And all the old window shortcuts still work: [Alt+F9] = Minimize; both [Alt+F10] and [double-click title bar] = Toggle Maximize; [Alt+right-mouse-button] = window menu.
GNOME is just much leaner than it has ever been before. Instead of starting 3 different programs at login (nautilus, gnome-panel, metacity), it simply starts gnome-shell.
The Bad
Requires 3D support. Unfortunately, this is not always a simple request for us Linux users. Tried it on my netbook and failed. Couldn’t run it and probably never will thanks to the terribly supported poulsbo integrated graphics.
And not just any 3D support… Tried it on my desktop, also with integrated graphics, but a better supported ATI x1250 – performance wasn’t stellar, but it was usable.
Not very mature and not very customizable (yet). Panel Applets in prior versions of GNOME are extremely popular. Now we have this huge piece of space we can’t do anything with. But I’m sure something like panel applets will come eventually.
It’s really hard to train myself to look to the middle of the top panel for the time/date… I keep looking at the top-right. 😛
Some of the changes had me fishing for functionality. Like, where is the control-center? It’s not in the Applications list under the Activities window. It’s under the user menu, under System Settings.
And once you’re in the System Settings, you often want to change many things. At first, I was opening System Settings, selecting a component (they’re called Panels) to adjust (Background, for example), making changes, closing, repeat. When you open a panel from the System Settings window, that panel replaces the contents of the System Settings window. I didn’t notice the All Settings button that replaced the search entry in the dark grey area! After realizing that, it wasn’t so bad. 🙂 And to be honest, I think the theme or something is not quite finished. Looking at other screenshots on the web, the button is much more noticable.
The Ugly
BIG change in the way it expects people to use it. This will likely cause lots of frustration.
Doesn’t quite seem ready for prime time. I guess that makes sense, it’s still beta.
Some odd input lag every now and then. Visual artifacts. For both of these, I point my finger at my integrated graphics. Just a general lack of polish. But that’s to be expected with alpha/beta software.
Bold, black window titles with same-colour shadow. Ugh… I expect that will change soon. 🙂
After trying Shell, I’m actually more excited for it. It still lacks polish in areas, which is expected at this point, but I love the direction GNOME3 is taking GNOME. I’m hoping I can get by on my integrated graphics, but I’m probably willing to purchase a low-end video card to get better performance. Anyway, I’m really interested to see how Canonical’s Unity and GNOME Shell will evolve side by side. Now I have to try Unity, I guess….
To access the Internet on my desktop computer, I must use wireless. Unfortunately, it’s about as far away from the access point as possible: opposite corners of the house and different floors. And the wireless card I’ve got in my desktop is a little old and pretty cheap. Basically, I’ve had to battle with a poor connection for years. Often, I would have to manually move the antenna an inch this way or that, try reconnecting, and repeat. I vented to my friend, Shirley, about my connection, and she said her friend was having similar issues, so Shirley recommended she make a signal booster. That’s something I’d been thinking about doing, and thought it was about time. I googled how to make a booster. Enter the Parabolic Reflector available here. I’m sure there are lots others, but this is the one I decided to try out.
I made 3 of them. the first was made entirely with paper and tinfoil and it worked fine, but I figured I would try making a couple more with different materials: 2 different strengths of card. It’s good I did that too, as I ended up using 2 of them and giving the paper prototype to Shirley’s friend who most likely has better things to do than build paper parabolas. 🙂 (I, on the other hand, do not.)
What does it do? It turns your omni-directional antenna into a directional antenna with a stronger signal. The tinfoil does the radio wave reflecting and the shape (the parabola) just happens to be an efficient way to do that. Using this new direction, I’ve “pointed” the antenna on my wireless router towards my room – even on a bit of an angle through the floor. In my room, on my desktop PC, I’ve just pointed it horizontally in the direction of the access point.
The results have been great. Without any home-made boosters, I received 25-35%, with one on the access point, i received 35-55%, and with one on both the access point and my desktop antennas, I’m receiving a pretty steady 62-68% (see the graph, above). I still receive disconnects, but it’s now much easier to reconnect… usually happens automatically on the first try – I don’t even have to do anything!
So if you’re having wireless issues, give it a shot! It certainly doesn’t cost much. 🙂
If you have any trouble understanding how income tax works or is calculated, play around on this webpage and see if it helps you. (It probably won’t, but you might have fun not learning anything!) It lets you dynamically compare different income taxes within Canada using a pretty graph and it lets you calculate your own (simplified) tax results, whether your income is salary or hourly based.
Why Did I do this?
I didn’t do my taxes; an accountant did. But when I was reading about them, I stumbled upon a couple webpages and became interested in the differences among the provinces and territories within Canada and
different income ranges. That’s what started this mini Javascript project.
This is not a work of art
I wrote it mostly on the bus using my recently acquired Dell Mini 12 netbook (on Windows XP… ew). And from that experience, I can firmly say that writing even very simple things, it’s good to have a fair amount of time set aside in a relaxed environment. I would write a couple things here and there for 20 minutes or so… then not look at it again for a few days… it took me 5 minutes to figure out what I wanted to do the next time I opened it. The only times I made significant progress was when I sat down for more than an hour. The code wasn’t really designed, it was just… written. It’s messy, there’s lots of hard-coding, poorly named fields and variables (didn’t help with figuring out what I was doing last time), and if it were anything serious, I’d rewrite large chunks of it. And make it prettier. But as it stands, it’s just kinda fun. 🙂
In addition to being curious about the taxes in Canada, I was also interested in trying a javascript graphing library. I had been impressed with different javascript-generated graphs on the web and wondered how difficult they were to create. I used FLOT (with lots of copying and pasting from examples), and it seemed to work alright, but it depends on JQuery, which I wasn’t familiar with. Actually, I’m still not very familiar with it… and wrote almost everything in regular javascript. I know it’s worth learning, but I guess I’ll save
that for another time. 🙂
Let me know of any errors in tax calculation.. or code design, for that matter. There’s lots of those, but I’m sure I’m not aware of all of them! hah.
(I’ve been sitting on this post for about 2 months now. hah! Figured I might as well publish it.)
I decided that before I did any more work on the applet, I would improve its installation process to make it easier for people to try it out. So, the process to get and build the source now looks like this:
./configure --prefix=/usr(the prefix is important!)
make
sudo make install
If the applet does not show up in your Add to Panel menu, try restarting the bonobo-activation-server: killall bonobo-activation-server.
Autotools
Autotools is pretty much the standard in source package management on linux. Except for the name, there is nothing automatic about autotools. Every encounter I’ve had with autotools has usually defeated me and left me frustrated and leaving whatever I was working on to do something else. For me, because I had labeled it the next step, it basically stalled the entire project for a while. Most people tend to copy and paste other projects’ autotools setup, but I figured that was overkill for my purposes and I didn’t find anything that quite suited me. I looked at gnome-blog, but it seemed like some stuff wasn’t quite working properly and some was completely unnecessary… in fact, this seemed to be a trend when looking at the autotools stuff in projects. Why is this? Autotools is not simple and due to this simple fact, I think it fails completely on many levels. Developers massage it enough to get it working, but few actually understand it all – I know I sure don’t! So please forgive the sloppiness and feel free to send patches. 🙂 I gave up doing a couple things, like getting the revision number (bzr revno) and including it in the version string (see configure.ac). I know it’s probably something super simple, but I couldn’t seem to pass a variable containing a string as the version….
I feel that GNOME, as a platform for development, could seriously benefit from some kind of frontend to autotools that handled GNOME development nicely and hid as much as possible from the developer (including all those nasty config files that pollute the package tree). Anyway, I did not have an enjoyable time grappling with autotools, but I’ll end this mini-rant here.