Mind Mining Medium

November 09, 2011

Solving 'stdin: is not a tty' error

The “stdin: is not a tty” warning kept on popping up when ssh-ing to a few servers. I’ve learned that the problem is because I had mesg n on top of my .bash_rc file. Quick fix is to wrap it around an if statement, like so:

if `tty -s`; then
   mesg n
September 24, 2010

'Hello' spam clogging mailboxes

A new influx of spam is making its way around the internet in the form of a very simple “Hello” email and an attachment. Mainly they consist the subject “Hello” and an attachment. The attachment is just an HTML file with some ‘encrypted’ code in there. The file itself doesn’t contain any viruses.

I decrypted the code and it produced:

<meta http-equiv="refresh" content="0;url=http://BADURL.HERE" />
<table width="100%" border="0"><tr bgcolor="#556688" align="center"><td><a href="http://www.pullsoft.com/htmlpower.htm"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF" size="-1">This Web Page was protected by HTMLPower,  Click here to Register</font></a></td></tr></table>

Things that I found funny about this:

  • Gmail engineers haven’t been able to stop this. This could be because it’s not widespread yet.
  • Whoever created this spam wasn’t smart enough to encrypt their own code. They used a tool provided by Pullsoft
  • They used a meta refresh rather than a Javascript window.location=http://BADURL.HERE;. They are already assuming the target has Javascript turned on to decrypt their “code”.
December 18, 2009

Object Type in Javascript

Someone noted the interesting line that I use to find the object type.

function getType(obj){
    if (obj === undefined) { return 'undefined'; }
    if (obj === null) { return 'null'; }
    return Object.prototype.toString.call(obj).split(' ').pop().split(']').shift().toLowerCase();

Object.prototype.getType = function(){
    return Object.prototype.toString.call(this).split(' ').pop().split(']').shift().toLowerCase();

I posted the QUnit test suite. I’ve tested it in IE6-8, Safari 4, and Firefox 3.5.6. It would be greatly appreciated if you post your results.

While the typical method of using typeof or instanceof may produce results, they have their faults.

Douglas Crockford writes about type detection and his methods work for most cases, but not all.

On a side note, the reason why the Object.prototype.getType doesn’t check for undefined or null is because neither of those have properties, that is, they are not an Object. That said, they cannot call any functions.