Tuesday, December 14, 2010

Horrible CSS

This is wrong.

<div class="wid200 text_right border_top pad3">
<div class="clear">
...

Basically, authoring CSS like this is the same way people authored HTML before stylesheets. You are explicitly itemizing style hierarchically and ignoring encapsulation and the semantic bridge that CSS is meant to provide. If you prefer to code like this, You should probably actually write like this

<big>
<big>
<br> <br> <br> <br>
<font color=red>
<strong>
Markup like this, in circa 1996 style --- because when you are explicit
with every style declaration, you are doing the Exact Same
Thing.
</strong>
</font>
and I wrote code like this, it was the mid 90s ... I used Navigator 3.04 gold,
and connected to the internet via 14400 bps. We've moved one.
</big>
If you ever profess that you do "MVC" and then code like this, you are
just using buzzwords and totally mistaken. End of story.
</big>


Here is what a good piece of CSS would look like
<span class="profile cta container">
<button onclick=dosomething()>Something</button>


The Most Important Thing here is to notice that the class does not dictate a layout or a style - it dictates a higher level, encapsulated, semantic meaning for the content. If you want consistency in layout, design, and theme; this is what it should look like. Then when you do your JS coding, using your fancy jquery, you do

$(".profile .cta button")

And you don't have to add an additional id tag to reference the section semantically. The principle here is simple:

De-couple, but do not de-correlate

Sunday, December 5, 2010

Enterprise Database is

Using a number in a state column that corresponds to a 5 field state table, that is cross referenced to a country table that has 8 fields so that you have to 3 table joins in order to get from "20183" to "CA". Here? you want the billing address I know how to do that!

select users.FirstName || ' ' || users.LastName,
Ship.AddressLine1, Ship.AddressLine2,
Country.State, State.PostalRegion, Country.name from
users as users
join ShippingAddress as Ship on users.ID = Ship.UserID
join State as state on Ship.StateCode = state.stateID
join Country as country on state.countryId = Country.code
where users.ID = '101';

That was so easy and totally necessary. You know things are done Right when a 12-core machine takes 15 seconds to produce a page full of addresses; cause that's how long it took in 1975; when a kilobyte of memory set you back $10,000.

Tuesday, October 19, 2010

What's revision control?

This is the css directory for one of my clients, just for one file:

++main.css
__main.css
main-17-october.css
main-1st-nov.css
main-23rdfeb.css
main-3-8-9.css
main-bk1.css
main-extra.css
main.css
main.css.bk
main14April2009.css
main15April2009.css
main_bk.css
main_old.css
main.css.bak

Not only are their 14 versions of that file, but their are 5 separate conventions for assigning dates. Truly remarkable.

Horrible Javascript Code

      var class_schedules_text = '';
class_schedules.each(function() {
class_schedules_text = class_schedules_text + $(this).html();
});
parts = class_schedules_text.split('</strong>');
class_schedules_text = parts[1];
class_schedules_text = '<div style="width: 280px; margin-bottom: 10px; float: left; margin-left:
5px;font-size: 12px;">'+class_schedules_text+'</div>';

What it was replaced with

var class_schedules_text = class_schedules.html().replace(/<[^b].*?>/g,'');

Remember, there are two ways of doing layout

  1. Know what you are doing and do it
  2. Use excessive markup to eventually coerce the elements into place


For instance,

box_content += "<p><div style='overflow: auto;'>
<label style='float: left; margin-right:3px;font
-size: 12px;'>Schedule:</label><ul style='margin
:0; padding:0; float: left; font-size:12px;'>"+c
lass_schedules_text+"</ul></div></p>";

Becomes:

box_content += "<p>"+class_schedules_text+"</p>";

Monday, October 18, 2010

Stupidity example: Whm

So you have this things "WHM" installed. It looks like the default apache page. All you need to do is put things into /usr/local/apache/htdocs/ and you are done right? Override the default script and that's that.

NO, Bitch, You Are Wrong


If you do this, then you will get a bunch of errors; apache is looking for sys_cpanel or something somewhere. It will not actually feed the index.php file. It will feed a subdirectory and it's content listings. So if you wanted to look at /usr/local/apache/htdocs/mydocs, you will see the contents of the directory, but as soon as you click
on a single file, KABOOM!

