понедельник, 29 марта 2010 г.

rake db:backup

#= encoding: utf-8
namespace :db do desc "Backup the database to a file. Options: DIR=base_dir RAILS_ENV=production MAX=20"
task :backup => [:environment] do
datestamp = Time.now.strftime("%Y-%m-%d_%H-%M-%S")
base_path = ENV["DIR"] || "db"
backup_base = File.join(base_path, 'backup')
backup_folder = File.join(backup_base, datestamp)
backup_file = File.join(backup_folder, "#{RAILS_ENV}_dump.sql.gz")
db_config = ActiveRecord::Base.configurations[RAILS_ENV]
pass = ''
pass = '-p' + db_config['password'] if db_config['password']

sh "mysqldump -u #{db_config['username']} #{pass} #{db_config['database']} -Q --add-drop-table=true --add-locks=FALSE --lock-tables=FALSE | gzip -c > #{backup_file}"
dir = Dir.new(backup_base)
all_backups = dir.entries[2..-1].sort.reverse
puts "Created backup: #{backup_file}"
max_backups = (ENV["MAX"] || 20).to_i
unwanted_backups = all_backups[max_backups..-1] || []
for unwanted_backup in unwanted_backups
FileUtils.rm_rf(File.join(backup_base, unwanted_backup))
puts "deleted #{unwanted_backup}"
puts "Deleted #{unwanted_backups.length} backups, #{all_backups.length - unwanted_backups.length} backups available"
task :restore => [:environment] do
base_path = ENV["DIR"] || "db"
backup_base = File.join(base_path, 'backup')
dir = Dir.new(backup_base)
all_backups = dir.entries[2..-1].sort.reverse
last_backup_dir = File.join(backup_base,all_backups[0])
backup= File.join(last_backup_dir,"#{RAILS_ENV}_dump.sql.gz")
if File.exist?( backup)
puts "Restore #{backup}"
db_config = ActiveRecord::Base.configurations[RAILS_ENV]
pass = ''
pass = '-p' + db_config['password'] if db_config['password']

cmd_str="gunzip < #{backup} | mysql -u #{db_config['username']} #{pass} #{db_config['database']}"
puts cmd_str
puts "Backup file <#{backup}> not found"
оборудование для татуажа

понедельник, 22 марта 2010 г.

Autoplay DVD with VLC

Autoplay DVD with VLC

1) Create a script using Script Editor and paste the following:

activate application "VLC"
tell application "Finder" to set frontmost of process "VLC" to true
tell application "System Events" to click menu item "Open Disc..." of menu of menu bar item "File" of menu bar of process "VLC"
tell application "System Events" to tell process "VLC"
keystroke return
end tell
tell application "VLC"
end tell

2) Compile and Save
3) Open "System Preferences..." and select "CDs & DVD's".
4) Select "Run Script" for "When you insert a video DVD".
5) Browse to where you saved your new script, select it and click "Choose".

This will automatically play DVD using VLC.
If you are using a localized non-English version just replace the "Open Disc..." and "File" accordingly.

суббота, 20 марта 2010 г.

GetBundles для TextMate

ставим для управления всеми Bundle

mkdir -p ~/Library/Application\ Support/TextMate/Bundles
cd !$
svn co http://svn.textmate.org/trunk/Review/Bundles/GetBundles.tmbundle/
osascript -e 'tell app "TextMate" to reload bundles'

четверг, 18 марта 2010 г.

Делаем virtual hosts на Apache OS X Leopard

У меня работает так.

Шаг 1:
Правим файл /etc/apache2/httpd.conf в любом редакторе, удаляем комментарии # в строке:

#LoadModule vhost_alias_module libexec/httpd/mod_vhost_alias.so

и ставим коммент на

#LoadModule userdir_module libexec/apache2/mod_userdir.so
#LoadModule alias_module libexec/apache2/mod_alias.so

Шаг 2:
Ищем строку:
# Supplemental configuration

и отключаем
# Fancy directory listings
#Include /private/etc/apache2/extra/httpd-autoindex.conf
# User home directories
#Include /private/etc/apache2/extra/httpd-userdir.conf
# Local access to the Apache HTTP Server Manual
#Include /private/etc/apache2/extra/httpd-manual.conf
# Virtual hosts
#Include /private/etc/apache2/extra/httpd-vhosts.conf

Шаг 3:
добавляем строки после второго шага 2:

UseCanonicalName Off
VirtualDocumentRoot /Library/WebServer/Documents/%0
так настраиваем перенаправление для виртуальных хостов т.е. http://foo.homelinux.net -> /Library/WebServer/Documents/foo.homelinux.net/

Шаг 4:
Сохраняем файл и рестартуем апач (отключаем веб шаринг и включаем его снова).

Ну и наконец создаем необходимые директории для виртуальных хостов например для
foo.homelinux.net и bar.homelinux.net делаем следующие директории:


