How to fix ESC[ in your terminal

Posted June 13, 2011 under General, Hacking, Ubuntu

I don’t know exactly what happened the other day, but I ran a git diff and instead of the usual red and green colors, everything was some form of ESC[32m ESC[1m ESC[m and so on in order to tell the terminal to switch colors.

ESC[1mindex 6008531..985ce31 100755ESC[m
ESC[1m--- a/bin/build-site.pyESC[m
ESC[1m+++ b/bin/build-site.pyESC[m
ESC[36m@@ -1,5 +1,9 @@ESC[m
 #!/usr/bin/env pythonESC[m
 ESC[m
ESC[32m+ESC[m
ESC[32m+ESC[m
ESC[32m+ESC[m
ESC[32m+ESC[m
 import getoptESC[m
 import gitESC[m
 import osESC[m

Okay this is just great. No idea what is going on, and I can’t possibly continue coding like this. After a bit of googling, there wasn’t much on the situation.

It turns out that the less command got misconfigured. I was working on Ubuntu and found the culprit to be the $LESS environment variable misconfigured.

$ echo $LESS
-eiMX
$ export LESS="-eirMX"

These two commands in terminal will print out the $LESS environment variable and then set it. The “r” option is what is crucial here. It’s what enables coloring in less output. Another environment variable you may look at is $PAGER.

Take a look here for a really good description of the problem: http://www.xcombinator.com/2008/07/23/mac-os-x-color-showing-escwhatever-for-git-diff-colors-and-more/


Upgrading to Dropbox 1.0 on Ubuntu

Posted December 21, 2010 under General, Ubuntu

Dropbox has to be one of my favorite services. I honestly don’t know what I would do without it.

Recently Dropbox moved up to version 1.0. Awesome! Right? Well, how do you upgrade to it in Ubuntu? The nautlius-dropbox package you installed didn’t receive an upgrade because no Dropbox repository was added to your sources. So what do we do?

Simple. Just stop Dropbox and remove the daemon.

Dropbox
Step 1) Close Dropbox
Step 2) Open up Terminal
Step 3) rm -rf ~/.dropbox-dist
Step 4) Start Dropbox again from Applications->Internet->Dropbox

Let Dropbox install the proprietary daemon again, and once it’s done, you’ll be happy to see that Dropbox 1.0 is installed and running. Complete with Selective Sync! :D


Asus 3070 Wireless USB and Ubuntu

Posted November 19, 2010 under Ubuntu

At home, my desktop is far enough away from our wireless routers that I can’t use a wired connection. I meant to pick up a wireless card for it, but apparently forgot (go figure!). Coming home today, I realized my desktop doesn’t have an internet connection anymore because I ganked the wireless router I had setup as a client-bridge for the desktop so that I could use it somewhere else. Whoops! I’ll write up a post on using DD-WRT as a client-bridge for a wireless network if people are interested as well.

Come home, fire up the desktop, no internet. What’s the first thing that comes to mind? Yoink my parent’s wireless card from their desktop. It’s not like they use it right? My usage of the internet has to be far more important than theirs so I’ll just use this for a week. :P

Well, being an Asus Wireless USB card with the RT3070 chipset, I figured I’d just plug it in and everything would be hunky dory. Of course not. Yeah, maybe if I was using Windows, but if I was using Windows I’d spend 30% of my time scanning for viruses, another 20% of my time cleaning out all these leftover temporary files everywhere, and the rest of the time would be trying to fix the 0×02350 error codes the software I’m trying to get working so I can just turn in my freaking homework. Okay maybe it’s not that bad, but it sure feels like it sometimes. :P

As for the wireless card, I knew it was one of the most popular on Newegg so a few minutes of googling brought me across the following instructions that lead to a successful wireless connection!

vim /etc/udev/rules.d/network_drivers.rules
Put this line in the file:
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="0b05", ATTR{idProduct}=="1784", RUN+="/sbin/modprobe -qba rt2870sta"
Proofread carefully, save and close.

sudo vim /etc/modprobe.d/network_drivers.conf
Put this line in the file:
install rt2870sta /sbin/modprobe --ignore-install rt2870sta $CMDLINE_OPTS; /bin/echo "0b05 1784" > /sys/bus/usb/drivers/rt2870/new_id
Reboot!

Simple enough. What can I say, I love the Ubuntu community! Mad propz go out to chili555 and his post over here: http://ubuntuforums.org/showpost.php?p=9445731&postcount=58


Getting Started with Ubuntu, CodeBlocks, and GLUT

Posted October 29, 2010 under Ubuntu

One thing I’ve been doing lately is getting into a little OpenGL. I’ve been using GLUT in Code::Blocks and really don’t mind it at all. As your typical Vim user, I find IDE’s to be bloated, ugly, and just plain messy to work with. I figured being mainly a scripter, I was biased because most of the languages I use are filled with beautiful stack traces that allow for easy debugging.

It’s been a while since I went back to C++ and I always used Visual Studio for development (because that’s what the school uses). Sure, I should have fought the power and built GCC compatible binaries, but in the long run, it’s easier to just build it in the environment it’ll be tested on and worry about building good software in my free time.

Here’s the couple of steps I did to get started with Glut on Ubuntu 10.10:

  1. Installed the dependencies: build-essential, codeblocks, and freeglut3-dev
  2. I fired up Code::Blocks and created a new GLUT project.
  3. Choose the GCC compiler and when it asks you where GLUT is installed, just tell it /usr. All the headers should be located in /usr/include and libs in /usr/lib so that’s why you just tell it to use /usr.
  4. Compile and debug away!

Passwordless SSH on Ubuntu

Posted October 22, 2010 under Ubuntu

I’ve been working on quite a few computers on a small network lately (more details about that to come). This is a huge pain since I’ve only got 1 keyboard and mouse for the bunch. I’ve setup Synergy to make my life incredibly easier, but even still, it’s nice to be able to ssh into the other machines effortlessly. I also need passwordless SSH for some applications I’ll be running on them.

First off, you’ve got to install openssh-server on all of your machines. That’s really simple. “sudo apt-get install openssh-server”, done. Now you may want to allow any machine to ssh into the others, so you can use the rest of these steps on your own to accomplish that, but I’m making one machine the master node where it will be allowed to SSH into all of the rest, but only that one (for now).

Second step is to hop on the master node you designated and run “ssh keygen -t rsa”. Follow the instructions and have it save to the default location and tell it to not use a password. Make sure to keep your private key private. This is very important.

The last step is what lets you login to the other machines using that ssh key you just created. It’s really simple. “ssh-copy-id -i ~/.ssh/id_rsa.pub username@HOSTNAME.local”. Just replace the username and hostname and you’re done. Do this for each of your machines and now you can use ssh passwordless and painless.


Ruby on Rails 3 and MySQL on Ubuntu 10.10

Posted October 16, 2010 under Ubuntu

Ruby on Rails has become my favorite web framework recently. The sheer speed factor of development is incredible, and once you get past the learning curve, you can build anything in a short matter of time.

Recently my Asus laptop’s graphics card has become supported in the Ubuntu kernel so I now have a dual booting machine running both Windows 7 and Ubuntu. This is particularly handy now as I can use this laptop for development in Rails.

The steps aren’t hard to figure out on your own if you’re familiar with the tools, but this is what I did to get Rails 3 with MySQL on Ubuntu 10.10.

Installing Rails from Terminal

sudo apt-get install ruby-full

wget production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz

tar -xvf rubygems-1.3.7.tgz

cd rubygems-1.3.7/

sudo ruby setup.rb

sudo ln -s /usr/bin/gem1.8 /usr/bin/gem

sudo gem install rdoc

sudo gem install rails

Installing MySQL Server from Terminal

sudo apt-get install mysql-server libmysqlclient-dev libmysql-ruby

Setting up your first Rails project

It seems that Rails 3 depends on sqlite3 even if you don’t intend to use it as the backend for your application. We’ll create an example rails app to make sure everything is working.

sudo apt-get install libsqlite3-dev build-essential

rails new example

cd example/

bundle install

rake db:create

rails s

Now fire up your browser, and go to http://localhost:3000 and you should be greeted with a nice little rails homepage. :D

UPDATE: I recently just ran these commands over again and ran into a “File not found: lib” error. After a bit of googling, I found this and appended the solution into the instructions above: http://stackoverflow.com/questions/2709683/ruby-on-rails-beta-3-install-problem-on-snow-leopard


Keryx on OMG!Ubuntu!

Posted September 24, 2010 under Keryx, Ubuntu

It’s been a while since I’ve posted anything on here. Life has been hectic, senior year of college has begun, and I’m working quite a few hours each week. Little free time means I’m usually too exhausted during those hours to actually accomplish something productive. That’s going to change and I needed a little boost to get motivation. I submitted Keryx as a tip for OMG!Ubuntu! yesterday to help spread the word.

I certainly did not expect such an overwhelming and encouraging response from the community. :-) It really touched me, as this blossomed out of an itch I had, and I never expected to have contributed to so many users along the way. It’s been a rough 4 years learning Python, version control, proper programming styles, and managing a decent sized project for a college student with no experience. I never dreamed I’d have over 32,000 downloads.

I just wanted to stop for a moment and thank each and every one of you. Each download sparks another ounce of motivation, and the contributions of code, translations, and bug reports has been unbelievably helpful in teaching me and helping to build a better product. Again, thanks for being such a wonderful community, I’m just happy that I could be of help to at least one other Linux user. :D

For those of you that haven’t read the article or the comments, here is the link: omgubuntu.co.uk/2010/09/keryx-offline-package-installation-made-easy-in-ubuntu/


Ubuntu Color Terminal

Posted July 22, 2010 under Ubuntu

So one of the things that might get annoying is Ubuntu’s plain terminal. You see everyone else with these sweet terminals, but when you make the configuration changes, it actually messes up the terminal options for changing colors! There’s actually a really simple configuration change in bashrc that will allow you to have a color terminal but continue using the colors in your profile flawlessly too:

gedit ~/.bashrc
Find this line: “#force_color_prompt=yes” and delete the “#” so it looks like “force_color_prompt=yes”
Save and close
Restart terminal

Voila! And you get something like this:


Multiple Version Control Systems At Once!

Posted July 12, 2010 under General, Hacking, Keryx, Ubuntu

For Keryx, I have been working on a new backend system called Unwrapt (A play on words regarding the APT package system :P ). I’ve been coding on github for the social coding aspects and keeping the branch on Launchpad.net as well to be part of Keryx’s page. This meant every time I wanted to commit and push, I’d have to do twice the amount of commands. Of course, being a lazy coder like the rest of us, I decided to script it. Fired up Gedit, and two seconds later I had this:

#!/bin/bash
 
bzr commit -m "$@"
bzr push
 
git commit -am "$@"
git push origin master

Usage is simple (example is using this script saved in ~/vcs.sh). Just execute this from inside your versioned directory like you would normally with git and bazaar:

$ sh ~/vcs.sh "first commit"

It pushes to your default branches (if you have any setup) in one strike using the commit message you pass to the script. Easy as that! I’m sure people might have some good ideas on features and improvements so leave them in the comments!


Changing the Ubuntu 10.04 Audio Channel Control

Posted June 10, 2010 under Ubuntu

This has been driving me nuts for the longest time and I just haven’t had time to look up the fix until now. Luckily the Ubuntu Forums has an unbelievably great community and got me an answer within a few hours. My problem was that the volume control for the new PulseAudio system in Ubuntu 10.04 would have either an On or Off volume and absolutely nothing in between. You could go from Off to completely On and none of the other notches would change a thing. Fiddling with alsamixer, I could tell that it was modifying the Master Front channel, but this wasn’t what was needed for my HDA audio card on my Asus M4N78 motherboard. I needed it to use the PCM channel.

lidex on the forums pointed me to this post where the details were all layed out for me:
This is being currently discussed in bug 410948.
To sum up, here's what you do:
Code:
sudo nano /etc/pulse/default.pa
Uncomment the line : #load-module module-alsa-sink
And add: control=PCM
So it reads: load-module module-alsa-sink control=PCM
Further down where it reads: load-module module-udev-detect
Add: ignore-dB=1
So it reads: load-module module-udev-detect ignore_dB=1
And save. You may need to restart for changes to take effect.
The volume control will now only adjust the PCM channel, so you may want to turn the Master and LFE to maximum in alsamixer.

And if you're getting that crackling sound:
Code:
sudo nano /etc/modprobe.d/alsa-base.conf
Comment out the last line which reads: options snd-hda-intel power_save=10 power_save_controller=N

After applying that fix, restarting and checking with the volume controls, I was pleased to see it was controlling the PCM channel finally!! Talk about an annoying issue. You never knew if you were going to blow your eardrums out plugging in headphones or turning on the speakers. All is good! I love the linux community. <3


« Older |