How the fuck do you make it work then?


Good questions.

Let's back up

The old way, clearly too difficult



  1. # touch /usr/local/apache/htdocs/index.html
  2. Point your web browser to http://ip/


The new way, clearly easier



  1. Point web browser to http://ip_address/whm
  2. Log in
  3. Click on the 14th icon, "Account Functions" between "Account Information" and "Multi-Account Functions"
  4. Click on the 2nd icon, "Create a New Account"
  5. For the domain, give it the eventual domain you'd like to use
  6. Enter a Username
  7. Enter a Password
  8. Retype the Password
  9. Enter in an email and scroll down to the bottom
  10. Click Create
  11. SSH to the ip address using the new username/password pair
  12. Run touch public_html/index.html
  13. Go to the machine you need to access it on and open up your etc/hosts file. On Windows its c:\%WINDOWS%\system32\etc\hosts, on MacOS and Linux is /etc/hosts.
  14. Add the domain name you used in the above step and the ip address. This is a temporary mapping so that you can see the empty file
  15. Save the file
  16. Restart your web browser to clear out your dns cache
  17. Enter in the domain you used above


It's so much easier the new way, right?

How did you figure this out?


It took days. Literally. Who would have thought that you needed to create an account through WHM in order to view a php file on the web server? What kind of stupid is this?

Fuck Cpanel

Is it really excessively hard to learn how your website stack works? Really? Do you realize that all the complexities of the site are just presented to you in different packaging through Cpanel? It doesn't actually make things easier, all it does is rephrase the same shit in a new way.

While, at the same time, overriding all of the traditional ways of doing things.

If you have the slightest idea what you are doing, this bludgeoning piece of crap software will just randomly regenerate its wrong and broken configuration files over the ones that you manually configured.

Furthermore, they insist on protecting me for some reason and requiring me to do things there way ... instead of doing things the way that has worked since about 1992 - no that wasn't good enough; finding a file through locate, and editing it directly just was way too difficult. Now we need 5 levels of colorful icons amongst a collection of 140 and I have to remember "Services Panel" > "Web Services Panel" > "Web Server Configuration" > "Permissions for Web Server" or whatever the fuck they have decided to come up with.

It's called "httpd.conf" it's in the /usr/local/etc directory or the /etc directory. It's under the apache config, I use vim to edit it, just like I did in 2005, 2000, and 1995. Why must you insist on splicing the file into a spewed out mess of 85 different menu options.

Why?



Because the old way didn't use a fucking mouse. That's why. It wasn't user friendly enough, I'm guessing because it didn't look like the Windows Explorer shell - the epitome of ease of use, of course.

Now I need to find this shit that accesses that single fucking line of the file, and still type in the same damn configuration directives as if I was editing it manually in vim; but now it's through a web app; That's Progress!

I still actually have to have the knowledge of what to change to what; but now I need to know a bunch of additional information so that Cpanel won't overwrite it next time it decides to regenerate all the files from some stupid innocuous command, like an apache restart.

What files does Cpanel like to rewrite?

Who the fuck knows! Really. I don't know at all. I'm thinking that the entire /etc directory is becoming a black box where I would need to start up KDE4 on tightvnc in order to edit like, /etc/hosts in a way that won't get reverted every 5 minutes. If I knew any better, I'd know that I'd have to go into 6 configuration files and rewrite a bunch of Python and XML to disable it, along with running a bunch of distribution specific command line tools. Because you know, putting 4 layers of abstraction on a key/value pair text file is totally awesome; and people are totally capable of modifying the value of two input boxes, but are totally incapable of modifying the value of a single line of a file.

This shit is totally moronic. What is wrong with people?

I see where you are going. But what, pray tell, does Cpanel actually do?


That's easy!

All it does is that it takes a previously rather straight-forward Layout and piles shitpile after shitpile on it to create this crazy obfuscated interface where the obvious and important things are littered 4 menus deep and strewn about like some fucking 12 year old with ADHD and Photoshop decided to start making webpages last tuesday and then jizzed out some sorry excuse for a piece of software and called it Cpanel.

