Archive for October, 2008
Javascript Argument Handling
by admin on Oct.31, 2008, under Coding
Problem:
yourhappyhtml.html?argument=xxx
Solution:
function d(){var x=window.location.search.split(‘?’);if(isset(x[1])){setTimeout(“z(“+x[1]+”)”,200);}}
Explanation:
this will call a function z that will show a specific hidden div depending on the parameter sent, due random crappyness on onload function i added a timer as a workaround, to call this in a bare way you should do ?number , and nothing else, x[0] is always null, isset() is:
function isset(v) { return ((v == undefined) || (v == “”)) ? false : true; }
to send more than one argument you will need to split the “=” as well inside the x[1], since javascript will take the whole query as a variable.
Disabling Firewall on Fedora (Lame)
by admin on Oct.23, 2008, under Linux Happyness
Problem:
fedora is firewalled and only accepts ssh connections
Solution:
system-config-firewall-tui
Javascript to Replace Accent Chars
by admin on Oct.18, 2008, under Coding
Problem:
convert accent html encoded chars, like ç , to their real values in javascript
Solution:
var _chr=[];var _etn=[];for(var x=0;x<95;x++){_chr[x]=(x+161);_etn[x]="&#"+(x+161)+";";} // replacing all chars could be slow you would like to restrict it to only the accent chars or the ones that you like
function chr(x){return String.fromCharCode(x);} function e2c(s){for(var x=0;x<95;x++){var m=s.indexOf(_etn[x]);while(m!=-1){s=s.replace(_etn[x],chr(_chr[x]));m=s.indexOf(_etn[x]);}}return s;}
you can test by:
alert(e2c(“¡¡¡¡¢çç㤥¿”));
to do the reverse just change the order of the replace vars
note that javascript is lame and don’t have array replace and it will only replace a single char on the string (even if there’s more) so lots of loops had to be added to it, this might be a drawback if you use this too many times into a same page or into very large texts.
Javascript eval(return)
by admin on Oct.17, 2008, under Coding, Tips & Hints
Problem:
javascript:eval(“return 666″)
Solution:
No solution; do a workaround you idiot.
Zend and Fedora Issue
by admin on Oct.17, 2008, under Linux Happyness
Problem:
Failed loading /usr/local/Zend/lib/Optimizer-3.3.3/php-5.1.x/ZendOptimizer.so: /usr/local/Zend/lib/Optimizer-3.3.3/php-5.1.x/ZendOptimizer.so: cannot restore segment prot after reloc: Permission denied
Fix:
setenforce 0 (and restart httpd) and disable SELINUX here: /etc/selinux/config SELINUX=disabled to have this set next time you boot the machine.
apache (13) permission deined error
by admin on Oct.13, 2008, under Linux Happyness
Error:
[XXX] [crit] [client XXX] (13)Permission denied: /path/to/user/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
Solution:
chmod 777 /home/userfolder