заливаем в них нужные файлы и все работает
если не работает смотрим вывод команды
apachectl -t
и правим httpd.conf

в дополнение я использую www.dyndns.org для своих хостов ( айпишник внешний но динамический)

Фортуна Моторс Хабаровск

среда, 3 марта 2010 г.

Asus p5k


CPULGA775 socket for Intel® Core™2 Quad / Core™2 Extreme / Core™2 Duo / Pentium® Extreme / Pentium® D / Pentium® 4 Processors
Compatible with Intel® 05B/05A/06 processors
Support Intel® next generation 45nm multi-core CPU
*This motherboard supports FSB 1333/1066/800
ChipsetIntel® P35 / ICH9 with Intel® Fast Memory Access Technology
Front Side Bus1333 / 1066 / 800 MHz
Memory4 x DIMM, max. 8GB, DDR2 1066*/800 / 667 MHz, non-ECC, un-buffered memory
Dual channel memory architecture
* The chipset officially supports the memory frequency up to DDR2 800MHz. Tuned by ASUS Super Memspeed Technology, this motherboard natively supports up to DDR2 1066MHz
Please refer to www.asus.com or user manual for Memory QVL.
Expansion Slots2 x PCI-E x16 (blue @ x16 mode, black @ x4 or x1 mode) supports CrossFire Technology
1 x PCI-E x1
3 x PCI
- 4 x SATA 3.0 Gb/s ports
JMicron® JMB363 PATA and SATA controller
- 1 x UltraDMA 133/100/66 for up to 2 PATA devices
- 1 x SATA 3.0 Gb/s ports
- 1 x External SATA 3.0 Gb/s port (SATA On-the-Go)
- Supports SATA RAID 0,1 and JBOD
LANPCIe Gb LAN controller featuring AI NET2
AudioRealtek ALC 883, 8-channel High-Definition Audio CODEC
- Support Jack-Sensing, Enumeration, Multi-streaming
- Coaxial S/PDIF out ports at back I/O
- ASUS Noise Filter
IEEE 1394VIA VT6308P controller supports 2 x IEEE 1394a ports (one at midboard; one at back panel)
USB12 x USB 2.0 ports (6 ports at mid-board, 6ports at back panel)
ASUS AI Lifestyle FeaturesASUS AI Lifestyle Features:
- ASUS AI Gear2
- ASUS Fanless Design: Heat-pipe solution
- ASUS Q-Fan 2
ASUS Crystal Sound:
- ASUS Noise Filter
- ASUS Q-Connector
- ASUS O.C. Profile
- ASUS CrashFree BIOS 3
- ASUS EZ Flash 2
- ASUS AI Slot Detector
Overclocking FeaturesIntelligent overclocking tools:
- AI NOS™ (Non-delay Overclocking System)
- ASUS AI Booster utility
Precision Tweaker:
- vCore: Adjustable CPU voltage at 0.0125V increment
- vDIMM: 16-step DRAM voltage control
- vChipset: 4-step Chipset voltage control
SFS (Stepless Frequency Selection):
- FSB tuning from 200MHz up to 800MHz at 1MHz increment
- Memory tunning from 667MHz up to 1333MHz for DDR2
- PCI Express frequency tuning from 100MHz up to150MHz at 1MHz increment
Overclocking Protection:
- ASUS C.P.R.(CPU Parameter Recall)
Other FeaturesASUS MyLogo 2
Back Panel I/O Ports1 x PS/2 Keyboard
1 x S/PDIF Out (Coaxial)
1 x External SATA
1 x IEEE1394a
1 x RJ45 port
6x USB 2.0/1.1
8-channel Audio I/O
Internal I/O Connectors3 x USB connectors support additional 6 USB ports
1 x Floppy disk drive connector
1 x IDE connector
1 x COM connector
5x SATA connectors
1 x CPU Fan connector
2x Chassis Fan connector
1 x Power Fan connector
1 x IEEE1394a connector
Front panel audio connector
1 x S/PDIF Out Header
Chassis Intrusion connector
CD audio in
24-pin ATX Power connector
1 x 4-pin ATX 12V Power connector
System Panel(Q-Connector)
BIOS8 Mb Flash ROM, AMI BIOS, PnP, DMI2.0, WfM2.0, SM BIOS 2.3, ACPI 2.0a, ASUS EZ Flash 2, ASUS CrashFree BIOS 3
Manageability WfM 2.0, DMI 2.0, WOL by PME, WOR by PME, PXE
AccessoriesUltraDMA 133/100/66 cable
FDD cable
2x Serial ATA cables
1 x 2-port Serial ATA power cable
I/O Shield
User's manual
3 in 1 Q-connector
Support CDDrivers
ASUS Update
Anti-virus software (OEM version)
Form FactorATX Form Factor, 12"x 9.6" (30.5cm x 24.4cm)
O/S CompatibilityWindows Vista/XP