Skip to content

Instantly share code, notes, and snippets.

View k2052's full-sized avatar
🦄
awesome

K k2052

🦄
awesome
View GitHub Profile
##
# Authentication Plugin via omniauth on Padrino
# prereqs:
# http://github.com/intridea/omniauth/
# http://github.com/achiu/omniauth/ working fork
#
module OmniAuthInitializer
def self.registered(app)
require 'omniauth'
def drawRoundedRec(offset, width, height, radius, color = nil)
x = offset['left']
y = offset['top']
ry = y + height
rx = x + width
str = <<-eos
var idMk = charIDToTypeID( "Mk " );
var desc77 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref42 = new ActionReference();
# For documentation see move_layer_to_group()
def move_layer_to_group(layer_name, group)
doc = @app.current_document
dest = find_layer_set(doc.layer_sets.to_a, group)
src = find_layer(doc.art_layers.to_a, doc.layer_sets.to_a, layer_name)
if src[:depth] > 0
src[:depth] = src[:depth] - 1
end
@k2052
k2052 / text.md
Created May 11, 2011 00:17
Phrases relatable to designers & developers; often overused, sometimes cliche, sometimes stolen, sometimes brilliant. Tweet sized for your convenience.
  • A designer free to choose will always choose Helvetica.
  • What do I think of HTML5? I think it would be a very good idea.
  • If you do not understand yourself, how can you expect to understand your users?
  • Design is its own reward.
  • To me, being a designer doesn't mean knowing design; it means taking pleasure in designing.
  • Practical IE development and marketing consists of ignoring ever other browser.
  • Poor design is simply an opportunity to re-design.
  • A good designer creates form from function, function from form, thought from ideas.
  • Java paralyzes the mind and leaves one so unable to think like a programmer; so that by the time these kids are out of school their foundation is hopelessly ruined
  • When the problem is complexity, the cure might just be ruby.
@k2052
k2052 / string_ext.rb
Created May 27, 2011 19:20
Text Truncation By Word.
class String
# Truncates a string
def truncate(length = 30, end_string = '…')
return self if self == nil
words = self.split()
words[0..(length-1)].join(' ') + (words.length > length ? end_string : '')
end
end
class AllButPattern
@@match = Struct.new(:captures)
def initialize(app, *exceptions)
@controller = app.current_controller
@app = app
@exceptions = exceptions
@captures = @@match.new([])
end
TestingRoutes.controllers :main do
before(:index) do
@test = 'cow'
puts 'before filter hit?'
end
get :index, :map => "/example" do
puts @test
"Hello world!"
class Everything
@@match = Struct.new(:captures)
def initialize(*exceptions)
@exceptions = exceptions
@captures = @@match.new([])
end
def match(str)
@captures
TestingRoutes.controllers :main do
before(:index) { @test = 'before'}
get :index, :map => '/test' do
@test
end
end
should "be able to filter based on a symbol or path in a controller" do
mock_app do
controllers :foo do
before(:index, '/foo/main') { @test = 'before'}
get :index do
@test
end
get :main do
@test
end