Skip to content

Instantly share code, notes, and snippets.

@mizanRahman
mizanRahman / Rakefile-Snippet-commit-deploy
Created June 13, 2013 19:42
rake task for git commit and deploy
###
### Rake tasks for git commit and deploy
###
##use it if you want commit only -no pushing
desc "Task description"
task :commit, :message do |t, args|
message = args.message
if message==nil
message = "Source updated at #{Time.now}."
end
@mizanRahman
mizanRahman / power-syntex.md
Last active December 18, 2015 07:39
ruby notes

Collection lambdas

accumulating over a list

a=[1,2,3]
sum = a.inject(0) {|result, e| result+e}
p sum

transform each element

b = a.map{|i| i*i}

print b

@mizanRahman
mizanRahman / fogdemo.rb
Created June 7, 2013 18:15
using amazon s3 file storage with fog
require 'rubygems'
require 'fog'
# create a connection
connection = Fog::Storage.new({
:provider => 'AWS',
:aws_access_key_id => YOUR_AWS_ACCESS_KEY_ID,
:aws_secret_access_key => YOUR_AWS_SECRET_ACCESS_KEY
})
@mizanRahman
mizanRahman / gemlist.md
Created June 6, 2013 23:27
important gems list

#Important gems list

##Production

##Development

##test

  • rspec
  • guard
@mizanRahman
mizanRahman / ruby-install-mac.sh
Created June 5, 2013 23:08
ruby install script for mac
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
brew install ruby
@mizanRahman
mizanRahman / git-commands.md
Last active December 17, 2015 16:29
handy git commands

###to discard unstaged changes

git checkout .
git checkout <filename>

to unstage the staged changes

git reset HEAD <filename>

###to remove unstagged changes

<% @profile.errors.full_messages.each do |msg| %>
<p class="alert"><%= msg %></p>
<% end %>
@mizanRahman
mizanRahman / Rakefile
Last active December 17, 2015 10:28
common tasks for heroku deployment and source-controlling with github and bitbucket
#!/usr/bin/env rake
remote_repos = {
"github" => "github",
"bitbucket" => "origin"
}
deploy_remotes = {'heroku'=>"heroku"}
@mizanRahman
mizanRahman / Rakefile
Created May 16, 2013 11:05
rake task to sync your source files to github
desc "commit source to github"
task :sync do
puts "syncing source files to github"
system "git add ."
puts "\n## Commiting: Site updated at #{Time.now.utc}"
message = "Site updated at #{Time.now.utc}"
system "git commit -m \"#{message}\""
puts "\n## Pushing source files"
system "git push origin source"
puts "\n##Source Sync completed"
@mizanRahman
mizanRahman / rails-heroku.sh
Last active December 16, 2015 22:19
rails-heroku
rails new test_app
cd test_appli
git init
git add .
git commit -m "initial commit"
heroku create --stack cedar
git push heroku master
heroku run rake db:migrate