Linux Mint Tips and Tricks

I use Linux Mint, based on Ubuntu, almost exclusively. Here are a few tips and tricks I’ve picked up along the way:

  1. To get a panel from one monitor to the other, hold down alt while dragging the panel with the mouse.
  2. To connect to a Windows using remote desktop, use the Terminal Server Client application.
  3. To make Terminal Server Client capable of connecting to VNC hosts, install the xtightvncviewer: sudo apt-get install xtightvncviewer
  4. To find files modified in the past 3 days, use Terminal and this command: find . -mtime -3
  5. To be able to minimize any application to the system tray, install AllTray: sudo apt-get install alltray
  6. If you need a color picker that can get colors from anything you can see on your screen, try Gpick.

Maybe you’ll find these useful, maybe not. This post is more for my benefit so I don’t have to worry about losing these tidbits of knowledge in the future.

Do you have any good Linux Mint tips?

Posted in Linux | Leave a comment

Fixing the digitizer on a Samsung Rogue

My touch screen on my wife’s Samsung Rogue U960 recently stopped working. There were no cracks or other visible damage, but it didn’t recognize touches on the left third of the screen. Because the phone was designed to be used almost exclusively by touching the screen, this made the phone pretty much useless for anything other than receiving calls or calling people already in her address book. She couldn’t set alarms, browse the web, or use any of her phone’s other fun features.

Samsung Rogue Digitizer

I decided this would be a fun time to learn how to fix a broken cell phone. With the help of Google and eBay, I discovered that cell phone touch screens have something called a digitizer that lays on top of the normal LCD screen. It is thin, clear, and is what actually “captures” your touches. The LCD screen itself is just a screen. Without the digitizer, touching it will just leave smudges. Turns out my wife’s digitizer was broken.

So I ran to eBay and found a US seller that had replacement digitizers for the Samsung Rogue for only $12.99. The price was right and I enjoy not having to wait for shipping from Hong Kong, so I bought it.

The picture on the right is what arrived. No instructions. No tools. Just the digitizer. Hmm. What to do with it?

I decided step 1 had to be “rip apart my wife’s cell phone while she was in the other room so she couldn’t freak out about said ripping apart of cell phone”. So that is what I did.

It was harder than I thought it would be. The Rogue has a piece of plastic on the back that covers/surrounds the camera. It is easy to get under the edge of it at the bottom, and really really hard to get under the edge of it from the top. What I didn’t know at the time is that it can only be removed from the top, so I’m pretty surprised I didn’t break anything trying to pry it off incorrectly.

The rest of the case came off pretty easy with the help of my trusty New Haven Public Library card. It easily slipped under the case and unlatched it without breaking anything.

Eventually I got the phone fully apart, took off some screws, and had the phone in 5 or 6 pieces sitting on my desk. With some effort, I removed the old digitizer. It was glued in pretty good. I put the new digitizer in place, but it didn’t quite fit right. Upon further inspection, I discovered that the cell phone had a plastic bump that my new digitizer didn’t have a hole for. “Stupid American parts. I should have ordered from Hong Kong,” I grumbled.

So I found a razor blade and started shaving off the plastic bump. It didn’t look like it was actually needed anyway.

This is when my wife walked in. Pro tip: Don’t let your wife walk in until you are done taking a razor blade to her phone!

After a few minutes of carefully removing the plastic bump (very carefully once my wife started watching), I was able to attach the digitizer, connect it to the appropriate daughter board, and screw everything back together. I put the battery in, hit the power button, and….

IT WORKED! Woohoo! I didn’t crack the screen or lose any screws or end up with too many screws or completely break the touch screen capability. I was pretty excited. Becca was, too, because it was like getting a brand new phone for only $12.99.

So before you suffer with a broken cell phone or ditch it for new one, consider searching eBay for replacement parts and fix it yourself.

Posted in DIY, Electronics | Leave a comment

Zend Alternatives

When most people think of PHP they think Zend, but did you know that Zend isn’t the only company that makes a PHP engine? There are many competing compilers and interpreters for PHP, each with their own slightly different take on the PHP language.

Facebook’s HipHop

HipHop takes normal PHP code and transforms it into C++, which is then compiled in machine code. Code compiled by HipHop runs significantly faster than normal PHP run with the Zend Engine.

It has its disadvantages though. HipHop is only capable of transforming a subset of the PHP language. Some important (and some may say evil) features, such as eval, have been removed to make it possible to transform from PHP to C++. It also has a few other limitations, such as only supporting PHP 5.2 and 64-bit operating systems.

IBM’s WebSphere sMash

WebSphere sMash is a Java implementation of a PHP runtime environment. The PHP code is compiled into Java bytecode which runs on the Java Virtual Machine. The major benefit of running things in Java is that it is portable to more operating systems and allows you to use things like database connection pooling.

While it does support more PHP functionality than HipHop, it is still missing some features. However, it is capable of running a few major open source packages out of the box, including SugarCRM, Mediawiki, and WordPress.

Caucho’s Quercus

