Skip to content

Instantly share code, notes, and snippets.

@rgo
rgo / gist:113090
Created May 17, 2009 18:39
relative_url_root gotcha rails 2.3.x passenger
Problem: `load_missing_constant’: uninitialized constant ActionController::AbstractRequest (NameError)
Solution:
-ActionController::AbstractRequest.relative_url_root = "your_root"
+config.action_controller.relative_url_root = "your_root"
# More gotchas: http://giantrobots.thoughtbot.com/2009/4/15/rails-2-3-2-upgrade-gotchas
@rgo
rgo / photos_controller_test.rb
Created May 14, 2009 00:51
how to send a multipart post?
test "should create photo" do
assert_difference('Photo.count') do
post :create, :album_id => albums(:gallery_one_one).to_param, :photo => {:name => 'photo_fooooo', :description => 'bar', :image => fixture_file_upload('rails.png')}
end
assert_redirected_to admin_album_photos_path(assigns(:album))
end
@rgo
rgo / gist:110574
Created May 12, 2009 16:29
Apache config - Expires by type
ExpiresActive on
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
@rgo
rgo / gist:108039
Created May 7, 2009 10:15
wp-cron is having mod_security error 500
# Add this to every host running WP (either in Apache conf files - a recommended method - or in .htaccess):
<Files ~ "wp-cron\.php$">
<IfModule mod_security.c>
SecFilterEngine Off
</IfModule>
Order Deny,Allow
Deny from All
Allow from my.own.IP.address
</Files>
@rgo
rgo / gist:96968
Created April 17, 2009 10:55
; Enable username:[email protected] in Internet Explorer and Windows Explorer.
; Enable username:[email protected] in Internet Explorer and Windows Explorer.
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_HTTP_USERNAME_PASSWORD_DISABLE]
"iexplore.exe"=dword:00000000
"explorer.exe"=dword:00000000
@rgo
rgo / gist:86642
Created March 27, 2009 11:09
Restore table mysql
#!/bin/bash
# Restore table(table+data or only data) from mysqldump file
#
# NOTE: 'foo' is the table to restore and 'bar' next table in backup.
# Restore one table
zcat backup_20090316-0200.sql.gz | awk '/Table structure for table .foo./,/Table structure for table .bar./{print}' > output.sql
# Restore only data from one table
zcat backup_20090316-0200.sql.gz | awk '/Dumping data for table .foo./,/Table structure for table .bar./{print}' > output.sql
# MySQL gui tools hangs when select an schema
export DEBUG_DONT_SPAWN_FETCHES=1
/usr/bin/mysql-admin
@rgo
rgo / gist:83527
Created March 23, 2009 12:19
Connect to TS
# Connect to terminal server with license problems("without" delays)
rdesktop <ip> -n <random_name> -a 15 -z -P
@rgo
rgo / gist:82325
Created March 20, 2009 11:22
MySQL to CSV
# Mysql to csv
mysqldump -u XXX -p -t <table> --tab=tables --tables users --fields-enclosed-by=\" --fields-terminated-by=, --where="<where condition here[optional]"
@rgo
rgo / gist:76361
Created March 9, 2009 16:16
Rename multiples files with a regex.
# Rename multiples files with a regex.
# If filename are "*bazbar.txt" rename them to "*foobar.txt"
for f in *;do mv "$f" "${f/baz/foo}";done