function createARB($refId, $name, $length, $unit, $startDate, $totalOccurrences, $trialOccurrences, $amount, $trialAmount, $cardNumber, $expirationDate, $firstName, $lastName,$loginname, $transactionkey, $host,$path,$address,$city,$state,$zip,$country,$phone,$email,$address2,$city2,$state2,$zip2,$country2) {
^^^ THAT ^^^ has a bigger brother:
function fetchRequestString($login, $password, $trans_id, $x_first_name, $x_last_name, $x_address, $x_city, $x_state, $x_zip, $x_country, $x_phone, $x_email, $x_Amount, $x_card_num, $x_card_code, $x_exp_date, $desc, $merchantEmail, $transKey,$x_invoice_num,$x_ship_to_first_name,$x_ship_to_last_name,$x_ship_to_address,$x_ship_to_city,$x_ship_to_state,$x_ship_to_zip,$x_ship_to_country, $x_tax, $x_freight,$x_line_items = false){
You know, modern languages can pass in structured data, right? We don't have to push things on to the stack like we did in 1965; you know this, right?
Sunday, January 16, 2011
USPS API is horrible
Garbage Names
On January 2nd, USPS changed shipment option names from things like
First Class Mail International Package
to
First-Class Mail<sup>&reg;</sup> International Package**
This is not a bug. This is what USPS intentionally wants to use going forward.
The solution suggested to fix the apis that break on this is to do something like "strip <sup>&reg;</sup> and the **".
That is to say, that programmers should now put in a data sanitizer because USPS has decided to supply a bunch of garbage tags in their latest API. The recommended solution is to drop the new garbage.
Let me take some time and try to figure out how this could have ever possibly went down:
In December there was a board meeting:
Manager: Our brand name needs to be protected. Are we putting a ® everywhere that our brand "First-Class Mail" appears?
Programmer: Well, not exactly. Our programmer facing API...
Manager (interrupts): I've heard enough. When should we do this? Now, or after we fire you?
Programmer: B..but, this will break everything!
Manager: Well then, we will find someone that will respect our brand.
Programmer (under her breath): Holy fuck...
Programmer: Alright ... no problem sir. We'll have to send an email out.
Manager: The email has already been sent. We can't send out a second.
Programmer: Again, this will break everything, internatio...
Manager (interrupts): One email only. It's already been sent. People will adapt.
Programmer: Let's at least update our documentation by that week.
Manager: The documentation server are due for a scheduled downtime that week. We can't change this - the policy has been set. (yes, they went down that week)
Really odd requirements
Ordering of things that probably ought to not matter, really do for USPS. For instance, This is correct:
<Length>12</Length>
<Height>8</Height>
This is wrong:
<Height>8</Height>
<Length>12</Length>
You have to do Width, then Length, then Height ... and only in that order. Similarly, you have to do Pounds, then Ounces, then Machinable, then MailType, then GXG, then ValueOfContents (mind the case), then Country, then Container, then Size, ... etc... in this order, and only this order.
And when it says it's optional on the documentation, don't count on it. It's required.
Here's how this may have happened, maybe.
Programmer: Let's use XML for our API.
Manager: What if someone specified Ounces first, then Pounds, instead of Pounds then Ounces?
Programmer: The keys are unique, that ordering will not be a problem.
Manager: What if it was a mistake?
Programmer: XML shouldn't care. The siblings orders should be interchangeable in the case of Key/Value assignment like this.
Manager: There should be only one correct way?
Programmer: We would have to go way out of our way to make this.
Manager: We pay you well, right?
Programmer: Ok Ok, let's at least state this in our documentation.
Manager: What? That there is only one correct way? Isn't this assumed? You are a programmer right? Aren't computers supposed to be this pedantic?
Programmer: Yeah well ...
Manager: We pay you well, don't worry about it.
Horrid Documentation
And why on earth does http://www.usps.com/webtools/htm/Rate-Calculators-v1-2a.htm take sooo damned long to load?
A peak at the source reveals:
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 11">
Yes. They write there technical APIs in Microsoft Word and then just save them as HTML and post them directly to the site. Genius. At least we can scrape a few things:
<o:Subject>Web Tools API Reference</o:Subject>
<o:Author>john.f.johnson@hp.</o:Author>
...
<o:LastAuthor>Amanda Loser</o:LastAuthor>
...
<o:_AuthorEmail dt:dt="string">Sherry.McNeill@hp.com</o:_AuthorEmail>
<o:_AuthorEmailDisplayName dt:dt="string">McNeill, Sherry</o:_AuthorEmailDisplayName>
My first tone of complaint will be the fact that they don't talk about the changes, although they seem to suggest there has been some. You see stuff like this in there example code:
First-Class Mail Interna<!--127 suppressed-->)
So their example code, isn't actually an example; it's a neutered copy and paste that doesn't actually illustrate a full exchange. It fails to serve its most fundamental purpose; which is to illustratively show what one means.
Tuesday, December 14, 2010
Horrible CSS
This is wrong.
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
Here is what a good piece of CSS would look like
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
And you don't have to add an additional id tag to reference the section semantically. The principle here is simple:
<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!
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.
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:
Not only are their 14 versions of that file, but their are 5 separate conventions for assigning dates. Truly remarkable.
++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
- Know what you are doing and do it
- 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.
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!
Good questions.
Let's back up
It's so much easier the new way, right?
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?
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
- # touch /usr/local/apache/htdocs/index.html
- Point your web browser to http://ip/
The new way, clearly easier
- Point web browser to http://ip_address/whm
- Log in
- Click on the 14th icon, "Account Functions" between "Account Information" and "Multi-Account Functions"
- Click on the 2nd icon, "Create a New Account"
- For the domain, give it the eventual domain you'd like to use
- Enter a Username
- Enter a Password
- Retype the Password
- Enter in an email and scroll down to the bottom
- Click Create
- SSH to the ip address using the new username/password pair
- Run touch public_html/index.html
- 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.
- 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
- Save the file
- Restart your web browser to clear out your dns cache
- 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?
Subscribe to:
Posts (Atom)