Posts

Showing posts with the label howto

Effectively Internet Filtering in 2020

(To skip my rambling intro and get to the nitty gritties, search this page for, "After that long introduction") In college, back when the internet was young, I hated the clumsy ineffective internet filtering that was in place on campus. It often blocked sites that were perfectly fine, and did not catch all the sites of the type that they were trying to block. Fast forward 10 years or so and I saw my children stumbling upon some content that I didn't want them to see on my unfiltered home internet and my attitude changed a bit. Back then web filtering was pretty easy. Nothing was encrypted and DansGuardian was the go-to tool. You set up a transparent web proxy and DansGuardian would scan the entire content of every website that you downloaded in your home. Incriminating words and phrases would trigger its blocking and it would replace the website you were downloading with an explanatory message. The beauty was that there was no need to scour the web, categorize every web...

How To Retroactively Annex Files Already in a Git Repo

UPDATE : With current versions of git, I no longer recommend git annex or git LFS unless you really need to store your large files on a separate server from your git repository. Just add your large files to git like any other file and when you clone, you can avoid downloading the full repository history with git clone --filter=blob:none and use git as normal. Table of Contents How To Retroactively Annex Files Already in a Git Repo First Tries: filter-branch, filter-repo Success with git rebase –interactive Added binary files Deleted binary files Modified binary files Moved binary files Dealing with Tags Clean Up and Results How To Retroactively Annex Files Already in a Git Repo In my last post I talked about how surprisingly easy it is to use git annex to manage your large binary files (or even small ones). In this post, I'm going to show how hard it is to go back and fix the mistake you made when you decided not to learn and use git annex at the start of your p...

Git Annex is Great

UPDATE : With current versions of git, I no longer recommend git annex or git LFS unless you really need to store your large files on a separate server from your git repository. For the simple use I describe here, just add your large files to git like any other file and when you clone, you can avoid downloading the full repository history with git clone --filter=blob:none and use git as normal. I'm developing the website for my business and I have a mix of code an images in my git repository. Since everyone seems to know that you shouldn't keep large binary files in your git repo, I decide to see what the current solutions to that problem are. After doing a little bit of searching, I narrowed things down to git lfs and git annex . Git lfs looks so nice and simple, except I'm not using github. Sure, you can set up your own central git lfs server yourself, but that sounded suddenly not so nice and simple. The website for git annex immediately hits you with all the ...

How not to mount a particular server with autofs

