Skip to content

Instantly share code, notes, and snippets.

View xirukitepe's full-sized avatar
🙈
See No Evil

Shi xirukitepe

🙈
See No Evil
View GitHub Profile
@xirukitepe
xirukitepe / rspec_source
Created November 8, 2012 08:17
Rspec for newbies tutorial
http://net.tutsplus.com/tutorials/ruby/ruby-for-newbies-testing-with-rspec/
@xirukitepe
xirukitepe / Better Database Pulling With Heroku
Created November 23, 2012 06:44 — forked from jackkinsella/Better Database Pulling With Heroku
Taps isn't reliable for anything but dummy databases. This command invokes the more powerful PGBackups. A side effect is that every time you pull your database locally a backup is also generated on your server.
#!/bin/bash
# Best use case is to create a file "update_local_db.sh" in your project folder and then call the command with bash update_local_db
# Follow me: @jackkinsella
function LastBackupName () {
heroku pgbackups | tail -n 1 | cut -d"|" -f 1
}
# This part assumes you have a low limit on no. of backups allowed
sudo apt-get install zsh tree
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
mv ~/.zshrc ~/.zshrc.bkp
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
chsh -s $(which zsh)
@xirukitepe
xirukitepe / database_cleaner_mongoid.rb
Created November 27, 2012 06:14
Database Cleaner for MongoDB
config.before(:suite) do
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.orm = "mongoid"
end
@xirukitepe
xirukitepe / mongo_config.rb
Created November 27, 2012 06:33
MongoDB initializer in config/initializers folder
MongoMapper.connection =
Mongo::Connection.new('localhost', 27017)
MongoMapper.database = "#expense-#{Rails.env}"
if defined?(PhusionPassenger)
PhusionPassenger.on_event(:starting_worker_process) do |forked|
MongoMapper.connection.connect if forked
end
@xirukitepe
xirukitepe / oh my zsh as default
Created December 27, 2012 02:15
Oh my ZSH as default shell
chsh -s /bin/zsh
@xirukitepe
xirukitepe / confirm-modal.js.coffee
Created January 29, 2013 15:14
overriding the ugly/traditional confirm alert box using bootstrap modal
$.rails.allowAction = (element) ->
# The message is something like "Are you sure?"
message = element.data('confirm')
# If there's no message, there's no data-confirm attribute,
# which means there's nothing to confirm
return true unless message
# Clone the clicked element (probably a delete link) so we can use it in the dialog box.
$link = element.clone()
# We don't necessarily want the same styling as the original link/button.
.removeAttr('class')
@xirukitepe
xirukitepe / fadeout.js.coffee
Last active December 11, 2015 22:58
FadeOut Div with specific setTimeOut function
# Flashing Message
# Fade flash message
$(document).ready ->
$(".alert").fadeOut 4000
$(".alert").mouseenter ->
$(".alert").stop()
@xirukitepe
xirukitepe / Gemfile_structure
Created February 16, 2013 06:15
GemFile structure before deploying to HEROKU!
source 'https://rubygems.org'
gem 'rails', '3.2.11'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'bootstrap-sass', '2.1'
gem 'twitter-bootstrap-rails'
gem 'pg'
@xirukitepe
xirukitepe / deploy.rb
Created February 18, 2013 05:16
deploy.rb copy
set :application, "gppb"
set :repository, "[email protected]:AppSource/gppb.git"
set :scm, :git
set :user, "gppb.com"
set :deploy_to, "/home/gppb.com/apps/#{application}"
set :use_sudo, false
set :keep_releases, 5
set :normalize_asset_timestamps, false
# set :scm, :git # You can set :scm explicitly or Capistrano will make an intelligent guess based on known version control directory names
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`