Mar 15 2010

Pure PHP Pagination

So, for a while I’ve been looking for a ridiculously simple way to paginate data stored in a table. And while I love PHP, it just doesn’t come with some of the free things I take for granted in .Net

Today, while working on a pretty simple plugin, I wanted to add this functionality, and I didn’t want to waste a bunch of time. I was given a link to this great script:

It took me about a minute to implement the functionality. I then spent another 5 minutes doing CSS and that was it. Done. I’m not usually one for link sharing, but this made my life much easier. Hopefully it can make yours easier too.

The solution is pure PHP, no javascript required. Some day, I may try to expand upon this to include javascripty goodness, because that’s pretty much the only thing that could make it better

Mar 5 2010

ASP.Net 301 Redirect

<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
Response.Status = "301 Moved Permanently";

Jan 20 2010

mysql command doesn’t work in OS X snow leopard

So you install mySql on your mac, and it’s working great, but then you go into terminal to run a mysqldump or something, and it doesn’t work!

you get a message something like:

-bash: mysqldump: command not found

so how do you fix this? well, copy and paste the following into your terminal window and press enter:

echo export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH" >> ~/.profile

source ~/.profile

whoa, whoa, you say. what is this doing? It makes it so that when you type any command into the terminal, it does a check of these folders before giving you the “command not found” error.

If you want to undo it, you can always edit your .profile, or just delete it.

Jan 12 2010

WordPress on Snow Leopard: Unable to Connect to Database

If an “unable to connect to database” comes up while installing WordPress on a Snow Leopard machine, try adding :3306 to the end of the DB_HOST in wp-config.php

Assuming everything else works, this should solve your problem!

Jan 11 2010

Run JavaScript function every n seconds

//tell javascript to run a function in 1 second
setTimeout ("myFunction()", 1000 );

function myFunction(){
//do stuff

//once the function is finished, queue this function up to run again in 1 second
setTimeout ( "myFunction()", 1000 );

Oct 30 2009

New Car

Got a new 2010 Toyota Corolla! It is awesome.

Sep 12 2009

Get latitude and longitude of an address using google maps

Google doesn’t make it easy to show you the latitude and longitude of an address you search in google maps, but there’s an easy way to get the info.

  1. go to google maps, type the address, and click search
  2. once you’ve found it, go to your address bar and clear what’s in it
  3. paste: javascript:void(prompt('',gApplication.getMap().getCenter())); into the address bar
  4. use the coordinates for whatever you wish!

Aug 18 2009


Screen shot 2009-08-18 at 3.15.51 PM

Aug 13 2009

VirtualHostX and mod_rewrite

To enable mod_rewrite manually, see: OS X server tips but if you are using VirtualHostX it changes your default config file. Add the following code to the Directives box:

Options FollowSymLinks
AllowOverride All AuthConfig
Order deny,allow
Deny from all

if you’re using the new version of VirtualHostX, make sure that you select Directory from the dropdown, then use:

Options FollowSymLinks
AllowOverride All AuthConfig

Jul 8 2009

Embedding Web Fonts: A cautionary tale

So for work, the designer says “Hey, can we use this font in the webpage” and like an idiot, I say “sure, why not?”. Well, FF and Safari don’t support .otf files (for whatever reason) So I download FontForge, open it in X11 (on my mac) and convert it to .ttf, which works great.

Then I messed around in IE, trying to make it work, even downloading this tool:

Microsoft WEFT

Worst thing EVER. Don’t do this. Don’t get this. Don’t even look at this. You will feel violated if you use it.

So…how to embed an OTF font in a website (make sure you have a license to do so kids):

  1. Convert OTF file to .ttf (use fontForge)
  2. Embed with @font-face
  3. When adding the font to a style, in IE you CAN NOT call it by the name you gave it with the @font-face declaration. You have to call it by it’s name. So if the font’s name is myfontLTSTDBOLDITALICROMAN you have to do: body{ font-family: myfontLTSTDBOLDITALICROMAN; } Sucky? Very. Works? yes.

Have a nice day