There are a couple servers that I use the fancy new (to me at least) autofs scripts to mount on my Ubuntu 9.10 client machine. You know, the ones that let you just cd /net/servername/exportname and it automagically turns that into the command to mount that export from that server at that mountpoint (so cool). To test something out though, I wanted to make sure one of the servers was not auto-mounted by autofs. The simple way to tell autofs to ignore that server (let's call it, foobarbaz) is to edit /etc/auto.net and put this snippet right after the key="$1" line: # don't mount foobarbaz, for now: if [ $key = "foobarbaz" ]; then exit fi Then restart autofs: sudo /etc/init.d/autofs restart And autofs automagically mounts any nfs server except foobarbaz.

Mac nfs client, Linux nfs server

I have a Mac laptop at work and it's been interesting to play with. We have nfs mounted home directories for our Linux workstations and I thought, hey, my Mac is a UNIX machine, it should be able to mount that nfs export too! Turns out, no, not by default. You get a nice "Operation not permitted" error message. The problem is that Mac nfs clients insist on using high numbered TCP ports, and Linux nfs servers by default insist on rejecting clients that use high numbered TCP ports. You can tell the Linux server to stop rejecting clients using high numbered ports with the insecure option in /etc/exports , or you can tell your Mac client to stop using high ports with the resvport option to your mount command. Most websites I found while googling for this just listed the Linux nfs server solution, which works fine if you have control over the server. Most people have a lot more control over their client. For autofs on the Mac, put ,resvport at the end of the /net ...

Ode to the Compaq 8510w

I got a sweet new laptop at work. It's a Compaq 8510w . The Core 2 Duo T7500 is fast, 3 GB of RAM is luxurious, and the 1900x1200, 15.4 inch widescreen LCD is pretty. I installed Ubuntu 8.10 and it sleeps (suspends to RAM) and wakes up like no other Linux box I've ever had, which is very, very nice (though the XO has started doing that with the latest update extremely well too). I installed the corporate image of windoze XP under VirtualBox. With the processor's virtualization extensions it runs pretty snappily. I can watch the corporate propaganda WMV movies, use Lookout for calendaring, and access the internal IE-only "web" apps just fine. I went with VirtualBox instead of kvm this time, kind of just to see what the differences where. I had to set up bridge networking because the corporate image didn't like not having a corporate IP address. I hear the newest version of VirtualBox doesn't need this, but here is the script I run to set up bridged...

You Really Should Hack Linux

I have a confession to make. I'm an avowed Linux geek, yet I haven't complied the kernel in years. The last time was probably in school when I had to write my own scheduler for the kernel as an assignment, which isn't all that bad when you consider that most people compiling their own kernels are just enabling some obscure driver that they needed. They haven't made Major Modifications to a core piece like The Scheduler. Right? Right? Well, OK, the scheduler wasn't anything to write home about, but it still felt pretty l33t. Anyway, I've decided it's time I delve into the source of Linux again. It's one of the most successful large software projects on the planet, and it's completely open for anyone to dig into. It would be a horribly wasted opportunity for a serious software engineer to miss out on, especially someone interested in nitty-gritty low-level stuff. Even if you aren't interested in OS code or drivers at all, you could study...

"could not stat the resume device file"

We have a local mirror of the Ubuntu repos here at work and they are pretty fast. I couldn't figure out how to get update-manager to use them, so I upgraded my desktop machine to Hardy Heron by changing everything in /etc/apt/sources.list from gutsy to hardy and typed sudo aptitude update && sudo aptitude full-upgrade and let it run. It asked a couple questions about modified config files and such which I answered, and then it was done. I rebooted and it put up the pretty "UBUNTU" with the new pulsating KITT -esque progress bar...and it never went beyond that. I finally hit alt-f1 and saw that it was waiting for my input with the prompt: resume: could not stat resume device file /dev/sda10. Please type in the name to try again or press ENTER to boot the system I hit enter and it seemed to boot just fine. This is a pretty annoying thing to have to do every time you boot, so I searched until I found the solution for me: reinstall initramfs-tools , like so...

KVM in Ubuntu Hardy Heron

Apparently there are some new gui apps for running and interacting with KVM on Ubuntu 8.04. After reading those two blog entries, I fired up virt-manager and virt-install, and wasn't very impressed. I didn't like the idea of piping the graphics through VNC when all I want is to run a virtual machine on my local desktop. And why do you need a confusing GUI when the command-line utilities for kvm/qemu are so straightforward? Now that I've said that, I'll point you at this overly complex KVM guide just so you can follow the first part to check if your CPU supports hardware virtualization . I would pretty much ignore the rest of that guide. Oh, and if your CPU doesn't support hardware virtualization, you can pretty much replace kvm with qemu in all the below steps and this will still work, just slower. Allright, here's how I set up a new KVM instance on my Ubuntu Hardy Heron box. I installed Hardy on the virtual machine in this example, but you could ju...

Better gnome-terminal Colors

If you use gnome-terminal with a dark background, the default colors that you get when you type, say, ls --color are hard on the eyes, especially the dark blue. To fix it, right-click, edit current profile, click on the colors tab, and under Palette choose XTerm from the Built-in schemes. Much much better.

GPS Fun(?) on Linux

I have a Magellan SporTrak Map GPS that I won as a door prize a few years back. Every now and then I dig it out of a drawer and play with it. I bought a new bike this week, you see, and I downloaded some routes from MapMyRide that I wanted to put on the GPS so I would have a route to follow while biking. Should be pretty straightforward, I thought. MapMyRide offers downloads of routes in gpx format, which I've run into before while playing with this gps stuff. Cool. So I downloaded the files and did a quick search for Linux GPS software. Unfortunately it still looks like gpsman is still really the only software out there that does what I need (please, please correct me if I'm wrong). gpsman is a piece of ugly tcl/tk software that does a fine job of connecting to my Magellan and allowing me to download and upload track data using the gpx file format. The interface is awful. It opens up three windows that aren't really labeled as to what they are, and offers all...

Screen as Serial Terminal

At work we use minicom on our Linux workstations to connect to the serial port of our development hardware. It works fine, but it's very text oriented. It also loses everything in the window if you re-size it. I've sometimes wondered if there are better alternatives, and today someone on one of our internal forums gave me a nice list. Sadly I couldn't find any of the suggestions for our old Red Hat 8 development boxes, except screen. I've used screen before and it's great. I had no idea it could do serial communication too. Here's the command I used for our environment: screen /dev/ttyS0 115200,cs8,-ixon,-ixon,istrip I also have this .screenrc file that someone gave me years ago: # kill startup message startup_message off # define a bigger scrollback, default is 100 lines defscrollback 1024 # remap CTRL-A to CTRL-] escape ^]] # status bar hardstatus on hardstatus alwayslastline "%{rk}%H %{gk}%c %{yk}%M%d %{wk}%?%-Lw%?%{bw}%n*%f %t%?(%u)%?...

Resize a QEMU/KVM Windows Disk Image

After playing with kvm and qemu during my knee surgery recovery , I got hooked. I have a working windoze XP install running under kvm on my Core 2 Duo, Ubuntu Gutsy Gibbon box, and it flies. It almost, almost feels like native speed (I also got help here and here ). It's great. Except, not being a regular windoze user, I'd lost track of how much space a windoze installation (and all the service packs and security updates) needs. When I created my original hard drive image file I made it 6 GB, which, it turns out, is too small. I didn't want to just create a new disk image and re-install, it took a lot of work to get this image up to it's full 6 GB glory. I hunted and found some instructions for resizing qcow (qemu copy-on-write) disk images , but they just didn't work for me. Once I converted from qcow (qcow2 actually) to raw, windoze wouldn't boot on the raw image. Gparted didn't show any partitioned drive space either. Then I remembered I'...

