Skip to content

Instantly share code, notes, and snippets.

Rails.logger.info self.weightage.to_f
Rails.logger.info self.weightage.to_f/100.0
self.weightage = self.weightage.to_f/100.0
Rails.logger.info self.weightage
11.0
0.11
0
desc "Make sure there is something to deploy"
task :check_revision, :roles => :web do
unless `git rev-parse HEAD` == `git rev-parse origin/production`
puts "WARNING: HEAD is not the same as origin/production"
puts "Run `git push` to sync changes."
exit
end
end
Reduced Functionality:
This version of wkhtmltopdf has been compiled against a version of QT without
the wkhtmltopdf patches. Therefore some features are missing, if you need
these features please use the static version.
Currently the list of features only supported with patch QT includes:
* Printing more then one HTML document into a PDF file.
* Running without an X11 server.
* Adding a document outline to the PDF file.
pdf, err = Open3.popen3(command) do |stdin, stdout, stderr|
#stdin.binmode
#stdout.binmode
#stderr.binmode
stdin.write(File.read('pdf_string.xhtml'))
stdin.close
[stdout.read, stderr.read]
end
$('div.news .pagination a').click(function() {
setTimeout(function() { Ghf.run(); }, 2000);
});
# h = ActiveSupport::OrderedOptions.new
# h.boy = 'John'
# h.girl = 'Mary'
# h.boy # => 'John'
# h.girl # => 'Mary'
> 5000.times do |i|
| a[i] = i
| end
> a.symbolize_keys.reject { |k,v| k.class == Fixnum }.sort { |x,y| x[1] <=> y[1] }
=> [[:"!", 33], [:, 37], [:, 38], [:, 42], [:, 43], [:-, 45], [:, 47], [:, 60], [:, 62], [:, 94], [:, 96], [:, 124], [:, 126], [:, 317], [:-, 318], [:, 319], [:=>, 320], [:, 321], [:, 322], [:"!=", 323], [:, 324], [:, 325], [:, 328], [:"!~", 329], [:"..", 330], [:"...", 331], [:[], 332], [:[], 333], [:, 334], [:, 335], [:"::", 336], [:__autoload__, 2881], [:__autoload__, 2884], [:__classpath__, 2889], [:__classpath__, 2892], [:__tmp_classpath__, 2897], [:__tmp_classpath__, 2900], [:"Object=", 2908], [:Object, 2909], [:__classid__, 2913], [:__classid__, 2916], [:"Module=", 2924], [:Module, 2925], [:"Class=", 2932], [:Class, 2933], [:__attached__, 2937], [:__attached__, 2940], [:"Kernel=", 2948], [:Kernel, 2949], [:allocate, 2953], [:allocate, 2956], [:initialize, 2961], [:initialize, 2964], [:inherited, 2969], [:inherited, 2972], [:initialize_copy, 2977], [:initialize_copy, 2980], [:include
if uploaded_file.instance_of?(Tempfile)
FileUtils.copy(uploaded_file.local_path, path_to_file)
else
File.open(path_to_file, "wb") { |f| f.write(uploaded_file.read) }
end
# Respond to also allows you to specify a common block for different formats by using any:
#
# def index
# @people = Person.all
#
# respond_to do |format|
# format.html
# format.any(:xml, :json) { render request.format.to_sym => @people }
# end
# end
def pie_to(val, r)
rads = (val*3.60) * Math::PI / 180 # 360 deg of val % in radians
sr = (r * Math.sin(rads)).to_i
cr = (r * Math.cos(rads)).to_i
arc = val <= 50 ? 0 : 1
[sr, r-cr, arc]
end