This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Teacup::Stylesheet.new(:iphone) do | |
# enable orientations on the root view | |
style do | |
left 0 | |
top 0 | |
width 320 | |
height 480 | |
backgroundColor :lightyellow.uicolor | |
portrait true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Objective-C | |
uuid_t myAppUUIDbytes; | |
NSUUID *myAppUUID = [[NSUUID alloc] initWithUUIDString:@"226834ae-786e-4302-a52f-6e7efc9f990b"]; | |
[myAppUUID getUUIDBytes:myAppUUIDbytes]; | |
# Ruby | |
myAppUUIDbytes = Array.new(16, 0) | |
myAppUUID = NSUUID.alloc.initWithUUIDString("226834ae-786e-4302-a52f-6e7efc9f990b") | |
myAppUUID.getUUIDBytes(myAppUUIDbytes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# nslog with message | |
NSLog("Message from watch received: %@", message) | |
2014-02-21 10:47:01.514 OnTelly Remote[1298:60b] Message from watch received: { | |
2 = "<PBNumber 0x1650ba50> { value: 41, width: 4, signed: Y }"; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# UPDATED - IT WORKS | |
# Thanks to "kuadrosx"! | |
# #mongoid on chat.freenode.net | |
class Conversation | |
include Mongoid::Document | |
field :name | |
embeds_many :messages, as: :messagable, :class_name => 'ConversationMessage' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a file, call it "Gemfile" and write these 3 lines, then save it: | |
source "https://rubygems.org" | |
gem 'sinatra' | |
gem 'nokogiri' | |
# Run | |
bundle install | |
# from your terminal | |
# Create a file called "app.rb" and paste the follow lines (and run it with "ruby app.rb": |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'RMagick' | |
include Magick | |
width = 500 | |
height = 500 | |
start_color = "#333" | |
end_color = "#000" | |
fill = Magick::GradientFill.new(0, 0, height, height, start_color, end_color) |
OlderNewer