ReCAPTCHA and Django FreeComments

My little family blog has been discovered by spammers. They have started leaving comments on my Django powered blog. Not very often, but enough to be annoying. I heard about reCAPTCHA and thought it was a fabulous idea, so I decided that was how I wanted to up the ante for the spammers on my blog. Integrating reCAPTCHA with the Django freecomments wasn’t as easy as I thought it would be though, so I want to write down how I made it work in case it will help somebody else down the road. First of all, I did my due diligence and googled for help. I didn’t find much, but I found an email , a snippet , and a blog that got me going in the right direction. While I’m citing references here, I also made use of the comments page on the Django wiki , and the request and response documentation too. The reCAPTCHA api docs were vital as well. OK, after doing my reading googling I got to work. I registered for a set of reCAPTCHA keys, downloaded the recaptcha-clie...

Getting Desktop Effects Back for Gutsy

When I upgraded my Ubuntu machines from Feisty Fawn to Gutsy Gibbon the cool beryl/compiz desktop effects stopped being so cool. I have learned how to fix it, however, from a few awesome blog entries . Here's how I did it. First, remove any oddball compiz/berylemerald repositories from your sources.list. Everything you need is in the standard Ubuntu Gutsy Gibbon repositories. Next, remove any compiz/beryl packages that you previously had installed: sudo apt-get remove compiz* && sudo apt-get autoremove sudo apt-get remove beryl* emerald* && sudo apt-get autoremove Now, install the needful compiz packages: sudo aptitude install compiz compizconfig-settings-manager Now you can turn it on by running System->Preferences->Appearance and the clicking over to the Visual Effects tab. Choose Custom and then click on Preferences to bring up the settings manager. Then you can follow the How to set up Compiz Fusion instructions to get wobbly windows,...

How To Convert Bazaar Repo to Git

This was way more difficult that I thought it would be, but I have conquered. I may be the only person in the world who even cares about doing this, but I'm writing it here so I don't forget. I think it's hard because both the revision control tools, and the conversion tool are all still pretty new and in a state of flux. I finally got it to work using bzr version 0.15.0, git version 1.5.2.3, and tailor version 0.9.29. Both bzr and git are just what I had on my Ubuntu Feisty Fawn box that I keep up to date with backports and everything. Tailor version 0.9.26 is in the feisty repositories, but it most definitely didn't work for this. I grabbed the tarball for the latest source from here . You can just untar it and run it right from there. OK, now, once you have tailor, to make this work, you need a tailor configuration file. Just put it anywhere and name it whatever you like. Mine looked a little like this: [DEFAULT] verbose = True patch-name-format = ...

'git revert' Is Not Equivalent To 'svn revert'

I just learned that if you have some changes in your working tree that you want to get rid of, you don't type 'git revert' like you might guess. No, that's what cvs, subversion, mercurial, and bazaar (to name a few) use revert to mean, but not git. With git, revert is used to undo actual commits. Thankfully, you can undo your revert with another 'git revert', I just learned. So let me repeat to be clear, if you have changes to your working files that you want to abandon, DO NOT do this: git revert HEAD That will undo your last commit. Do this instead: git reset --hard HEAD I'm glad I have that straightened out now. I'm wondering if /etc was really a good place for me to start out playing with git. UPDATE: Nearly two years later and I'm still getting comments on this. I'm glad I've been able to help people out this way. The discussion in the comments is good, and one thing I'd like to point out is that I now always use...

Put /etc Under Revision Control (with git)

UPDATE : There is a much easier way now : sudo aptitude install etckeeper There, now etc is under revision control and changes are automatically committed with a helpful message after you install new packages. Thanks for the tip, Marcelo! Read on for the original blog entry. --- I put my /etc directory under revision control. I used git. It's awesome. Not that I think I'm going to wholesale copy my /etc from one machine to another, nor because I'm going to branch my /etc directory and spend weeks developing some cool new feature (whatever that would look like...) and then merge it back into the main branch. No, it's mostly because I like the idea of having the big "undo" option that having things under revision control provides. Having to commit changes and write check-in comments when I make changes helps me stay more organized too. It's never good when I go in willy-nilly to make a "quick change" to some configuration file. I r...

Fixed Django Powered Blog

OK, I figured out the problem with my Django powered blog . The new pg_hba.conf file had stricter permissions for local users. I had to change it from "ident sameuser" to "trust" and then my django app could connect to the database. I also had to make sure, after editing it as root, that the pg_hba.conf file was writable by the postgres user. Then I could /etc/init.d/postgresql-8.2 restart successfully, and everything works again. Oh wait, my php photo gallery is still down. Grrr!

Restore PostgreSQL

The magic command to restore my lost database , once I got my dump file out of my backup, was: sudo su postgres -c 'psql -f /home/bryan/backups/all.dbs.out postgres' My Django website still doesn't work though. Darn you, Ubuntu! (sorry for the harsh language)