Use source to import large .sql files

Its true, don’t waste your time with strange scripts and such if you’re trying to upload an .sql file that exceeds the limit. Just give up and use source. Note: don’t be confused that I don’t capitalise my MySQL commands. Its my silent protest against standard MySQL syntax: I think capitalising commands you have to type over and over is dumb. SOURCE is the same as source.

  1. Upload the .sql file to your server somewhere, preferably with lftp
  2. ssh to your server: $ ssh username@username.hostname.com
  3. Start mysql: $ mysql -u username -p password
  4. Find the correct table: $ show databases;
  5. Access the database you want to import to: $ use databasename;
  6. And finally the source command: $ source path/to/filename.sql

I used several sources for this, but John Andrews was the angriest.

Posted in Solutions | Leave a comment

A plug for Lee Howard and Mystery Machine Studio

Lee is the owner and sound engineer at the soon-to-be huge recording studio Mystery Machine Studio in Portland, OR. I built his website (http://www.mysterymachinestudio.com/).

A CD that Lee recorded for local folk/pop hero Nick Jaina was just released to critical acclaim, and we’re trying to drum up some exposure for Lee’s beautiful little basement studio. Go Lee!

Posted in Musings | Leave a comment

The better way to install LAMP on Ubuntu Karmic 9.10

All this comes from here:

https://help.ubuntu.com/community/ApacheMySQLPHP

In the teminal:

  • $ sudo tasksel install lamp-server
  • $ sudo apt-get install phpmyadmin
  • $ sudo gedit /etc/apache2/apache2.conf
    • Add the following to the end of this file:  “Include /etc/phpmyadmin/apache.conf”
  • Edit the /etc/php5/apache2/php.ini file and increase the memory_limit value. I used 64M, but that may be overkill.
Posted in Apache, Linux, Solutions, Ubuntu | Leave a comment

Bash aliases: create your own bash shortcuts!

When I’m building websites especially, I have to work with a lot of deeply nested files. But typing cd ~/public_html/websitename/wp-content/themes/themename/ in the terminal every time is giving me carpal tunnel, so I found a better way:

First open ~/.barshrc in a text editor and uncomment lines 73 through 75 so they look like this:

if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi

Then create a file called .bash_aliases in your home directory (if it doesn’t already exist). Edit that file like so:

alias themename="cd ~/public_html/websitename/wp-content/themes/themename/"

Restart terminal (or source .bashrc with $ source ~/.bashrc, or even terser $. .bashrc), type in themename and press enter. Voila! Your are cd’ed all the way into that deeply nested file without having to type the whole thing. This works great for lots of other common commands that are a little too verbose:

alias ins="sudo apt-get install"

Once those lines are added to your .bash_aliases file and you restart terminal, you will be able to install new packages like so:

ins packagename

Handy eh? (That last suggestion is courtesy of the always useful Lifehacker)

Posted in Linux, Solutions, Ubuntu | Leave a comment

How to configure Apache virtual hosting in Ubuntu Karmic 9.10

Before you do anything, back up your original config files. I used to just create a copy of the files with the suffix “.bak” (sudo cp example.conf example.conf.bak), which works, but creates a lot of clutter. Now I use a great little utility called etckeeper which automatically places all files in /etc under version control using Bazaar. It also automatically performs a commit each day if you forget to. You can get etckeeper by typing this in the terminal: sudo apt-get install etckeeper.

Update, 3/29/10

I just had to do this from scratch after a computer disaster, and I found an omission. Before you get started on this business you need to do what this post says:

http://www.likesalmondesign.com/use-your-users-public_html-directory-to-serve-webpages/

And we’re off

Now on to virtual hosts. The first thing you need to do is edit /etc/hosts so your computer knows where to look for your website:

  1. In the terminal, enter: $ sudo gedit /etc/hosts
  2. In gedit, add the following line to the hosts file: 127.0.0.1 mysite.dev
    • Note: you can use whatever name you want for your virtual hosted site. I like to use the suffix .dev because it won’t conflict with sites on the actual internet.
    • Note: 127.0.0.1 is the same ip address that is assigned to localhost in that file. If yours is different, use that one.

Next add your site to /etc/apache2/sites-available/ and then link to that file in /etc/apache2/sites-enabled/:

  1. In the terminal, cd to /etc/apache2/sites-available/
  2. Create a new file with: $ sudo touch mysite.dev
  3. Open that file in gedit: $ sudo gedit mysite.dev
  4. Add following to that file:
    <VirtualHost *:80>
    ServerName mysite.dev
    ServerAlias mysite.dev
    ServerAdmin myaddress@email.com
    DocumentRoot /home/yourusername/public_html/mysite/
    </VirtualHost>

Add a pseudo link to that file in /etc/apache2/sites-enabled/:

  1. cd over to /etc/apache2/sites-enabled/
  2. In the terminal, enter: $ sudo ln -s /etc/apache2/sites-enabled/mysite.dev mysite.dev
    • Note: $ ln -s target linkname

Finally, restart Apache:

  1. $ sudo service apache2 restart
  2. You’re done!

See! Not so bad…

Posted in Apache, Solutions, Ubuntu, Virtual Hosts | Leave a comment

Add Mootools to a Wordpress child theme

The following code, when included in the functions.php file in your Wordpress child theme, will correctly load Mootools and a custom script. This is the only way I am able make custom scripts work, but you hear a lot of stuff out there on the interweb…


<?php
function add_js() {
$stylesheet_dir = get_bloginfo('stylesheet_directory');
$myscript = $stylesheet_dir . '/js/myscript.js';
$mootools = $stylesheet_dir . '/js/mootools.js';
wp_enqueue_script('mootools', $mootools, '', '1.2.4', false);
wp_enqueue_script('myscript', $myscript, array('mootools'), '1.0', false);
}
add_js();
?>

Notice how every parameter is used in the < ?php wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ); ?> function even though all but the first one is supposed to be optional. Maybe its a PHP thing. Whatever.

