Programming
Archived Posts from this Category
Archived Posts from this Category
If you’re as obsessed as I am about tracking some packages, you’ll get sick of typing in your tracking number and submitting the form over and over. But if you go to:
http://trkcnfrm1.smi.usps.com/PTSInternetWeb/InterLabelInquiry.do
it doesn’t work because the form used a POST method.
Well, on the previous page, the form input field was called strOrigTrackNum. Some sites let you post a form via the GET method, so let’s see if this works:
http://trkcnfrm1.smi.usps.com/PTSInternetWeb/InterLabelInquiry.do?strOrigTrackNum=[your tracking number]
Yup! Worked fine. Now you have a URL that you can bookmark to quickly track your shipment.
0 comments Thursday 30 Oct 2008 | jordan314 | Computers, Firefox, Programming, web
On most machines that I use PHPEclipse, I can control click on a method, function or include and open it immediately. F3 does the same thing. On my Eclipse installation in parallels, this doesn’t work. I’m not sure why – I followed the instructions here:
http://www.phpeclipse.de/tiki-index.php?page=ParserBuilder
and it still doesn’t work. I thought it was parallels acting up initially but now I think my Maven configuration is misconfigured and interfering with it, because I get errors building the workspace when I save files.
-edit
Yay, I fixed it by updating eclipse, maven, ajdt, and phpeclipse. FYI PHPeclipse’s new automatic site update URL seems to be here: http://phpeclipse.sourceforge.net/update/stable/1.2.x/
0 comments Friday 06 Jun 2008 | jordan314 | Computers, Eclipse, Programming
In my last post, I kept getting this error when I clicked Publish in wordpress:
Error 406, Not Acceptable. An appropriate representation of the requested resource /wp-admin/post.php could not be found on this server.
It turned out my host was running mod_security and there are certain phrases it won’t let you publish. It’s censorship, but I understand why they do it. I was talking about the most dangerous command you can run in unix:
sudo rm -rf
That’s what triggered it. I had to obfuscate the text in that entry and this one just to be able to post it. (View the source of this page to see what I mean).
If you’ve been able to post normally and suddenly you can’t and are getting this error, check for weird linux commands or files in your post that could be triggering this.
0 comments Tuesday 08 Jan 2008 | jordan314 | Computers, linux, Programming, security, solved, wordpress
I’m beginning to work with comet (an ajax-like technology that uses a single connection with multiple server pushes) and found this tutorial extremely helpful:
http://www.zeitoun.net/index.php?2007/06/22/46-how-to-implement-comet-with-php
However, I had to modify the code slightly to work with PHP 4, which doesn’t support json_encode. Instead I just returned the json array manually:
// return a json array
//$response = array();
//$response['msg'] = file_get_contents($filename);
//$response['timestamp'] = $currentmodif;
//echo json_encode($response);
echo "{&92;"msg&92;":&92;"" . file_get_contents($filename) . "&92;",&92;"timestamp&92;":" . $currentmodif . "}";
flush();
I don’t know enough french to navigate or comment on Zeitoun’s site so I thought I’d at least publish this here.
-edit-
Hmm, my code markup plugin seems to be deleting backslashes. I tried replacing them with &92; but they just look like &92;. So replace all &92;s above with \.
0 comments Monday 13 Aug 2007 | jordan314 | ajax, comet, Computers, PHP, Programming, solved, web
Hey, I have some questions that would help me work faster.
In SQLyog, or MYSQL in general, is there any way to quickly view the last, say, hundred rows of a table automatically? You know, without having to select count(*) from the table (which gives me 2469207), then make a select * … LIMIT 2469107, 100; ?
Also, in PHP Eclipse, I like how I can paste in an SQL statement into a string, then hit enter and have Eclipse add end and start quotes and an append operator (.) at the end of the line automatically, to make my SQL statement pretty.
My question is, when I’m debugging, a lot of times I have to put that statement back into SQLyog (or MySQL Query Browser, or whatever). Is there a way to have one of these programs *remove* those quotes for you?
edit
Note: One trick I’ve been seeing programmers do lately is open double quotes, paste in the SQL as a paragraph on a new line, make another line break, and then close the quotes with a semicolon to make the code block easily copy and pastable. The problem is that I’ve seen the SQL query blow up in PHP every once in a while when the SQL query starts with a new line. It happens erratically so I’m still trying to replicate it. Meanwhile this sqlyog product enhancement would be sweet.
end edit
To make this post worth reading, here are two eclipse tricks I recently found out about:
If you’re using CVS, and you go to Team > Show Annotation, and use QuickDiff, you can see line by line who last edited that line. This would be great for project managers or for getting help from fellow coders!
And to indent a bunch of code, you can highlight it all and hit tab to indent it more, or shift-tab to indent it less.
0 comments Tuesday 30 Jan 2007 | jordan314 | Computers, Eclipse, Programming, unsolved
I spent way too much time on this, trying all sorts of solutions, for how easy it finally was to solve. I want to list everything I tried though first so others having this same problem might find this post.
I have a new programming gig. I was assigned a bug where the application we’re using generated a SOAP fault if a user pasted content from a Word doc into a form. The SOAP call specified ISO-8559-1 as the character set that it uses, and Word evidentially uses another character set. I tried changing the call to UTF-8 but it didn’t help.
Using ord() in PHP to get the character numbers of the bad characters, I detected that the nasty characters included chr(145), chr(146), chr(147), chr(148), chr(133), chr(150), chr(151), chr(210), chr(211), chr(128), chr(153), chr(156), and chr(157). These are the stupid “smart” or “balanced” quotation marks, left and right single and double quotes, em dashes, en dashes, and elipses (three dots …) .
However, I was unable to find and replace these characters using a variety of methods. It turned out the encoding from Word was in Windows-1252, which is a multibyte encoding that str_replace isn’t going to find when using chr().
I tried mb_check_encoding but it didn’t work, possibly because it wasn’t supported on my server. I tried iconv() but it kept giving me “illegal character” and “cannot convert encoding” errors. Frustratingly, iconv did not honor the //TRANSLIT and //IGNORE flags as documented on php.net, which were supposed to convert or ignore the bad characters automatically.
I did find a preg_replace function on the comments of iconv on php.net that stopped the soap faults by converting all bad characters to question marks, but the question marks wouldn’t have satisfied the client, and on continuous re-edits the question marks doubled and tripled themselves.
Finally, I found the answer here:
http://www.webmasterworld.com/php/3151831.htm
(BTW, when did they open up the webmasterworld forums again? They’ve been locked for like a year. Sweet!)
It turns out if you add an accept-charset=”UTF-8″ flag in your input form tag, the browser will do all the character conversions for you automatically before it even reaches the PHP, SOAP or Java. Even though my SOAP call was in ISO-8559-1, UTF-8 passes through fine and all of the weird word gremlins remain unchanged.
—– ©®™…‘’“”
Sweet!
0 comments Monday 27 Nov 2006 | jordan314 | Computers, PHP, Programming, solved
-Update
I was able to fix this using this command in terminal:
apachectl configtest
This allowed me to test my config files and diagnose what was wrong with them.
-Original Post-
I have lots of cool web content served via Apache on my mac running tiger. I run a test server environment, MAMP, and a production server using tiger’s personal web sharing and entropy (a php server for os x). They used to run fine together, each on different ports, but now MAMP’s apache is always on (can’t shut it off via mamp’s app, and apache is already started on program launch), and
when I click “start” for personal web sharing in system preferences > sharing, it spins and spins as if it’s trying to start but remains grey and never becomes highlighted.
My HD is corrupted I think, spotlight has stopped functioning and mail’s search is malfunctioning. Still, I think the machine has somehow confused the two apaches, when I run sudo apachectl start (thanks to a ‘web sharing won’t start up’ thread here)I get an ‘httpd (pid 219) already running’ error.
Anyone’s help is appreciated while I deal with applecare’s worsened support hours.
0 comments Tuesday 19 Sep 2006 | jordan314 | Computers, Programming, solved, web
I will be posting a lot of bbedit / textwrangler tips in here. Some may be obvious, others may be not.
I was looking for a way in textwrangler to indent a section of code without having to individually hit the tab key for each line.
The answer is simple: Highlight the block of code you want, then hit command ] to indent right or command [ to indent left. (Undent?)
The equivalent menu commands are text > shift right and shift left.
I love you textwrangler!
0 comments Wednesday 31 May 2006 | jordan314 | Computers, OS X, Programming, solved