Skip to content

Instantly share code, notes, and snippets.

View michelson's full-sized avatar
🏠
Working from home

Miguel Michelson Martinez michelson

🏠
Working from home
View GitHub Profile
total used free shared buffers cached
Mem: 512 508 4 0 0 11
-/+ buffers/cache: 495 16
Swap: 1023 93 930
top - 02:03:18 up 18:55, 1 user, load average: 0.10, 0.24, 0.11
Tasks: 74 total, 2 running, 72 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 524460k total, 520456k used, 4004k free, 660k buffers
Swap: 1048568k total, 95780k used, 952788k free, 11316k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
22847 animalit 15 0 196m 151m 1848 S 0 29.6 0:17.10 mongrel_rails
22850 animalit 15 0 194m 149m 1764 S 0 29.2 0:17.26 mongrel_rails
22856 animalit 15 0 130m 71m 1664 S 0 13.9 0:05.61 mongrel_rails
module WordTruncateHelper
def word_truncate(text, *args)
options = args.extract_options!
unless args.empty?
options[:size] = args[0] || 75
options[:omission] = args[1] || "..."
end
options.reverse_merge!(:size => 75, :omission => "...")
text.scan(/(\S+)(\s+)/)[0..options[:size]].flatten.join << options[:omission] if text
# app name
app_name = @root.split('/').last
if yes?("Drop databases?")
run "mysqladmin -u root -p drop #{app_name}_development -f"
run "mysqladmin -u root -p drop #{app_name}_test -f"
run "mysqladmin -u root -p drop #{app_name}_production -f"
end
if yes?("Create databases?")
One other cause is your :dependent callbacks.
class Blog < AR::Base
has_many :posts, :dependent => :destroy
end
This will iterate through every post and call #destroy on it. Use :delete_all if you want to just issue a single delete query. HOWEVER, this won't hit your destroy callbacks on Post.
class Blog < AR::Base
has_many :posts
sudo apt-get install erlang-nox
# Get the latest .egg file for your version of python ("python -V"), then run it: # this is only for phyton < 2.6
wget http://pypi.python.org/packages/2.5/s/setuptools/setuptools-0.6c9-py2.5.egg
sh setuptools-0.6c9-py2.5.egg
easy_install simplejson
cd /root
#! /bin/sh
### BEGIN INIT INFO
# Provides: mongodb
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the mongodb data-store
# Description: starts mongodb using start-stop-daemon
begin YAML.load_file("#{:config}/mongo_config.yml")
MONGOCONNECTION = YAML.load_file("#{:config}/mongo_config.yml")[ENV['RACK_ENV']]
rescue => e
puts "WARNING! loading config file mongo_config.yml , #{e}"
end
MongoMapper.connection = Mongo::Connection.new(MONGOCONNECTION['ip'])
MongoMapper.database = MONGOCONNECTION['db']
# environment.rb
config.gem 'mongo_mapper'
#initializers/mongo.rb
begin YAML.load_file("#{RAILS_ROOT}/config/mongo_config.yml")
MONGOCONNECTION = YAML.load_file("#{RAILS_ROOT}/config/mongo_config.yml")[RAILS_ENV]
rescue => e
puts "WARNING! loading config file mongo_config.yml , #{e}"
end
<? $recentPosts = new WP_Query();
$recentPosts->query('offset=1&showposts=5'.'&limit='.$how_many);
?>
<div class="box">
<?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
<div class="latest_news latest_news span-12 last append-bottom">
<div class="tiny_box">
<h3><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
<? if (has_post_thumbnail()) {