Pagination with Laravel and MySQLs FOUND_ROWS()

Laravel counts the total amount of rows that a paginator must use by re-issuing your query with a COUNT(*) statement instead. This is and should be the "default" way to do things, but in MySQL there's a more performance-efficient way via SQL_CALC_FOUND_ROWS and FOUND_ROWS().

I've created a small patch that hacks Laravel to use these functions which may increase performance for you depending on your use. They work with my version which is currently 4.0-dev (2aea469f0c49ede7994cc27f68fcdd658d4d15e2) from the 1st of September 2013. It will most likely break at some point in the future. Perhaps Taylor will add a way to implement this in a more clean way. Perhaps not.

foundrows_wheres.diff

Note: The patch also contains a fix for issue #2225

Clamshell Mode with open lid in Mountain Lion

Problem

Since Lion (10.7) it hasn't been possible to use your external display as the primary and have the internal laptop display shut off. This "feature" was removed in favor of the so-called "Clamshell mode" where Apple decided that the only way to turn off the internal screen should be to close the lid.

Notice: As of OS X update 10.8.3 (released 15th of March), this app no longer works. Any prior versions should work just fine.

Why would you need to open the lid, if it's off?

There are several reasons. Some of them are:

1) Performance. The GPU is burdened by 2 active screens when lid is open. Even if you are only using 1 of them.

2) Wi-fi signal. Worse when lid is closed.

3) Heat. Will overheat more (and fan will come on) and worsen the life of your computer when the lid is closed. Opening it greatly increases airflow.

4) Digitizer sensitivity. Digitizers cursor will span horizontally over 2 screens, but vertically over 1. It will become more sensitive to minute movements and cause you to drag  stuff when you meant to just click. (Personal issue)

How to fix it

Instructions are simple: Close the lid. Launch the program. Open the lid. Press escape.

Download now

(To re-activate the display, Close the lid. Wait 5 seconds. Open the lid.)

The source code is also open.

Video demo

ACME Whistle no. 212 sound test

Using Audacity I've recorded a few blows of the ACME 212 Field Trainer whistle.

Spectrum analysis

Conclusion

The strongest frequency is consistenly around 5,000 Hz. The output varies from how strong/soft you blow it, which is not entirely consistent with how ACME advertises it:

With consistent frequency no matter how
hard or soft you blow.

 

Oister.dk Data Usage, The Google Chrome extension

Recently I switched to carrier to Oister to get cheaper prices, but still get to use 3's network.

However, with cheaper prices often less functionality follows. In my case I've got a limit of 5 GB data usage per month which should be fine. But actually knowing how much data I use is still better but Oister doesn't provide the total usage amount, just how much you've used on each connection.

So I wrote a small Chrome Extension to counter this. Go to "Forbrug" and expand the "XXX gange Data" row. It will then show a green bar for each usage compared to your total use, and in the top it will display your total use, in megabytes.

Install now

Understanding Google, how to view your page

Search engines look at your document structure and text. The age of meta tags are gone, and meta description mostly ignored or rarely used.

Wouldn't it be nice, if you could actually see what the search engine sees? Well, you can.

(You need Firefox to see this – any version will do)

How to see

  1. Visit your target page or take a random pick, i.e. http://en.wikipedia.org/wiki/HTML
  2. In your browser menu, open View -> Page Style and choose No Style

(To undo, repeat the process, but choose "Basic Page Style")

What to look for

  • Look for headings, such as <h1> and look at the structure.
  • Does images appear right above/below the text they relate to?
  • Do headings correctly emphasize the section that comes below? Headings can be used for sections, so the engine knows what comes next. Use important and relevant keywords in the heading.
  • Does the structure of your menu appear clearly?
  • When you are listing something, does the lists appear correctly, indented with bullet points?
  • Does tables appear clean without specific layout? Headers would usually appear clearly in bold and regular table cells (table data) should appear without visual formatting.
  • Would your page be mostly functional without the stylesheet? Usually, it should be.

When you disable the stylesheets as described above, it means you will see how the document looks to the search engine*. Search engines ignore stylesheets, so this will give you an idea what they see.

* What you see is actually your browsers default stylesheet, but coincidently it emphasizes the important elements

A lession in stress

I'm writing an article on stress and how to handle it

I will be as concise as I can. I will iterate over the sections and cut away babbling. My aim is to provide a useful tool-set and some mental tips. The fewer words, the better.

I will however be needing some feedback. If you read it and feel I've missed something or that I am not clear enough throw me a note.

Also – I'll try to include some illustrations, so it won't be too boring :-)

Digital signatur i Safari med Mac

This article is only in danish and contain information that is specific to digital signatures in Denmark.

Problemstilling

Nogen gange kan det være svært at få resten af verden til at forstå, at Internet Explorer ikke er den eneste browser. TDC var en af de tungnemme, da de blev sat på opgaven. Mac brugere oplever ofte at få beskeden "Vi understøtter ikke Mac med digital signatur". Det er dog ikke helt sandheden, da de fleste offentlige institutter rent faktisk godtager det, hvis man installerer den korrekt. Som regel virker det, hvis den installeres i Firefox, men det er dog ikke altid. Installering i ens Keychain er desværre ikke nok til, at det fungerer i Safari.

Løsningen er dog enkel… Continue reading Digital signatur i Safari med Mac

jEdit makes major release for first time in 5 years

jedit128For the first time in over 5 years a major release will be made to jEdit! Alan Ezust has now committed a change that makes the next release version 4.3.0. With a new visual look, better platform support, many more features and much improved performance I can safely say that it's a great release and much welcomed!

When I discovered jEdit back in 2002/2003 I was happy to see that there was finally an editor that met all my weird needs and supported all the platforms I was using. I felt that my search for an editor was over… Continue reading jEdit makes major release for first time in 5 years