Archive for October, 2009
Dark Skin for Firebug
by z3n on Oct.28, 2009, under Uncategorized
Problem:
Firebug skin is white, it’s annoying and it hurts my eyes.
Solution:
I edited myself a bunch of css files and build up a less annoying version, although there’s a lots of borders that still too light, it’s a real relief for me already.
You can download it here.
You should replace the files on the classic skin, they are located inside the document settings/your user/data something/mozilla/extensions/firebug/skin/
Search in files and count lines
by z3n on Oct.27, 2009, under Linux Happyness
Problem:
I wanted to know how many occurences of a string appears on a log file, by ssh.
Solution:
cat file.ext | grep search_string | wc -l
cat will print the whole file contents, grep will search for the string, wc -l will count the lines.
Search in files and replace by bash
by z3n on Oct.26, 2009, under Coding, Linux Happyness, Tips & Hints
Problem:
How to change a string on several files by bash without opening one by one.
Solution:
for i in $(find . -type f); do sed ’s/find/replace/g’ $i > $i-tmp; mv $i $i-backup; mv $i-tmp $i; done
Yes, it’s just a copy paste from the source, i don’t have time to explain each command.
Source:
Things you will forget when migrating to a new server
by z3n on Oct.26, 2009, under Linux Happyness
When migrating to a new server you will forget to:
- Check php session folder pemissions (/var/lib/php/session/ this folder must be writable)
- Do a DNS reverse setup, and will only notice when emails start to bounce.
- To configure dovecot you need to enable the protocols AND make sure it’s listening to internet as well (webmin configuration is ambiguous and bugged, you should edit the conf file manually)
- To add ALL old users BEFORE doing the file copy
- To add a trailing slash (/) when doing rsync file copy, which will generate /home/user/home/user/ instead of /home/user/
- To check server’s firewall before starting apache and wondering why nothing is working.
- When setting up a new nameserver, you always tend to ignore “.org, .net, .com only” which might cause lots of headaches later, when you realize that ns will not work, after changing 100 domains.
Linux USB 2.0 Issue
by z3n on Oct.07, 2009, under Linux Happyness, Tips & Hints
Problem:
Using high speed usb on linux is a problem. Even if the device supports USB 2.0 it works as 1.1.
Solution:
DO NOT use a USB hub, between your device and the computer.
This ALSO includes extension cables.
Some linux kernels got an issue only enabling one usb as 2.0
you may check if with lsusb, connecting one by one until you find the right port.
Disable Disk Low Space Check on Windows
by z3n on Oct.05, 2009, under Tips & Hints
Problem:
Annoying stupid windows low space disk check.
Solution:
Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer] "NoLowDiskSpaceChecks"=dword:00000001
VNC clipboard transfer / Windows clipboard issues
by z3n on Oct.02, 2009, under Linux Happyness, Tips & Hints
Problem:
Windows clipboard stop working from nothing;
Windows <=> VNC (unix) not working;
Using alternate copy/paste keys/methods (ctrl/shift + insert, ctrl+x/v/c) will not help;
Solution:
vncconfig must be open on vnc server client
vncviewer must be configurated to allow clipboard transfers
If you are using Xvnc the default options for the server is to allow clipboard transfers, although you might want to check your config file to make sure it’s right (check man page link below).
You can also install autocutsel to check the debug and make sure it’s working.
On windows you might fall into clipboard issues, cleaning the clipboard at `clipbrd.exe` might not resolve the issue, sometimes a program keeps the clipboard handler open, making impossible to write data. There’s a little this program that detects that. You may also get the source code for it at code project link below.
Fun:
During the research on this, someone suggested that windows clipboard is a service and that by restarting it you would fix the problem.
Sources:
ASP LCID
by z3n on Oct.02, 2009, under Coding, Tips & Hints
Problem:
Date format is wrong on asp.
Solution:
ASP’s LCID (location configuration) is wrong, depending on what is the regional configuration of the machine you’re running your asp into the date format might be different. Thanks to microsoft.
There’s a workaround for this by setting the Session.LCID at global.asa:
Sub Session_OnStart
Session.LCID = 1033
End Sub
Will set the region to English – United States (1033).
You can see a full list on the source I’ve found this information, here.
Full Story:
Datetime formats were wrong on the MSSQL database after the migration, after doing some research I’ve figured out that MSSQL has it’s own datetime format which also might vary depending on the specific windows regional configurations, to know what is the format the MSSQL is running you should query sp_configure ‘default langauge’, config_value column will return the code of the language which you can find by sp_helplanguage, it also has the default datetime format, which you can set on the specific instance by SET DATEFORMAT mdy.
Configuring Sendmail to Queue
by z3n on Oct.01, 2009, under Linux Happyness
Problem:
So you got a new client on your server who loves to spam, and not only that, he doesen’t know how to do it, and keeps sending over and over to the same people (10,000 emails). You can’t realay on your own server, cuz, surprise! Your noisy subnet neighboors been spamming and the major spam control systems, like spamhaus, thinks that the whole subnet is spamming and will not unblock you unless all your happy russian friends stop spamming, which will never happen.. so you need to relay on a obscure controlled server that your ISP provided you, which surprise! has a mailing limit.
Solution:
Anything related to sendmail tends to be complicated and obscure, although i found it easier to just configure it using webmin, i tend to do it also by editing the raw conf files.
To have the queue implemented you need:
- Set sendmail to work with `queue only` mode, which will NOT delivery messages automatically, it will place them on a queue so you can decide when to send.
- Set `maximum queue size` to how many emails you want to send on a batch (read below)
- Set a cron to send emails, in my case i’ve set a cron to send every minute a batch of 3 emails, so i configurated maximum queue size to 3 and installed a cron:
* * * * * /usr/sbin/sendmail -bd -qp1m
Note the 1m this should match your crontab repeat time.
So, if i send 3 emails every 1 minute, this will be 180 an hour or 4320 a day, being below my ISP limit and calming down the happy spammers.