It takes very straightforward technical models and tosses them out the window, instead opting for some exponentially more complex "natural model" which is actually still a model, thus an abstraction, thus providing a barrier to entry, thus requiring a learning curve, and thus being counterproductive and extraordinarily detrimental to the intended purpose of further trying to simplify an already simple task.

Oh I see, what should I learn from this triage?


When webdevs get the rapt as being the stupidest, densest, dumbest programmers in the industry, I can clearly and emphatically agree when they turn to, and speak anything but with the most vile of contempt for this awful veneer that just smears and blurs otherwise obvious, straightforward processes.

For the love of God, if you want to be a programmer, learn to use a fucking computer.


For a more detailed example of this type of mentality, check out this posting on WHM
---

Tuesday, May 4, 2010

Javascript CSV Viewer

I had a csv file, you know, the typical... but I didn't have a viewer installed. I wanted something straight forward. I ended up using google docs but really, I was looking for copy and paste, something that would easily facilitate CSV files

Thursday, April 22, 2010

Image Fading in linux

Please look here: fade.html. I'm going to move away from this horrible platform soon.

Wednesday, April 21, 2010

CPAN


I like CPAN. Do you like it?
Would you like to answer now? [yes]
Is your answer in English? [yes]
Is your answer in ASCII? [yes]
Does UTF-8 look right to you? [yes]
Would you like to answer via keyboard input? [yes]
Would you like to continue? [yes]
Checking if you have a computer ...... ok
Checking if it is running ............ ok
Checking if it is done booting ....... ok
Checking if operating system loaded .. ok
Checking if perl is installed ........ ok
...
Error: terminal type "Linux" unknown. Aborting.
cpan>

Saturday, March 27, 2010

Apophnia, an image server

So I was presented with a problem like this:
Hiya, I have a bazillion images and I want to um you know like:
  • Be able to use new resolutions on the fly
  • Have these dynamically created images cached
  • Incur almost zero overhead in the process
  • Have a dedicated image web server or a web server module to do it ... images are important

Basically, given file /myimage.jpg I want to do say, /myimage_500x500.jpg and then say,
  1. Look for myimage_500x500.jpg.
  2. If not found, back up, try myimage.jpg
  3. See that (_500x500) is a resize directive
  4. Dynamically resize myimage.jpg to 500x500, serve that image
  5. Save a new file to disk myimage_500x500.jpg so that when it is requested again ... it's easy

Oh, and I want some other things
  1. When the image is resized the first time, I want it to be the fastest algorithm possible so that the user sees the resized image with minimal delay.
  2. But I also want a different, slow, high quality algorithm to run to save it to disk

One more thing, if it's not too hard
I want to specify things like this:
"medium": {
"resize": [1024,1024],
"quality": 50,
"cropwhitespace": true
}
so I can do something stupid like request /myimage_medium.jpg

If only this existed! [ Download it here ]

Current implementation details

  • Written in C.
  • Uses Mongoose as a webserver
  • Uses Imagemagick for sizing
  • Doesn't actually do *everything* above yet, but that is the goal.

Wednesday, February 24, 2010

Youtube music searcher

http://qaa.ath.cx/music.html

Try to copy and paste a list like...
+Run DMC - Peter Piper 
Salt N' Pepa - Push It
Slick Rick - A Children’s Story
Sugarhill Gang - Rapper’s Delight
Sugarhill Gang - Apache
Tone Loc - Funky Cold Medina
Treacherous Three - Feel The Heart Beat
Trouble Funk - Pump Me Up
Ultramagnetic MC's - Ego Trippin'
West Street Mob - Breakdance Electric Boogie
Whodini - Freaks Come Out At Night
Whodini - Friends

Friday, January 8, 2010

Online Porter Stemmer

I was looking for an online version of the Porter Stemming algorithm. I couldn't find one, and then realized that I am the person most recently credited with the official JS version here: http://tartarus.org/~martin/PorterStemmer/

So I guess then, it's my responsibility to make a demo: http://qaa.ath.cx/porter_js_demo.html

There it is.

Followers