Ok vediamo come fare:
Creiamo un file /etc/grub.d/11_windows come segue:
#!/bin/sh -e
echo "Found Windows XP" >&2
cat << EOF
menuentry "Window XP" {
drivemap (hd0) (hd1)
drivemap (hd1) (hd0)
set root=(hd1,1)
chainloader +1
}
EOF
Ricordate che in grub2 la mappatura degli HD e delle partizioni e` cambiata:
sda1 => hd0,1sda2 => hd0,2sdb1 => hd1,1sdc2 => hd2,2- …
Ora aggiorniamo il grub.cfg con il comando
sudo update-grub
Dovremmo vedere un output del genere:
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.38-10-generic
Found initrd image: /boot/initrd.img-2.6.38-10-generic
Found linux image: /boot/vmlinuz-2.6.38-8-generic
Found initrd image: /boot/initrd.img-2.6.38-8-generic
Found Windows XP
Found memtest86+ image: /boot/memtest86+.bin
done
Reboot e viaaa…
Copiate il seguente script in /etc/init.d/solr
#!/bin/sh
PATH=/opt/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=solr
DESC=apache-solr
VERSION=1.4.1
SOLR_PATH=/opt/solr-$VERSION
COMMAND=/usr/bin/java
OPTIONS="-Dsolr.solr.home=$SOLR_PATH/solr -Djetty.home=$SOLR_PATH -jar $SOLR_PATH/start.jar"
PIDFILE=/var/run/$NAME.pid
test -x $COMMAND || exit 0
test -f $SOLR_PATH/start.jar || exit 0
set -e
case "$1" in
start)
if [ -f $PIDFILE ]; then
echo "$PIDFILE exists. $NAME may be running."
else
echo -n "Starting $DESC: "
start-stop-daemon -b -p$PIDFILE -d$SOLR_PATH --start --quiet --exec $COMMAND -- $OPTIONS
sleep 3
echo `ps -ef | grep -v grep | grep "$COMMAND $OPTIONS" | awk '{print $2}'` > $PIDFILE
echo "$NAME."
fi
;;
stop)
if [ -f $PIDFILE ]; then
echo -n "Stopping $DESC: "
kill `cat $PIDFILE`
rm -f $PIDFILE
echo "$NAME."
else
echo "$PIDFILE does not exist. $NAME may be not running."
fi
;;
restart)
/etc/init.d/$NAME stop
sleep 1
/etc/init.d/$NAME start
;;
*)
echo "Usage: /etc/init.d/$NAME {start|stop|restart}" >&2
exit 1
;;
esac
exit 0
Goobalize3
Goobalize3 (Google + Globalize3) is useful to auto translate the attributes of your activerecord models.
If you have a model with some attributes translated with Globalize3 you can in easy way auto translate them via Google Translate.
Installation
As gem: put gem 'goobalize3' in your Gemfile
As plugin: run rails plugin install git@github.com:pioz/goobalize3.git
Requirements
- Globalize3
Usage
First of all, you need to create google_translate.yml configuration file in your config folder. Put
api : YOUR_GOOGLE_TRANSLATE_API_KEY
You can get api key at this link: https://code.google.com/apis/console/
Now, you can auto translate all globalized attributes of an activerecord object with
@post.translate
this translate the attributes from current set locale (I18n.locale) to all available locales (I18n.available_locales - I18n.locale).
You can set also the target locales
@post.translate(:it, :en, :de)
$!The exception information message set by ‘raise’.$@Array of backtrace of the last exception thrown.$&The string matched by the last successful match.- $` The string to the left of the last successful match.
$'The string to the right of the last successful match.$+The highest group matched by the last successful match.$1The Nth group of the last successful match. May be > 1.$~The information about the last match in the current scope.$=The flag for case insensitive, nil by default.$/The input record separator, newline by default.$\The output record separator for the print and IO#write. Default is nil.$,The output field separator for the print and Array#join.$;The default separator for String#split.$.The current input line number of the last file that was read.$<The virtual concatenation file of the files given on command line (or from $stdin if no files were given).$>The default output for print, printf. $stdout by default.$_The last input line of string by gets or readline.$0Contains the name of the script being executed. May be assignable.$*Command line arguments given for the script sans args.$$The process number of the Ruby running this script.$?The status of the last executed child process.$:Load path for scripts and binary modules by load or require.$"The array contains the module names loaded by require.$DEBUGThe status of the -d switch.$FILENAMECurrent input file from $<. Same as $<.filename.$LOAD_PATHThe alias to the $:.$stderrThe current standard error output.$stdinThe current standard input.$stdoutThe current standard output.$VERBOSEThe verbose flag, which is set by the -v switch.$-0The alias to $/.$-aTrue if option -a is set. Read-only variable.$-dThe alias to $DEBUG.$-FThe alias to $;.$-iIn in-place-edit mode, this variable holds the extension, otherwise nil.$-IThe alias to $:.$-lTrue if option -l is set. Read-only variable.$-pTrue if option -p is set. Read-only variable.$-vThe alias to $VERBOSE.$-wTrue if option -w is set.
E se volessimo usare Ruby come PHP? Senza Rails o qualche strano framework?
Vediamo come fare con Apache…
Per prima cosa installiamo Apache2
apt-get install apache2
Andiamo ad abilitare l’esecuzione dei CGI con i seguenti comandi:
a2enmod cgid
a2enmod actions
Modifichiamo il file /etc/apache2/sites-available/default e aggiungiamo:
<Directory /var/www/>
AddHandler rubypage .rhtml
Action rubypage /erb.cgi
AddHandler cgi-script .cgi
Options Indexes FollowSymLinks MultiViews ExecCGI
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Bene, ora riavviamo apache con /etc/init.d/apache2 restart.
Ora copiano il seguente codice nel file che creerete in /var/www/erb.cgi:
#!/usr/bin/ruby
require 'time'
require 'erb'
time = Time.now.httpdate
HEADERS = <<EOF
Date: #{ time }
Server: #{ ENV['SERVER_SOFTWARE'] }
Last-Modified: #{ time }
Content-Type: text/html
EOF
begin
path = nil
if (ENV['PATH_TRANSLATED'])
path = ENV['PATH_TRANSLATED']
else
file_path = ENV['REDIRECT_URL'].include?(File.basename(__FILE__)) ? ENV['SCRIPT_URL'] : ENV['REDIRECT_URL']
path = File.expand_path(ENV['DOCUMENT_ROOT'] + '/' + file_path)
raise "Attempt to access invalid path: #{path}" unless path.index(ENV['DOCUMENT_ROOT']) == 0
end
erb = File.open(path) { |f| ERB.new(f.read) }
print HEADERS + erb.result(binding)
rescue Exception
print "Content-Type: text/html\n\n"
# error message
print "<h1>Script Error</h1>"
print "<pre>#{ $! }</pre>"
# debug info
print "<h2>Backtrace</h2>"
print "<pre>#{$!.backtrace.join("\n")}</pre>"
print "<h2>Environment</h2>"
print "<pre>#{ENV.keys.map { |key| key + ' = ' + ENV[key] + "\n"} }</pre>"
print "<hr>"
print "<i>#{__FILE__} -- #{time}</i>"
end
Bene! Ricordiamo i permessi chmod 755 /var/www/erb.cgi
Infine creiamo il nostro file in Ruby (/var/www/test.rhtml):
<%= 'Hello World' %>
<strong>YEAH</strong>
Visitiamo http://localhost/test.rhtml