Skip to content

Instantly share code, notes, and snippets.

View Cosmo's full-sized avatar
📎
It looks like you're looking at my profile. Would you like help?

Devran Cosmo Uenal Cosmo

📎
It looks like you're looking at my profile. Would you like help?
View GitHub Profile
def color_with(value=nil, options={})
if options.is_a?(Numeric)
alpha = options.to_f
else
alpha = options.delete(:alpha) || 1
end
if value
if (value.is_a?(String) && value[0] == "#")
value = value.gsub("#", "").to_i(16)
@Cosmo
Cosmo / gist:2864121
Created June 3, 2012 16:44 — forked from colinta/gist:2864117
css dsl for rubymotion
# Inline styles
@calculate_button = UIButton.named(I18n.t(:calculate_button)).style(color: 0xFFFFFF, align: :center, vertical_align: :center, top: 10, left: 30, width: 120, height: 40)
# External styles
# /app/stylesheets/application.rb
class ApplicationStylesheet < Stylesheets::Base
# Stylesheets for UI-Elements
# usage: @element.outfit(:awesome_default)
@Cosmo
Cosmo / gist:2864098
Created June 3, 2012 16:34
css dsl for rubymotion
# Inline styles
@calculate_button = UIButton.named(I18n.t(:calculate_button)).style(color: 0xFFFFFF, align: :center, vertical_align: :center, top: 10, left: 30, width: 120, height: 40)
# External styles
# /app/stylesheets/application.rb
class ApplicationStylesheet < Stylesheets::Base
# Stylesheets for UI-Elements
# usage: @element.outfit(:awesome_default)
@Cosmo
Cosmo / gist:2489482
Created April 25, 2012 12:43
pdf to jpg
def convert_to_previews(new_file)
name = File.basename(current_path)
images = Magick::Image.read(current_path) do
self.background_color = "white" # does not work for me :/
end
if images.length > 0
save_path = "#{Rails.root}/public/uploads/#{model.class.to_s.underscore}/file/#{model.id}/slides"