Skip to content

Instantly share code, notes, and snippets.

allotments = []
params[:roles_divisions].map do |rd|
rd[2].each do |d|
allotments << Allotment.create(:user_id => @user.id, :division_id => d.to_i, :role_name => rd[0])
end
end
@user.allotments = allotments
@user.allotments.map &:destroy # delete old allotments
# format: [ ['role', 'human-role', [1,2,3]], ['role', 'human-role', [1,2,3]] ] defined in user model.
allots = []
params[:roles_divisions].each do |rd|
rd[2].each do |d|
allots << Allotment.create(:user_id => @user.id, :division_id => d.to_i, :role_name => rd[0])
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
# 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
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
> 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
# h = ActiveSupport::OrderedOptions.new
# h.boy = 'John'
# h.girl = 'Mary'
# h.boy # => 'John'
# h.girl # => 'Mary'
$('div.news .pagination a').click(function() {
setTimeout(function() { Ghf.run(); }, 2000);
});
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
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.