Posted in Solutions, Wordpress | Leave a comment

I’m switching to Chrome (on a trail basis)

I thought I would be a Firefox user till I died, but holy crap Chrome is fast! I can launch Firefox, go make a sandwich, launch Chrome and be browsing before Firefox loads. This is particularly nice on our crappy Windows machines at work. JavaScript is noticeably faster. Chrome seems more stable and doesn’t do that occasional temporary freeze thing on slow computers. As much. Well, at least the whole thing doesn’t freeze, just the one tab that is having trouble.

Extensions

The Dev and Beta version of Chrome work with extensions (like LastPass, worlds greatest password manager). The dev version has been very stable for me:

http://dev.chromium.org/getting-involved/dev-channel

Developer Tools! Eeeee!

The thing that sealed the deal is the built-in developer tools. Seems they’ve shipped Chrome with a built-in Firebug-like JavaScript debugger and inspector (press ctrl-shift-j). Its not installed automatically on Linux machines, so apt-get it:

sudo apt-get install chromium-browser-inspector

I haven’t used it enough to form an opinion yet, but it looks great. I’m going to finish out the current site I’m developing with Firefox and Firebug, but I’ve got another one in the pipe that is going to be all Chrome.

Fantastic UI

Best user interface of any browser I’ve used.

The teeny tiny branding means I get at least a quarter inch of screen real estate that would normally be full of dialog. Page loading info is shown in a tiny pop-up at the bottom, so I get more space there too. Its overlaid on top of the horizontal scroll bar, taking up no room at all. The combo address/search bar means the horizontal space is more usable too. I can usually see the whole url even when I’m using Chrome in a small window.

I love love love the tabs at the very top. It reinforces the idea that each tab is its own process doing its own thing (dialogs like preferences are also displayed in a tab, just like web pages). Tabs are arguably the most important feature of the browser dialog, they tell you where you are, and I definitely click on them more than anything else. Making them a big target right at the top where they are the most obvious thing in the whole interface is genius.

Way to go Google! Can’t wait for Chrome OS!

Update, 2/25/2010

Well, I tried.  Turns out that the Chrome developer tools has some usability issues that make it very hard to use effectively.  The number one problem is that the font is too small.  I get a headache just glancing at it.  I’m also annoyed by the checkboxes that pop up when you mouse over a css property.  I’m sure that one sounded really great on paper, but in practice its horrible.  The major thing it lacks is the “Larger Command Line” option that Firebug has, which allows you to put multi-line indented code in the console and run it.  It’s really nice and I use it all the time.

I still really like Chrome and I use it more and more (even though it doesn’t work with Netflix) for my non-development browsing pleasure.  Its still a young project and I’m hopeful that Google will improve the developer tools soon.

Posted in Musings, Software I use | Leave a comment

Wordpress Error: Unable to create directory / Is its parent directory writable by the server?

If you get this error when you try to upload an image to your WordPress blog, there are two things you can do:

  1. Go to Settings > Miscellaneous in your Wordpress admin area and make sure that ‘Store uploads in this folder’ is set to the default: wp-content/uploads (notice there is no ‘/’ before wp-content/uploads).  Try to upload again and see if it works.
  2. If that didn’t work, open up a terminal and navigate to the wp-content directory.  If wp-content does not contain sub-directory called ‘uploads’, create one and then change its permissions to wide open (sudo chmod 777 uploads/). Try to upload the image again.  If this works, navigate to the wp-content/uploads/ directory and check the owner of the image you just uploaded (ls -l). It will probably be something weird you’ve never seen before (mine was ‘www-data’). Navigate up a directory and change the owner of the uploads folder to the one WordPress want to use: sudo chown www-data:www:data. Then revert the permissions back to something a little safer: sudo chmod 755 uploads/ and you’re done.
Posted in Musings | Leave a comment

Use your user’s public_html directory to serve webpages

Using a public_html file in your home directory is much more convenient than /var/www for a local website development environment. The following commands create a file called public_html in your home directory and enable the UserDir module in Apache.

From the command line, enter:

  • $ mkdir ~/public_html
  • $ cd /etc/apache2/mods-enabled
  • $ sudo ln -s ../mods-available/userdir.conf userdir.conf
  • $ sudo ln -s ../mods-available/userdir.load userdir.load
  • $ sudo service apache2 restart
Posted in Musings | Leave a comment

Ubuntu Karmic LAMP stack installation

In the terminal, type:

  • $ sudo apt-get install apache2
  • $ sudo apt-get install php5 libapache2-mod-php5 php5-mysql
  • $ sudo apt-get install mysql-server
  • $ sudo apt-get install phpmyadmin

Just agree when it asks you stuff.

Posted in Solutions, Ubuntu | Leave a comment