Back up:
mysqldump -u myuser -p mydb > dump.sql
Restore:
mysql -u myuser -p mydb < dump.sql
Back up:
mysqldump -u myuser -p mydb > dump.sql
Restore:
mysql -u myuser -p mydb < dump.sql
mysql -u root -p
mysql> create database dbname default character set utf8;
mysql> grant usage on *.* to dbuser@localhost identified by 'userpass';
mysql> grant all privileges on dbname.* to dbuser@userpass ;
mysql -u dbuser -p'userpass' dbname
I like Texmate to show all the hidden folders and files, except .DS_Store and .Thumbs.db.
Open Preferences->Advanced->Folder References
Empty Folder pattern and put in File pattern: !(.DS_Store|Thumbs.db)
Create /usr/local/bin/mategem with:
Make it executable:
chmod +x /usr/local/bin/mategem
To autocomplete with tab add this to ~/.profile:
Reload:
source ~/.profile
Now to list all gems:
mategem [tab][tab]
control+shift+w: wrap text with tag
control+sift+command+w: wrap each line with tag
control+shift+l: wrap text with link to clipboard’s url
command+/: comment
control+shift+.: open erb code
command+control+t: select bundle window
command+shift+t: go to symbol window
command+shift+l: select line
control+shift+d: duplicate line
command+control+up/down: move line
command+alt+right/left: change tab
def+tab: function
cla+tab: class
tc+tab: test case
ase+tab: assert equal
If you are working in a bit big project and you try to Find in Project with Textmate, probably it’ll get frozen. The grep in project command is much more effective. Download it and double click on it. It replaces the Command+Shift+F default. More info.
In one of my last projects I had the opportunity to try Haml and Sass. I’m quite happy with it: the code is neat and clear, forcing the developers to maintain it correctly nested (something less usual as it should be), plus some other advantages like the CSS variables or output styles.
To highlight properly in Textmate install the Bundles:
cd ~/Library/Application\ Support/TextMate/Bundles
svn co "http://macromates.com/svn/Bundles/trunk/Bundles/Ruby Haml.tmbundle"
svn co "http://macromates.com/svn/Bundles/trunk/Review/Bundles/Ruby Sass.tmbundle"
Reload bundles (Bundles->Bundle Editor->Reload Bundles)
cd ~/Library/Application\ Support/TextMate/Bundles
git clone git://gitorious.org/git-tmbundle/mainline.git Git.tmbundle
In the TextMate preferences, advanced tab, shell variables, set the TM_GIT variable to point to /opt/local/bin/git (if installed via MacPorts).
Reload bundles (Bundles->Bundle Editor->Reload Bundles).
Now it works as the SVN bundle, but pressing Ctrl+Shift+G.
If you have a svn+ssh repository and you change the username or password, you’ll need to authenticate again checking out the code:
svn co svn+ssh://[email protected]/path/to/project project
But if the service is through https, you’ll need a special option in the command:
svn co --username user https://server.com/path/to/project project
Dreamhost is a great hosting, and now that they use Phusion Passenger (mod_rails), we can host Rack based applications, like Sinatra.
Adding the great repository hosting by github, we can have a professional deploying system for our home made projects.
myapp/
public/
tmp/
views/
Connect to your host via SSH
gem install sinatra
This will install sinatra for your user in ~/.gem
Now we could upload via FTP the application to the new domain generated.
If we need to restart the app, just create a restart.txt file in the tmp folder
touch tmp/restart.txt
But we want to use git as repository of the code, and capistrano for the deployment instead of upload manually. This are the steps:
Edit config/deploy.rb
Now you can also restart the app with:
cap deploy:restart