{"id":1510,"date":"2009-01-15T00:13:31","date_gmt":"2009-01-15T04:13:31","guid":{"rendered":"http:\/\/blogs.n1zyy.com\/n1zyy\/?p=1510"},"modified":"2009-01-15T00:13:31","modified_gmt":"2009-01-15T04:13:31","slug":"code-for-users","status":"publish","type":"post","link":"https:\/\/blogs.n1zyy.com\/n1zyy\/2009\/01\/15\/code-for-users\/","title":{"rendered":"Code for Users"},"content":{"rendered":"<p>One thing that I always thought was neat, in a really strange way, is how users and coders see things totally differently.<\/p>\n<p>At work, we have some admin tools to manage users, but periodically, we&#8217;ll come across a spammer who&#8217;s just signed up. They have tools to stop them and delete their posts, but I&#8217;ll often go the extra mile and log into a MySQL replicant and do a &#8220;SELECT * FROM users WHERE ip LIKE &#8216;$spammers_ip&#8217;G&#8221;, and see if it turns up any other users. Sometimes it&#8217;ll unearth a bunch.<\/p>\n<p>The other thing I&#8217;ll do is something like, &#8220;SELECT username, signup_time, email, ip FROM users ORDER BY signup_time DESC LIMIT 20;&#8221; to view the most recent users, and re-run it every 30 seconds or so to keep an eye on who&#8217;s signing up. I have much better things to do than sit around watching this all day, but it&#8217;s useful when spammers do their periodic, &#8220;Register thousands of accounts at once&#8221; thing.<\/p>\n<p>So today I was doing this for one of the customer service people, and they asked, &#8220;Where is that tool? I can&#8217;t find it.&#8221;<\/p>\n<p>&#8220;Oh, I&#8217;m logged into the database&#8230; There&#8217;s no way for&#8211;actually, give me a few minutes.&#8221;<\/p>\n<p>I threw together a couple PHP scripts that basically do the above, and display it in a table. It&#8217;s the type of thing that might bore a Programming 101 student, and the only thought involved, really, was in trying to figure out why it was aborting with an error. (Hint: searching for &#8220;&#8221; doesn&#8217;t do what you expect it will. I must have looked at the bit of code 30 times trying to figure out what could possibly be wrong with the line, and then it suddenly dawned on me. I&#8217;m a giant idiot. The  is an escape character, effectively telling PHP to treat the next quote as a literal quote, not a closing quote on the string. This is something I know well: I&#8217;ll often do something like <tt>echo \"<a href=\"\">link<\/a>\"<\/tt>, using the exact functionality that tripped me up today. And yet I kept missing the error.)<\/p>\n<p>Anyway, that&#8217;s not my point. My point is that I&#8217;m consistently amazed at how the user&#8217;s view is so radically different than the programmers. From my perspective, I just wrapped a little PHP around one of the simplest SQL queries imaginable. Heck, much of the logic was copied-and-pasted from another script. But from the perspective of the people who will use this script, it&#8217;s an immensely helpful tool that fills a void that&#8217;s existed for quite some time.<\/p>\n<p>Of course, sometimes it&#8217;s the opposite way. Sometimes all the user wants is a report on newly-created groups, the username of the person that created them, and the number of members. That&#8217;s just a simple SQL query! Actually, I suppose it&#8217;ll take a join. No, wait, two joins&#8230; But do we actually store the number of members in a group? I wonder if I can do that with a subquery&#8230; Maybe this needs to be a script. You know what? This is way too complicated.<\/p>","protected":false},"excerpt":{"rendered":"<p>One thing that I always thought was neat, in a really strange way, is how users and coders see things totally differently. At work, we have some admin tools to manage users, but periodically, we&#8217;ll come across a spammer who&#8217;s &hellip; <a href=\"https:\/\/blogs.n1zyy.com\/n1zyy\/2009\/01\/15\/code-for-users\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1510","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/posts\/1510","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/comments?post=1510"}],"version-history":[{"count":0,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/posts\/1510\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/media?parent=1510"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/categories?post=1510"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/tags?post=1510"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}