Skip to content

Instantly share code, notes, and snippets.

@bcambel
Created July 15, 2011 10:17
Show Gist options
  • Save bcambel/1084433 to your computer and use it in GitHub Desktop.
Save bcambel/1084433 to your computer and use it in GitHub Desktop.
Useful linux and rails dev and server related commands ( Git,Redis,MongoDB,RVM, etc..)
#!/bin/bash
echo "don't freaking run this shell script dude!"
exit 65;
# As a newbie to the unix systems, here are some of the scripts that I use commonly
# down below contains Ruby and related app commands
# the file is going to be a mess soon, I believe :) Enjoy it!
# editors (creates file if does not exist )
vim file
nano file
#readers
less file
#creates a file called "me" if it does not exist, otherwise changes the timestamp of the file to NOW
touch me
# Create recursive directories
# -p command is the mother of recursion creation in this case
mkdir -p /data/db
# search file or directory names and output error messages(indicated by 2 ) to the /dev/null
#/dev/null is a special stream in O/S that does nothing.
find / -name mongo 2>/dev/null
# symlink as known as directory shortcut or linking in windows
# NOTE: it is also used for nginx to indicate which sites are available to process
ln -s /usr/local/nginx/sites-available/website.com /usr/local/nginx/sites-enabled/website.com
#setting O/S locale-language
/usr/sbin/locale-gen en_US.UTF-8
/usr/sbin/update-locale LANG=en_US.UTF-8
#thin configuration
#generates a configuration file, sets the app path in file, creates a cluster of 3 thin proc and set
# the application mode production
thin config -C /etc/thin/app.yml -c /home/www/app/ --servers 3 -e production
# creates a rails Model/View/Controller structure for the given name
# generate:<rails-genName>:<structureName>:<fields:<fieldName>:<fieldType>
rails generate scaffold Post name:string date:DateTime content:String
#generates a new secret_token for Rails apps
rake generate:secret_token
# ==============GIT======================
# formatting git log output
# found in Diaspora config/initializers/version_header.rb (https://github.com/diaspora/diaspora )
# only get the last log item ( -1 ) in a desired format -
# the below ruby code extracts the formatted text
# if git_cmd =~ /^([\d\w]+?)\s(.+)$/
# AppConfig[:git_revision] = $1
# AppConfig[:git_update] = $2.strip
#end
# Example output
# 4cd4df4df8e40af782c254548f8bb03f61117c44 2011-07-15 07:11:22 +0200
git log -1 --pretty="format:%H %ci"
# shows the file name of the last commit change
# git-show - Show various types of objects
# run git show --help for a detailed description of the available commands
git show --name-only 2>/dev/null
# git commands
# adds all the files
git add .
# commits the change to the local repo
git commit -m "Commit message is this"
# sends the files to the remote link
git push -u origin master
# install mysql and related libs
apt-get install -y mysql-server libmysqlclient-dev libmysql-ruby
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment