You might expect this from people who don’t have much knowledge of iPhones; they don’t have a clear basis for comparison, so whatever features seem neat, they assume are new. But even people holding their own iPhone 4 up for direct comparison perceive the “iPhone 5″ Kimmel hands them to be superior, noting a range of details — it’s lighter, faster, just clearly better. They think a new version of a gadget must be way more awesome than the previous version, and Apple has an aura of coolness that leads people to expect their new products should be extra amazing. Since people expect a new iPhone to be awesome, they notice, or invent, features that confirm that it is, indeed, awesome.
Friday, September 14, 2012
Confirmation Bias and the iPhone 5
http://thesocietypages.org/socimages/2012/09/14/cognitive-bias-and-the-iphone-5/
Labels:
Links
Wednesday, September 12, 2012
How Apple and Amazon Security Flaws Led to My Epic Hacking
http://www.wired.com/gadgetlab/2012/08/apple-amazon-mat-honan-hacking/all/
After coming across my [Twitter] account, the hackers did some background research. My Twitter account linked to my personal website, where they found my Gmail address. Guessing that this was also the e-mail address I used for Twitter, Phobia went to Google’s account recovery page. He didn’t even have to actually attempt a recovery. This was just a recon mission.
Because I didn’t have Google’s two-factor authentication turned on, when Phobia entered my Gmail address, he could view the alternate e-mail I had set up for account recovery. Google partially obscures that information, starring out many characters, but there were enough characters available, m••••n@me.com. Jackpot.
Since he already had the e-mail, all he needed was my billing address and the last four digits of my credit card number to have Apple’s tech support issue him the keys to my account.
So how did he get this vital information? He began with the easy one. He got the billing address by doing a whois search on my personal web domain. If someone doesn’t have a domain, you can also look up his or her information on Spokeo, WhitePages, and PeopleSmart.
Getting a credit card number is tricker, but it also relies on taking advantage of a company’s back-end systems. … First you call Amazon and tell them you are the account holder, and want to add a credit card number to the account. All you need is the name on the account, an associated e-mail address, and the billing address. Amazon then allows you to input a new credit card. (Wired used a bogus credit card number from a website that generates fake card numbers that conform with the industry’s published self-check algorithm.) Then you hang up.
Next you call back, and tell Amazon that you’ve lost access to your account. Upon providing a name, billing address, and the new credit card number you gave the company on the prior call, Amazon will allow you to add a new e-mail address to the account. From here, you go to the Amazon website, and send a password reset to the new e-mail account. This allows you to see all the credit cards on file for the account — not the complete numbers, just the last four digits. But, as we know, Apple only needs those last four digits.
Labels:
Links
Sunday, September 2, 2012
Student Gulps Into Medical Literature
http://m.wpi.edu/news/19989/nitro.html
Mazur tells the story: "As tradition dictates, we made our own ice cream, using liquid nitrogen as a refrigerant and aerator. We spilled a little of the nitrogen onto a table and watched tiny little drops of it dance around."
Someone asked, "Why does it do that?" Mazur explained that the nitrogen evaporated when it came in contact with the table, which provided a cushion of air for the drop to sit on, and thermally insulated it to minimize further evaporation-enabling it to do its little dance without scarring the table, boiling away or being "smeared" out. "It's this principle," he said, "that makes it possible for someone to dip his wet hand into molten lead or to put liquid nitrogen in his mouth without injury."
Mazur had worked with the chemical in a cryogenics lab several years before and believed in the principle. To prove it to the doubting ice cream socializers, he poured some into a glass and into his mouth-fully expecting to impress the crowd by blowing smoke rings. But then he swallowed the liquid nitrogen. "Within two seconds I had collapsed on the floor, unable to breathe or feel anything other than intense pain."
Labels:
Links
Monday, August 27, 2012
Running Greasemonkey functions from page events
As you know, I wrote a simple Greasemonkey script to hide multiple results from one domain in Google searches. This script worked very well, and was easy to set up, but I had originally wanted to have the ability to click to show the hidden results. Doing this in javascript is pretty simple, but Greasemonkey runs all scripts in a sandbox which cannot be accessed from the page. This is somehow related to security, which I won't pretend to understand.
I was pretty content with how the script was, but someone on the script's page requested the click to show feature, and I figured I would give it a try.
Greasemonkey has something called the unsafewindow for stuff that must break out of the sandbox, and I got click to show working pretty fast using it. The problem is that everyone has a dogmatic animosity towards using it. So, I decided to try to figure out one of the alternatives.
The most common suggestion was to use the location hack, which just puts the function in a bookmarklet and links to it. If you don't know, you can run javascript on a page by just pasting it into your url bar. Prior to Greasemonkey, I used a lot of these via bookmarks called bookmarklets. Anyway, this is all relatively simple, but there is no actual example on the wiki. I eventually just had to try something out that I thought would work rather than being spoon fed someone else's example. Since the internet is no place for having to figure things out yourself I'll post the actual code I used.
Since the bookmarklet can be quite long I stored it in a variable first. Since javascript ignores whitespace like a sensible language I broke it up over multiple lines. The actual code is just wrapped in a self invoking function for reasons I still don't really understand.
Pasting that into something with syntax highlighting will show that
With this, my script is, at the risk of tooting my own horn, quite good. It is probably the only thing I've ever made that doesn't look like it was made by a 5 year old.
I was pretty content with how the script was, but someone on the script's page requested the click to show feature, and I figured I would give it a try.
Greasemonkey has something called the unsafewindow for stuff that must break out of the sandbox, and I got click to show working pretty fast using it. The problem is that everyone has a dogmatic animosity towards using it. So, I decided to try to figure out one of the alternatives.
The most common suggestion was to use the location hack, which just puts the function in a bookmarklet and links to it. If you don't know, you can run javascript on a page by just pasting it into your url bar. Prior to Greasemonkey, I used a lot of these via bookmarks called bookmarklets. Anyway, this is all relatively simple, but there is no actual example on the wiki. I eventually just had to try something out that I thought would work rather than being spoon fed someone else's example. Since the internet is no place for having to figure things out yourself I'll post the actual code I used.
Since the bookmarklet can be quite long I stored it in a variable first. Since javascript ignores whitespace like a sensible language I broke it up over multiple lines. The actual code is just wrapped in a self invoking function for reasons I still don't really understand.
showcode = "javascript:(function() {"+
"var results = document.getElementsByClassName('"+prevurl+"');"+
"for (i=0; i "document.getElementById('show"+prevurl+"').style.display = 'none';"+
"; } )()"; Pasting that into something with syntax highlighting will show that
prevurl is a variable, and outside the double quotes. Everything else is inside. This function is then called by just making the variable the destination of a onclick event. If you want to see more the source is on the script's page.With this, my script is, at the risk of tooting my own horn, quite good. It is probably the only thing I've ever made that doesn't look like it was made by a 5 year old.
Labels:
Stuff I Wrote
Wednesday, August 22, 2012
How Hollywood Is Encouraging Online Piracy
http://www.scientificamerican.com/article.cfm?id=how-hollywood-encouraging-onine-piracy
And if you don't make your product available legally, guess what? The people will get it illegally. Traffic to illegal download sites has more than sextupled since 2009, and file downloading is expected to grow about 23 percent annually until 2015. Why? Of the 10 most pirated movies of 2011, guess how many of them are available to rent online, as I write this in midsummer 2012? Zero. That's right: Hollywood is actually encouraging the very practice they claim to be fighting (with new laws, for example).
Labels:
Links
Monday, August 20, 2012
Hiker Leaves Dog on Mountain, Charged With Animal Cruelty
http://news.discovery.com/adventure/hiker-leaves-dog-on-mountain-charged-with-animal-cruelty-120820.html#mkcpgn=rssnws1
When Ortolani and his friend finally made it safely off the mountain and called 911, however, they discovered that Mt. Bierstadt rangers are not allowed to send rescues for dogs.This is certainly interesting. I suppose Captain Hindsight says you probably shouldn't bring a dog or person on a hike they can't physically do themselves.
Missy wasn't seen again until two hikers discovered her six days later. They, too, were unable to rescue her, but they posted a picture of the dog on a popular hiking website, which eventually prompted an eight-person volunteer crew to make a successful rescue -- despite a snowstorm.
The incident has sparked an outpouring of opinions. Ortolani goes to trial in October.
Labels:
Links
The Checkpoint: Terror, Power, and Cruelty
http://www.bostonreview.net/BR37.4/oded_naaman_israeli_defense_forces_palestinians_occupation.php
Threats. All day and all night he generates threats: he threatens people in order to extinguish their will. He does not know what their wills actually consist in. He can feel, by now, that part of them wishes he were dead. “If you didn’t have [your weapon], and if your fellow soldiers weren’t beside you, they would jump on you,” one soldier testifies, “beat the shit out of you, and stab you to death.” He imagines them charging his checkpoint by the hundreds: carpenters, doctors, teachers, farmers, mothers, uncles, children, grandparents, and lovers. How could so many people, people who look him in the eye every day, want him dead? How do the Palestinians see him? He does not recognize his own gaze reflected back at him from the windows of the cars he inspects or confiscates. He is no longer his own person.
Now that guilt is impossible, the soldier realizes that part of him is dying. The soldier starts to think that he is the real victim in all this, especially since no one understands that he is bound to fail, that his power makes him helpless. No one knows that since arriving here he has not made a single choice. Sure, the Palestinians are helpless too, but it is easy to see that they are victims, he tells himself. He, the soldier, is a powerful nobody—that is his tragedy.
Anger accumulates. Palestinians come up to him, one after the other, all day long, begging him to let them pass. Telling him they need to get to their schools, universities, hospitals, jobs; they need food; they want to see their children, their parents; they need to get to their funerals and weddings, to give birth. But how the hell should he know? Why do they think he has any clue as to whether they can pass through his checkpoint? He cannot tell the difference between them; they all act the same, the way terrified people act.
Labels:
Links
Sunday, August 19, 2012
Configuring Linux or: How I Learned to Stop Worrying and Love the Command Line
Foreword
Setup
Years ago, I had previously used Slackware with Fluxbox. So, I installed Slackware 13.37; the install was exactly the same as it had been 10 years ago. The network didn't work, and as I didn't really have another computer for troubleshooting I really didn't feel like dealing with Slackware. I have been wanting to give Ubuntu a try, and so I had also downloaded the newest Ubuntu, and I installed that.
Ubuntu used Gnome as its default desktop environment, although it seems to have switched to Unity, which I think is still Gnome based. I've never liked Gnome, and now both it and KDE have gone out of their way to be unusable. Luckily, there is a version of Ubuntu with lightweight xfce called Xubuntu. This didn't matter much as I planned on using the even more lightweight Fluxbox again.
It helps if you are familiar with the general structure of files in Linux. Here is a good overview:
http://www.thegeekstuff.com/2010/09/linux-file-system-structure/
http://lowfatlinux.com/
Installing Programs
When I used Slackware I used to install everything by compiling source, however, Ubuntu is well known for its friendly package manager and I made extensive use of it. It's nice because if you enter the name you think a program will have on the terminal it will tell you if it's installed. If it's not it will suggest similar names you may have meant. If there is a program called that, but it's just not installed it will tell you the command to run to install it:
Extra Programs
I had to install a lot of random utilities to do everything here. I won't bother mentioning them all; if you try something and it complains that something isn't installed, then just install it with apt-get. Rather, I will list the programs that I actually use directly that I had to find.
Geany is a text editor that I found as a replacement for Notepad++. It's ironic because when I first moved from Linux back to Windows one of my complaints was that I couldn't live without syntax highlighting provided by whatever text editor I had been using. I found Notepad++ as a suitable replacement on Windows and grew to love it. Now, moving back to Linux I don't know how I'll live without all the features of Notepad++. I'm liking Geany more as I use it. I'd say it may even be better than Notepad++.
For bit torrent, I went with qbittorrent. By default I had Transmission installed, which seemed good for people that didn't like bit torrent (I promise this opinion isn't biased by the fact that I associate Transmission with Macs). Anyway, qbittorrent is an open source clone of uTorrent, which is good because every since uTorrent was sold it was becoming increasingly annoying.
I found gmusicbrowser as a replacement for Foobar2000. I don't have many requirements in a music player, just a simple interface that can handle a lot of files. This wasn't hard to find, however, I couldn't find anything that simply had a random song feature. I should point out they all had shuffle, which randomizes the order of songs and plays them back. What I wanted was a button that when pressed would play a random song, but then playback would proceed in the normal order. I like to have that command mapped to one of my mouse buttons.
The closest I could find was a random album button, and to get this I had to manually edit the skin file to add the button to the system tray popup. As far as I can tell there is no command for it, so I have to use the button in the system tray.
Note this is no longer true. I'm using mpd, and wrote a section about it below.
Shell Scripts
Linux shell scripts are just a way to run commands that would normally be entered on the terminal via a text file. This is similar to batch files in Windows. The difference is that since everything in Linux is built on the command line from the ground up, they're much more powerful, and sensible to figure out. Just put commands in a text file and then run it with the command
Fluxbox Menu
Fluxbox is pretty simple. There are a handful of config files that control just about everything. These files are in a folder called ~/.fluxbox. One is called menu and it contains the Fluxbox menu that comes up when you right click the desktop (similar to the Windows start menu). This menu is pretty easy to edit, here are some good guides. There is one important note though. It doesn't update unless you update it yourself. There's a program called MenuMaker that will scan the system for programs and build a menu. You can run this with
This will just dump the menu to the screen. Redirect it to the menu file with:
Music Player Daemon
I eventually got tired of not having a random song button. I asked on stackexchange about a music player that had a random song command. The answers seemed to indicate that I was not explaining the concept of what I wanted to do very well. Reguardless, the common suggestion was to use mpd, which is a background command line music player, designed to be controlled by some other frontend. Note, mpd still doesn't have an actual play random song command, but I made a shell script to emulate that functionality.
To begin, I had trouble getting mpd to work at all. First it wouldn't connect to my gvfs music shares, and then it didn't produce audio. I ended up following this guide after which, despite being the same stuff I was doing, it worked. I'm sorry I can't give more details on what I actually did to fix my problems for anyone following this (ie future me).
After that, I had to figure out what client to use. mpc is a command line client that just issues commands. I also had Gnome Music Player Client installed, and it was suggested elsewhere, so I went with that. I must say, I must listen to music in a very different way from every other person on Earth, as I always find default music player's 'libraries' to be very unnecessarily complicated. I just want all my music in one giant list which will play back in order. Anyway, gmpc worked ok once I figured out how to set it up.
Another problem I had was that mpd purposely only supports one directory. If you have music in more than one directory and wish to add it all you are expected to set up symlinks in the one directory to the others. This is all well and good, but as I mentioned before all my music is on Windows Samba shares mounted via gvfs. Despite having write access in Linux to them, I couldn't set up symlinks in one to the other. After some experimenting to find the actual problem I found I could create symlinks to them, just not on them. So the solution was to just set up symlinks in my home directory to the various shares. This worked well, as it simplified the 20 levels deep nature of the shares at the same time.
All this and mpd still doesn't have an actual random command. It did have a random mode though. I got the functionality I wanted with this shell script:
This turns on random mode, skips to the next (now random) song, and then turns off random mode. Since mpd is very lightweight this is fast enough for me.
The Mouse and Media Buttons
I have a Logitech Performance Mouse MX, which I like very much. Unfortunately, Logitech doesn't support Linux at all. This meant I had to configure all the extra buttons myself. I found these two commands gave a good speed (which I like to be very fast):
As for the mouse buttons, I had to first find what the buttons were called. There's a simple program called 'xev' which displays the names of buttons that are pressed. After I found the names I added these lines to the Fluxbox config file keys:
Note the shell scripts. I did this because I use the mouse wheel left and right to switch tabs (Ctrl+page down/up). Since the sideways motion is not very good it would send a lot of key presses all at once and was unusable. I fixed this by adding some delays via this shell script:
I had to install sleepenh to get sleep times < 1 second.
Next, to get the media buttons (play, next, mute, etc) on my laptop to work I added these lines to the keys file:
A note about mute. There appears to be a bug in amixer where the mute toggle mutes three channels, but only unmutes one. This means you have to go in and manually unmute in the gui. I wasted a good hour trying to figure out what was going on with that. I had to write a shell script to mute and unmute all the channels. Here it is:
and muteall is just:
Startup File
One of those Fluxbox config files is the startup file. As the name implies it runs any commands in it when Fluxbox starts. It's important to note the command
I already explained some. xrandr sets the resolution. fbsetbg sets the wallpaper to a random one. The xfce4-power-manger gives popup alerts when the laptop switches to battery power. gvfs mounts windows samba shares. And, gmail notify is a Linux equivalent to the Windows gmail notifier by Google.
I made a bunch of 1440x900 wallpapers from various Hubble shots, and posted them here:
http://daleswanson.blogspot.com/2012/08/astronomy-wallpapers.html
Fluxbox Theme
Fluxbox themes are simple text files. I downloaded a few, but really didn't like most. I finally settled on the included 'squared blue' but modified it somewhat. I'll include my custom theme in the zip of all my custom files at the end of this post.
Cronjobs
Cronjobs are the Linux way of running a script or program automatically at set times, however, they are much more powerful than the Windows equivalent. The 'crontab' stores the various cronjobs set to run. It isn't stored as a simple file on the computer (while the system is running). To edit it enter the command
The format is somewhat interesting. It is in the form of: Mi H D Mo DOW command. Or: minute (0-59), hour (0-23, 0 = midnight), day (1-31), month (1-12), weekday (0-6, 0 = Sunday). For example:
Many more examples and a more thorough explanation are in this guide.
I wrote a simple backup script that currently consists of just a copy command, but I will likely expand it. I set it up to run every hour with
For things being run as cronjobs it is likely that you just want them to run with whatever idle resources there are, and to not get in your way. You can do this by making the command in your crontab that calls the script have a lower nice level (note -19 is highest priority, 19 is lowest, 0 is default, so kind of backwards [also it seems to be perhaps 20, at least sometimes]).
This is all well and good, but a backup script probably won't eat up too much CPU. What it will eat up is HDD I/O. That is where ionice come in to play. As you've probably already guessed ionice is a similar concept but just for I/O priority. In this case, class 3 is the lowest priority, and what I set the above backup script to.
Thunar Custom Actions
Thunar is the default file manager for xfce. It has something called custom actions which give you the ability to run commands on files from a right click menu. This has proven to be a very useful feature, which I've used to replace (and expand upon) the features of file menu tools in Windows.
They are stored in an xml file at ~/.config/Thunar/uca.xml. I've included that file in the zip of my custom text files at the end of this post.
Custom Text Files
As promised I've compiled a bunch of the text files I edited and uploaded them here:
http://daleswanson.org/blog/custom.7z
The 7 year old HDD in my laptop died. This gave me an excuse to switch from Windows XP to Linux. Since there was a lot of configuration to set things up I figured I'd document my trials and tribulations here for future reference. Note, this was written over about two weeks as I set things up. It sometimes reflects this, but I tried to edit it to make sense overall.
Setup
Years ago, I had previously used Slackware with Fluxbox. So, I installed Slackware 13.37; the install was exactly the same as it had been 10 years ago. The network didn't work, and as I didn't really have another computer for troubleshooting I really didn't feel like dealing with Slackware. I have been wanting to give Ubuntu a try, and so I had also downloaded the newest Ubuntu, and I installed that.
Ubuntu used Gnome as its default desktop environment, although it seems to have switched to Unity, which I think is still Gnome based. I've never liked Gnome, and now both it and KDE have gone out of their way to be unusable. Luckily, there is a version of Ubuntu with lightweight xfce called Xubuntu. This didn't matter much as I planned on using the even more lightweight Fluxbox again.
It helps if you are familiar with the general structure of files in Linux. Here is a good overview:
http://www.thegeekstuff.com/2010/09/linux-file-system-structure/
http://lowfatlinux.com/
Installing Programs
When I used Slackware I used to install everything by compiling source, however, Ubuntu is well known for its friendly package manager and I made extensive use of it. It's nice because if you enter the name you think a program will have on the terminal it will tell you if it's installed. If it's not it will suggest similar names you may have meant. If there is a program called that, but it's just not installed it will tell you the command to run to install it:
sudo apt-get install program-name, which can then be selected and middle clicked to install right away. Extra Programs
I had to install a lot of random utilities to do everything here. I won't bother mentioning them all; if you try something and it complains that something isn't installed, then just install it with apt-get. Rather, I will list the programs that I actually use directly that I had to find.
Geany is a text editor that I found as a replacement for Notepad++. It's ironic because when I first moved from Linux back to Windows one of my complaints was that I couldn't live without syntax highlighting provided by whatever text editor I had been using. I found Notepad++ as a suitable replacement on Windows and grew to love it. Now, moving back to Linux I don't know how I'll live without all the features of Notepad++. I'm liking Geany more as I use it. I'd say it may even be better than Notepad++.
For bit torrent, I went with qbittorrent. By default I had Transmission installed, which seemed good for people that didn't like bit torrent (I promise this opinion isn't biased by the fact that I associate Transmission with Macs). Anyway, qbittorrent is an open source clone of uTorrent, which is good because every since uTorrent was sold it was becoming increasingly annoying.
I found gmusicbrowser as a replacement for Foobar2000. I don't have many requirements in a music player, just a simple interface that can handle a lot of files. This wasn't hard to find, however, I couldn't find anything that simply had a random song feature. I should point out they all had shuffle, which randomizes the order of songs and plays them back. What I wanted was a button that when pressed would play a random song, but then playback would proceed in the normal order. I like to have that command mapped to one of my mouse buttons.
The closest I could find was a random album button, and to get this I had to manually edit the skin file to add the button to the system tray popup. As far as I can tell there is no command for it, so I have to use the button in the system tray.
Note this is no longer true. I'm using mpd, and wrote a section about it below.
Shell Scripts
Linux shell scripts are just a way to run commands that would normally be entered on the terminal via a text file. This is similar to batch files in Windows. The difference is that since everything in Linux is built on the command line from the ground up, they're much more powerful, and sensible to figure out. Just put commands in a text file and then run it with the command
sh file. For more complex stuff I'll just use Perl. The output of a script can be redirected to a text file with sh file > text.txt. I used several shell scripts where I needed to combine several commands into one.Fluxbox Menu
Fluxbox is pretty simple. There are a handful of config files that control just about everything. These files are in a folder called ~/.fluxbox. One is called menu and it contains the Fluxbox menu that comes up when you right click the desktop (similar to the Windows start menu). This menu is pretty easy to edit, here are some good guides. There is one important note though. It doesn't update unless you update it yourself. There's a program called MenuMaker that will scan the system for programs and build a menu. You can run this with
mmaker fluxbox -f, but if you want to have a custom menu you'll need to combine its output with your custom menu. I made a simple shell script to do this:echo "[begin] (Dale)"
mmaker fluxbox -c -i
cat custommenu.txt
echo "[end]"This will just dump the menu to the screen. Redirect it to the menu file with:
sh createmenu > .fluxbox/menu. Just put the custom part of your menu in the text file, and you're set. This is the custom menu I used, which includes easy access to several of the commonly edited Fluxbox config files:
[separator]
[submenu] (Mine)
[exec] (Thunar File Manager) {Thunar}
[exec] (FireFox) {firefox}
[exec] (gmpc) {gmpc}
[exec] (Pidgin Internet Messenger) {pidgin}
[exec] (qBittorrent) {qbittorrent}
[exec] (Calculator) {gcalctool}
[exec] (Geany) {geany}
[exec] (Leafpad) {leafpad}
[end]
[submenu] (FluxBox)
[workspaces] (Workspaces)
[submenu] (Styles)
[stylesdir] (/usr/share/fluxbox/styles)
[stylesdir] (~/.fluxbox/styles)
[end]
[submenu] (Config Files)
[exec] (startup) {geany .fluxbox/startup}
[exec] (menu) {geany .fluxbox/menu}
[exec] (keys) {geany .fluxbox/keys}
[exec] (layout) {geany .fluxbox/init}
[end]
[config] (Configure)
[reconfig] (Reconfig)
[restart] (Restart)
[separator]
[exit] (Exit)
[end]
Music Player Daemon
I eventually got tired of not having a random song button. I asked on stackexchange about a music player that had a random song command. The answers seemed to indicate that I was not explaining the concept of what I wanted to do very well. Reguardless, the common suggestion was to use mpd, which is a background command line music player, designed to be controlled by some other frontend. Note, mpd still doesn't have an actual play random song command, but I made a shell script to emulate that functionality.
To begin, I had trouble getting mpd to work at all. First it wouldn't connect to my gvfs music shares, and then it didn't produce audio. I ended up following this guide after which, despite being the same stuff I was doing, it worked. I'm sorry I can't give more details on what I actually did to fix my problems for anyone following this (ie future me).
After that, I had to figure out what client to use. mpc is a command line client that just issues commands. I also had Gnome Music Player Client installed, and it was suggested elsewhere, so I went with that. I must say, I must listen to music in a very different way from every other person on Earth, as I always find default music player's 'libraries' to be very unnecessarily complicated. I just want all my music in one giant list which will play back in order. Anyway, gmpc worked ok once I figured out how to set it up.
Another problem I had was that mpd purposely only supports one directory. If you have music in more than one directory and wish to add it all you are expected to set up symlinks in the one directory to the others. This is all well and good, but as I mentioned before all my music is on Windows Samba shares mounted via gvfs. Despite having write access in Linux to them, I couldn't set up symlinks in one to the other. After some experimenting to find the actual problem I found I could create symlinks to them, just not on them. So the solution was to just set up symlinks in my home directory to the various shares. This worked well, as it simplified the 20 levels deep nature of the shares at the same time.
All this and mpd still doesn't have an actual random command. It did have a random mode though. I got the functionality I wanted with this shell script:
mpc random
mpc next
mpc randomThis turns on random mode, skips to the next (now random) song, and then turns off random mode. Since mpd is very lightweight this is fast enough for me.
The Mouse and Media Buttons
I have a Logitech Performance Mouse MX, which I like very much. Unfortunately, Logitech doesn't support Linux at all. This meant I had to configure all the extra buttons myself. I found these two commands gave a good speed (which I like to be very fast):
xinput set-prop 9 "Device Accel Velocity Scaling" 30
xinput set-prop 9 "Device Accel Profile" 2As for the mouse buttons, I had to first find what the buttons were called. There's a simple program called 'xev' which displays the names of buttons that are pressed. After I found the names I added these lines to the Fluxbox config file keys:
Mouse9 :Exec sh random
Mouse7 :Exec sh tabright
Mouse6 :Exec sh tableft
Mouse13 :Exec xte 'key F5'
Mouse8 :Exec xte 'keydown Control_L' 'key W' 'keyup Control_L'Note the shell scripts. I did this because I use the mouse wheel left and right to switch tabs (Ctrl+page down/up). Since the sideways motion is not very good it would send a lot of key presses all at once and was unusable. I fixed this by adding some delays via this shell script:
xte 'keydown Control_L'
sleepenh 0.1
xte 'key Page_Up'
sleepenh 0.1
xte 'keyup Control_L'I had to install sleepenh to get sleep times < 1 second.
Next, to get the media buttons (play, next, mute, etc) on my laptop to work I added these lines to the keys file:
None XF86AudioLowerVolume :Exec amixer -q set Master 5%- unmute
None XF86AudioRaiseVolume :Exec amixer -q set Master 5%+ unmute
None XF86AudioMute :Exec sh togglemute
171 :Exec mpc next
172 :Exec mpc toggle
173 :Exec mpc prev
174 :Exec mpc stopA note about mute. There appears to be a bug in amixer where the mute toggle mutes three channels, but only unmutes one. This means you have to go in and manually unmute in the gui. I wasted a good hour trying to figure out what was going on with that. I had to write a shell script to mute and unmute all the channels. Here it is:
if amixer sget Master | grep "\[on\]"
then sh muteall
else sh unmuteall
fiand muteall is just:
amixer set Master mute
amixer set "Master Mono" mute
amixer set PCM muteStartup File
One of those Fluxbox config files is the startup file. As the name implies it runs any commands in it when Fluxbox starts. It's important to note the command
exec fluxbox is what runs Fluxbox itself. Any commands after that won't run until Fluxbox exits. Also, any command that will continue to run needs to have an ampersand placed after it. Here are the lines I added to my startup file:xinput set-prop 9 "Device Accel Velocity Scaling" 30
xinput set-prop 9 "Device Accel Profile" 2
xrandr -s 1440x900 -r 60
fbsetbg -c -r ~/.fluxbox/backgrounds/
sh createmenu > .fluxbox/menu
xfce4-power-manager &
gvfs-mount smb://Server-PC/Media &
python ~/gmail-notify/notifier.py &I already explained some. xrandr sets the resolution. fbsetbg sets the wallpaper to a random one. The xfce4-power-manger gives popup alerts when the laptop switches to battery power. gvfs mounts windows samba shares. And, gmail notify is a Linux equivalent to the Windows gmail notifier by Google.
I made a bunch of 1440x900 wallpapers from various Hubble shots, and posted them here:
http://daleswanson.blogspot.com/2012/08/astronomy-wallpapers.html
Fluxbox Theme
Fluxbox themes are simple text files. I downloaded a few, but really didn't like most. I finally settled on the included 'squared blue' but modified it somewhat. I'll include my custom theme in the zip of all my custom files at the end of this post.
Cronjobs
Cronjobs are the Linux way of running a script or program automatically at set times, however, they are much more powerful than the Windows equivalent. The 'crontab' stores the various cronjobs set to run. It isn't stored as a simple file on the computer (while the system is running). To edit it enter the command
crontab -e (-l will list the current one). This will allow you to edit it in a terminal based text editor, a concept I don't think I will ever embrace.The format is somewhat interesting. It is in the form of: Mi H D Mo DOW command. Or: minute (0-59), hour (0-23, 0 = midnight), day (1-31), month (1-12), weekday (0-6, 0 = Sunday). For example:
38 6 4 8 0 command would run at 6:38 am on Sunday Aug 4th. Much greater flexibility comes from wildcards (*), multiple entries (,) and multiples (/):12 4 * * * command - Every day at 4:12 am12 4,8 * * * command - Every day at 4:12 am and 8:12 am*/10 * * * * command - Every minute that is evenly divisible by 10 (ie every 10 minutes).Many more examples and a more thorough explanation are in this guide.
I wrote a simple backup script that currently consists of just a copy command, but I will likely expand it. I set it up to run every hour with
38 * * * * nice -n19 ionice -c3 sh ~/backup. Note the ionice. In Linux, nice is program which sets priority. The idea being that higher priority processes will get CPU and memory before lower priority ones will. In theory, this means that if a process is set very low it won't have any impact on the overall speed no matter how much CPU it eats up.For things being run as cronjobs it is likely that you just want them to run with whatever idle resources there are, and to not get in your way. You can do this by making the command in your crontab that calls the script have a lower nice level (note -19 is highest priority, 19 is lowest, 0 is default, so kind of backwards [also it seems to be perhaps 20, at least sometimes]).
This is all well and good, but a backup script probably won't eat up too much CPU. What it will eat up is HDD I/O. That is where ionice come in to play. As you've probably already guessed ionice is a similar concept but just for I/O priority. In this case, class 3 is the lowest priority, and what I set the above backup script to.
Thunar Custom Actions
Thunar is the default file manager for xfce. It has something called custom actions which give you the ability to run commands on files from a right click menu. This has proven to be a very useful feature, which I've used to replace (and expand upon) the features of file menu tools in Windows.
They are stored in an xml file at ~/.config/Thunar/uca.xml. I've included that file in the zip of my custom text files at the end of this post.
Custom Text Files
As promised I've compiled a bunch of the text files I edited and uploaded them here:
http://daleswanson.org/blog/custom.7z
Labels:
Stuff I Wrote
Saturday, August 18, 2012
Thursday, August 16, 2012
Hiding multiple results from the same domain in google search
A few months ago Google changed their search result behavior. Before, it would display one or two results from a single domain, and then give a link for more. After the change, it simply displayed all of them. This was made much worse by setting your results per page above the default 10. This was ridiculously annoying, to the point where I'm inclined to believe the conspiracy theories I read that Google did it to discourage people from setting the results higher than default and thus seeing less ads. I simply can't believe that Google thinks this is a legitimate improvement.
At this point, I should point out that all this really only applied if you turned off that crazy automatic search thing, and set your results per page to something high. I had pretty much assumed that everyone on Earth did this, but the fact that there wasn't a solution online after months tends to suggest that they don't.
I asked about this on stackexchange, but was surprised to get no solution. Although the fact that the question got a few votes suggested that other people were annoyed by this as well.
So, I decided to learn some more javascript by making a greasemonkey script to fix the results. I was almost deterred by the lack of formatting in the Google search results page, but a quick online formatter made it workable. Then, I had to figure out more of that javascript dot notation that I hate. All in all though, it went well. I wrote a basic script and uploaded it to userscripts.
http://userscripts.org/scripts/show/141480
As of now, it just looks at each result and if it's the same as the previous result it hides it. This means you will get less results displayed on a page than whatever you have it set to. I wrote a second version that counts how many duplicate domains there are in a row and hides them if there are more than a set limit, but I kind of like the simplicity of the current version. I will try to use it for a while and see what improvements I could make, as well as if anyone actually uses it.
At this point, I should point out that all this really only applied if you turned off that crazy automatic search thing, and set your results per page to something high. I had pretty much assumed that everyone on Earth did this, but the fact that there wasn't a solution online after months tends to suggest that they don't.
I asked about this on stackexchange, but was surprised to get no solution. Although the fact that the question got a few votes suggested that other people were annoyed by this as well.
So, I decided to learn some more javascript by making a greasemonkey script to fix the results. I was almost deterred by the lack of formatting in the Google search results page, but a quick online formatter made it workable. Then, I had to figure out more of that javascript dot notation that I hate. All in all though, it went well. I wrote a basic script and uploaded it to userscripts.
http://userscripts.org/scripts/show/141480
As of now, it just looks at each result and if it's the same as the previous result it hides it. This means you will get less results displayed on a page than whatever you have it set to. I wrote a second version that counts how many duplicate domains there are in a row and hides them if there are more than a set limit, but I kind of like the simplicity of the current version. I will try to use it for a while and see what improvements I could make, as well as if anyone actually uses it.
Labels:
Links,
Stuff I Wrote
Subscribe to:
Posts (Atom)