Quercus is another Java implementation of a PHP runtime environment.It too allows you to use Java features like connection pooling, and supports major open source packages like MediaWiki and WordPress.

The paid version allows you to pre-compile your PHP scripts, which allows them to run super-fast. Unfortunately, this is cost-prohibitive for users that have more than 1 CPU in their server (like me) or plan on having more than 1 CPU in the future (most anyone with a vaguely popular website).

Phalanger

Phalanger is a strange creature. It is sort of like PHP.NET. It takes your normal PHP code and compiles it into MSIL, which can then be run by .NET or Mono. The major advantage to using Phalanger is that it makes it possible to access .NET classes in PHP (for example, VB.NET or C#).

Thanks to Mono, .NET isn’t limited to Windows. This means you can write Gtk applications in PHP. I hope to have something released in the near future that uses Phalanger.

Posted in Linux, Web Dev | Leave a comment

Fixing Git

I use git as my version control system for all of my sites. It helps to reduce disk usage by occasionally running git gc. Last night when I went to run git gc on one of my sites, I received a message I had never seen before telling me that my git repo was corrupt. Corrupt? Oh noes!

So I searched the internet and discovered I could run git fsck –full to figure out what the problem was:

$ git fsck --full
broken link from    tree e79ab5efffca93a784afdb9cef73801eb1fa9db4
              to    tree fb9d707c76dde3f8cb672d1c07ca046615175587
dangling tree 1003e43ee3725b0482193aea9d82ca527c2903cc
dangling blob 361211b552b7910299e63b6627944ff72b0577eb
dangling blob 8e79df8dbe87431fbec8f25a4c6527fabe4d9e6f
dangling blob 9b3a891e5094920f743c36a49d1647d9aad2b2f0
missing tree fb9d707c76dde3f8cb672d1c07ca046615175587

After digging around the internet, I discovered that my repo was missing a tree, and that I could get it out of a cloned copy of the repo, assuming the cloned copy wasn’t corrupt, too.

I created a new empty repo:

$ mkdir new-repo
$ cd new-repo
$ git init

Next, I copied my pack file from the good repo to the new empty repo (there was only one in my pack folder):

$ cd /www/path/to/good/repo
$ cp .git/objects/pack/pack-c376dc3b9d2ce5f4d9ab9269d29ddc82f6f6a822.pack /path/to/new-repo

I unpacked the pack file to see if I could find the missing tree:

$ cd /path/to/new-repo
$ git unpack-objects < pack-c376dc3b9d2ce5f4d9ab9269d29ddc82f6f6a822.pack

My missing tree is fb9d707c76dde3f8cb672d1c07ca046615175587, so I looked to see if my file was there:

$ cd .git/objects/fb/
$ ls -l

9d707c76dde3f8cb672d1c07ca046615175587 showed up in the list, so yay! My missing tree was there! Now to copy it to the corrupt repo (my corrupt repo was a bare repo, so no .git in the path):

$ mkdir -p /path/to/corrupt/repo/objects/fb
$ cp /path/to/new-repo/.git/objects/fb/9d707c76dde3f8cb672d1c07ca046615175587 /path/to/corrupt/repo/objects/fb/9d707c76dde3f8cb672d1c07ca046615175587

That was it for me! I ran git gc and everything worked without a problem.

Hopefully this helps someone, or at least will help me remember what the heck to do next time my repo gets corrupted.

Posted in Linux | 1 Comment

DoS using a single client

Have you ever heard of Slowloris? It has been around for a little over a year, but fortunately I have never had the “pleasure” of dealing with it.

This short Perl script (less than 350 lines of actual code) is capable of turning your lowly desktop computer into a server killing monster. Traditional denial of service attacks use several clients (hundreds, sometimes thousands) to overwhelm the target server. The clients make as many requests as they can from the target server, causing it to use all its resources responding to the requests. Slowloris has a different approach.

Instead of using hundreds of clients, a Slowloris attack can often be successful run from a single client. And instead of overloading the server and utilizing a pile of bandwidth, Slowloris leaves the load on the target server at near zero and uses almost no bandwidth. It still makes a pile of requests, but it makes ….. them ….. nice ….. and ….. slow. Most web servers are only capable of handling a certain number of requests at a time (say, 150) so if you start 150 requests to the target server and leave those requests open for 10, 20, or even 30 minutes, you’ve effectively made it impossible for anyone else to get a valid request through to the web server. The target server isn’t actually doing any work, so the load doesn’t go up. What makes it even more annoying is the requests don’t show up in the log until they fail, if they ever do, which makes it more difficult to figure out what the heck is going on.

There are ways to mitigate the effectiveness of this type of attack, the most common being the use of a proxy to sit between the client and the web server (like haproxy or CloudFlare) and/or installing a bunch of Apache modules. Fortunately I’m doing both so hopefully I’ll be fine if someone decides they don’t like me much and wants to take down my server.

As a final note, I wholeheartedly discourage you from trying out the software unless you only do it on your local network. Attacking someone’s server is probably illegal and is likely to get your internet service shutoff. In other words, don’t be stupid.

Posted in Web Dev | Leave a comment