-
-
Save j-manu/708629 to your computer and use it in GitHub Desktop.
tips & tricks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Delete large number of files: | |
ls|xargs -L 1000 rm | |
-- | |
Maintenace page for Rails | |
RewriteEngine on | |
RewriteCond %{DOCUMENT_ROOT}/../tmp/stop.txt -f | |
RewriteCond %{SCRIPT_FILENAME} !-f | |
RewriteCond %{SCRIPT_FILENAME} !503.html | |
RewriteRule ^.*$ /503.html [L] | |
-- | |
Mysql | |
Innodb by default stores all tables in one big file and continues to grow. To better handle growth | |
store tables in separate files. This setting will be applied only to databases *created* after the | |
setting has been applied. So backup the database, drop database, add the setting, restart mysql server | |
and import backup to apply it to existing database | |
[mysqld] | |
innodb_file_per_table | |
Also to reclaim space from unwanted tables do | |
truncate table table_name; optimize table table_name | |
-- | |
Apache X-Sendfile | |
https://tn123.org/mod_xsendfile/ | |
apxs2 -cia mod_xsendfile.c | |
in virtualhost definition | |
XSendFile on | |
XSendFilePath path | |
By default Xsendfile is off and the path includes document root and below. Define the path to include | |
the main directory of the rails app to server files stored in non public folders | |
Rails 2.3.x definition | |
send_file file_location, :filename => filename, :x_sendfile => ENV['RAILS_ENV'] == 'production' , | |
:type => 'application/pdf' | |
--- | |
lzma file | |
try | |
tar --lzma -xvf filename.tar.lzma | |
OR | |
unxz filename.lzma | |
-- | |
Emulating slow links | |
I have done two simple scripts to configure my firewall automatically. They will slow down the http port (80) to a crawl. I do not handle the SSL port for https traffic, but it’s easily achieved by duplicating the script content and adjusting the parameters. | |
Here are the scripts. The first one, that slows down everything: | |
#!/bin/sh | |
/sbin/ipfw add 100 pipe 1 ip from any 80 to any out | |
/sbin/ipfw add 200 pipe 2 ip from any 80 to any in | |
/sbin/ipfw pipe 1 config bw 128Kbit/s queue 64Kbytes delay 250ms | |
/sbin/ipfw pipe 2 config bw 128Kbit/s queue 64Kbytes delay 250ms | |
And the one that brings your network back to normally: | |
#!/bin/sh | |
/sbin/ipfw delete 100 | |
/sbin/ipfw delete 200 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment