How Many Gigs of RAM Are On My Server?
How much memory is on my linux server? Run the free command
free -g total used free shared buffers cached Mem: 2 1 0 0 0 1 -/+ buffers/cache: 0 1 Swap: 3 0 3
Which will tell you memory in Gigs. You can pass other flags, such as, -m or -k, which will give you the number in megs and kilobytes respectively.
The man page is as follows
man free
FREE(1) Linux User's Manual FREE(1)
NAME
free - Display amount of free and used memory in the system
SYNOPSIS
free [-b | -k | -m | -g] [-o] [-s delay ] [-t] [-V]
DESCRIPTION
free displays the total amount of free and used physical and swap memory in the system, as well as the buffers used by the kernel. The shared memory column should be
ignored; it is obsolete.
Options
The -b switch displays the amount of memory in bytes; the -k switch (set by default) displays it in kilobytes; the -m switch displays it in megabytes; the -g switch
displays it in gigabytes.
The -t switch displays a line containing the totals.
The -o switch disables the display of a "buffer adjusted" line. If the -o option is not specified, free subtracts buffer memory from the used memory and adds it to
the free memory reported.
The -s switch activates continuous polling delay seconds apart. You may actually specify any floating point number for delay, usleep(3) is used for microsecond resolu-
tion delay times.
The -V displays version information.
FILES
/proc/meminfo
memory information
SEE ALSO
ps(1), slabtop(1), vmstat(8), top(1)
email Git Linux: /etc/hosts committer config Git mta push
by bseanvt
leave a comment
Have Git Email Committers After Pushes
You need a Mail Transfer Agent MTA on the server. The easiest way is to install Sendmail, which Git uses by default.
apt-get install sendmail
Remember that /etc/hosts file needs the ip address to map to the domain name your sending mail from
# vim /etc/hosts 127.0.0.1 localhost localhost.localdomain 207.136.202.87 wwwexample.com
Sendmail has a tendency to hang when sending mail otherwise. To test sendmail
sendmail email@example.com this is a test how are you today world? .
The period on a line by itself denotes end of message and will terminate the prompt and deliver the message.
Now you need to configure Git to send email after it receives a “push” from a committer. You can add email addresses, or you can set up a mailing list to email all members. Either way, you accomplish this with the following command, just remember to cd into the git repository.
git config --add hooks.mailinglist "mailinglist@example.com"
Next you need to activate the post-receive hook, located in the hooks directory of your repository.
cp post-receive.sample post-receive
And uncomment the last line, which uses sendmail to deliver the commit message
# uncomment the last line but keep the period "." . /usr/share/doc/git-core/contrib/hooks/post-receive-email
All done. Now just make some changes to your source code, add and commit them and you should receive an email with all the details!
Git: adduser developers development groupadd Linux mac os x repo shared ssh
by bseanvt
1 comment
Setting Up Users, Permissions and Groups for SSH Access to a Shared Git Repository
If you are having permission problems using git, such as
error: insufficient permission for adding an object to repository database ./objects
There are a couple thing you can do to remedy the situation, before moving to a full on git server like gitosis.
Create your users and add them to a group. Create (if you haven’t already) your git repo on the server and change permission and ownship and set the git config sharedRepository to true.
Here are all the commands, quick and dirty!
adduser sean adduser jackson groupadd developers adduser sean developers adduser jackson developers mkdir -p /git/dev/app.git cd /git/dev/app.git git --bare init vim description #edit this file (mac os x complains otherwise) chmod -R g+ws * chgrp -R developers * git repo-config core.sharedRepository true
Found from: http://mapopa.blogspot.com/2009/10/git-insufficient-permission-for-adding.html
mac os x ruby: development environment ruby rvm setup version management
by bseanvt
17 comments
Installing and Using Rvm on Mac OS X, Creating Gemsets and Reverting to Original Environment
What is RVM and why should you use it? RVM is a Ruby interpreter, version management tool. In short, it enables you to switch between different versions and releases of Ruby (for instance, version 1.8.6, 1.8.7, jruby 1.9.2, ruby enterprise edition) on the same machine, while associating different gems with each version of the ruby interpreter. This is super useful and awesome. If you want to play with Rails 3 and Ruby 1.9.1, for 5 minutes, and then want to switch back to your production apps, which are running on Rails 2.3.5 and Ruby 1.8.7, you can do so with a single command from the terminal. With RVM this is a fairly simple process so there is no reason not to install it. You can also revert back to your system settings (not using RVM) with a single command. After all Rails is just a gem, so you can easily create and manage different RVM “gemsets”, (sets of different gems), for the different versions of Ruby (rubies as RVM refers to them) you have installed.
Installing RVM
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
Next you have to add rvm to your bash profile
# place in ~/.bash_profile as the very last line [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
To check everything went well
type rvm | head -n1
Should tell you “rvm is a function”
How to add ruby, pass it the version to install
rvm install 1.8.7
*The current terminal session will load this environment. New sessions will not. To use a version of ruby and set it as the default, pass it the –default option
rvm use 1.8.7 --default
Next create a gemset, which will make available different gems for different versions
rvm gemset create rails_2_3_5
When you run “gem list”, you should see nothing!
gem install rails -v=2.3.5
Set a default rvm and default gemset, specify which gemset with the @ sign and include the –default option
rvm use 1.8.7@rails_2_3_5 --default
which gem gem list ruby --version rails --version
And to get back to where you started and revert to using your original ruby setup
rvm system
For upgrading your version of RVM check out this post I wrote http://seanbehan.com/ruby/how-to-upgrade-rvm-on-mac-os-x/
Finally, you can create a .rvmrc file and put it in any directory and when you cd into that directory the environment specified in the file will be loaded automatically. This way you don’t have to remember the version and gemsets and type them into the console. All you have to do is put the ruby version and gemset name in the file like so
ruby1.8.7@rails2.3.5
You’ll be prompted to trust the .rvmrc file the first time, type “y” for yes. Also, subdirectories will inherit this .rvmrc so you can just put it in the parent directory like
rails2/
.rvmrc
app1
app2
rails3/
.rvmrc
app1
app2
And both app1 and app2 will use the .rvmrc environment while your rails3 directory apps will load the environment in its directory!
More information available here:
http://rvm.beginrescueend.com/rvm/install/
http://www.stjhimy.com/posts/4
http://eddorre.com/posts/installing-rails-3-beta-4-using-rvm
Renaming Routes in Rails 3 with :As and :Controller
Renaming routes in Rails 2.* is straight forward. It goes something like this.
## config/routes.rb map.resources :users, :as => :members
This will give you users_path and form_for(User.new) helpers, for instance, mapping the url to /members instead of /users while using the users_controller.rb class.
In Rails 3.*, this is still possible. It is accomplished differently. In my opinion, it seems a little less elegant.
# config/routes.rb
resources :members, :as => :users, :controller => :users
# app/views/**/*.erb
link_to "Members", users_path
form_for User.new do |f|
# Rake routes
users GET /members(.:format) {:controller=>"users", :action=>"index"}
users POST /members(.:format) {:controller=>"users", :action=>"create"}
new_user GET /members/new(.:format) {:controller=>"users", :action=>"new"}
edit_user GET /members/:id/edit(.:format) {:controller=>"users", :action=>"edit"}
user GET /members/:id(.:format) {:controller=>"users", :action=>"show"}
user PUT /members/:id(.:format) {:controller=>"users", :action=>"update"}
user DELETE /members/:id(.:format) {:controller=>"users", :action=>"destroy"}
Your resource is “members” and you are overriding the name (using :as=>”users”) however, you still have to specify the controller.
Combat Spam with the Akismet Class for Ruby
Here is the Akismet.rb class, written by David Czarnecki. I’ve seen several tutorials online using this class, however, the class isn’t available at David’s blog. So… I reposted it here and at the pastie link below
http://pastie.org/1150693
Running Gem Server to View Docs for Ruby Libraries on Localhost
gem server
will boot up documentation on port 8808 by default pass it the -p flag followed by the port number to change.
gem server -p3000
Uploading Files with Curl
curl -i -F name=test -F filedata=@localfile.jpg http://example.org/upload
Courtesy of http://ariejan.net/2010/06/07/uploading-files-with-curl/
Using to_sentence method on an Array in Ruby on Rails
Member.all.collect {|member| member.firstname}.to_sentence
=> "Alex, Andy, and Sean"
Declare separator and the connector
Member.all.collect {|member| member.firstname}.to_sentence(
:connector => "and last but not least,",
:skip_last_comma => true
)
=> "Alex, Andy and last but not least, Sean"


