Archive for January, 2010
Bad Coders United
by z3n on Jan.31, 2010, under lol
Problem:
So I have this joint work where I do the frontend and another company does the backend and CRM integration of the system, I basically wrote a frontend and examples of all XMLs that backend should send to the system in order to have it working. After a week things were ready and i sent it to the backend team, and look how good they manipulate arrays:
$listai = str_replace(‘Ar’,” , $listai);
$listai = str_replace(‘Array’,” , $listai);
$listai = str_replace(‘ray’,” , $listai);
another example…
function datadma($dataz){
$dia = substr($dataz, -2);
$mess = substr($dataz, -5,2);
$ano = substr($dataz, -10,4);
return $dataz= $dia.”/”.$mess.”/”.$ano;
}
Oh man, wait, they DON’T KNOW what is an array!
How is that possible? Array is one of the first things a decent programmer is supposed to learn.
And the best, how is it possible for a company to build up a CRM system without the use of a single array? That’s like a coding challenge, specially when manipulating multiple fields and so on. And that’s not the only issue, after stating, in front of the client, that they weren’t able to work with jQuery + Ajax using XML (which they previously stated that could be worked without problems) they asked me to teach them … for free!!!!
ahahahah
Solution:
just sharing the story, there’s no solution for this :)
Reset jwysiwyg
by z3n on Jan.15, 2010, under Coding, Games and Gaming
Problem:
jquery’s extension jwysiwyg can’t be reseted on fly, calling the function again will just append another editor.
Solution:
You will need to do a workaround by adding the jwysiwyg object inside a container then resetting it using this little function:
-
function _reset_jwysiwyg(h,x,j){ // html, first id, second id
-
h=str_replace("\\","",h); // this requires php.js to work, can be removed if you don't add slashes on your vars
-
$("#cf"+x+""+j).html("<textarea id='#f"+x+""+j+"' class='jwysiwyg' name='jwysiwyg' cols=94 rows=30>"+h+"</textarea>");
-
$(".jwysiwyg").wysiwyg({
-
html: h
-
// you may want to add other control options here
-
});
-
}
this will work for this setup:
<span id=’c12′><textarea id=’f12′ class=’jwysiwyg’ name=’jwysiwyg’ cols=94 rows=30></textarea></span>
on this example it will be called as:
_reset_jwysiwyg(“”,1,2);
Note
this function is a snippet from my code, you might not want the identifiers just the div name, that makes it less complicated.
Symlinks on Windows
by z3n on Jan.12, 2010, under Uncategorized
Problem:
How to make a symlink or anything similar on windows?
Solution:
According to many sites, windows vista and newer has a built-in hability to do junctions (aka symlink on windows) due it’s new file system, but i don’t want all the gayness of vista, so i’m stuck on xp.
I found out that you can also do junctions on windows xp, although the manual method is not easy. But then i came across this post and found out that sysinternals has a tool to make things easy.
Neat huh?
In case you’re wondering, i’m using this “windows symlink” to freeup space on my o/s drive, since i made (long time ago) a setup with not so much space on that partittion and i don’t want to format, i just did a couple of symlinks to another drive, it worked flawlessly.
Using telnet to access pop3 (retrieve emails) and smtp (send emails)
by z3n on Jan.11, 2010, under Uncategorized
Problem:
How to test retrieve and send emails by raw telnet?
Solution:
Retrieving emails (bold lines are the commands, italics are outputs)
telnet mail.yourserver.com 110
Trying 1.2.3.4…
Connected to mail.yourserver.com.
Escape character is ‘^]’.
+OK Dovecot ready.
user your_email@yourserver.com
+OK
pass your_password
+OK Logged in.
list
+OK 1 messages:
1 1133
.
retr 1
message
.
quit
Sending emails:
telnet mail.youremailserver.com 25
Trying 1.2.3.4…
Connected to mail.youremailserver.com.
Escape character is ‘^]’.
220 youremailserver.com ESMTP Postfix
helo yourdomain.com
250 youremailserver.com
auth login
334 VXNlcm5hbWU6
eW91cmVtYWlsQHlvdXJkb21haW4uY29t (youremail@yourdomain.com base64 encoded)
334 UGFzc3dvcmQ6
eW91cnBhc3N3b3Jk (yourpassword base64 encoded)
235 2.0.0 Authentication successful
mail from:youremail@yourdomain.com
250 2.1.0 Ok
rcpt to: someone@somedomain.com
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
subject: test
hi
.
250 2.0.0 Ok: queued as 8B65ED40075
quit
Note that there’s many different authentication protocols, base64 is the less secure one, some servers may require a better authentication mechanism, or even use an ecrypted port, which will not work with telnet, try open ssl instead.
Port Scan on Linux
by z3n on Jan.11, 2010, under Uncategorized
Problem:
How to do a port scan on a specific ip/hostname on linux?
Solution:
nc -z <ip> <port-range>
eg.: nc -z 127.0.0.1 1-1024
Source: