Skip to content

Instantly share code, notes, and snippets.

View cmezak's full-sized avatar

Charlie Mezak cmezak

View GitHub Profile
@cmezak
cmezak / quiet_assets.rb
Created March 6, 2012 17:17
Rails 3.2 compatible quiet assets
if Rails.env == 'development'
Rails.application.assets.logger = Logger.new('/dev/null')
Rails::Rack::Logger.class_eval do
def before_dispatch_with_quiet_assets(env)
before_dispatch_without_quiet_assets(env) unless env['PATH_INFO'].index("/assets/") == 0
end
alias_method_chain :before_dispatch, :quiet_assets
end
end
@cmezak
cmezak / UITextView+WhatFuckingSize
Created October 16, 2013 16:26
Well, I tried so many things, hoping that some of the next TextKit API would finally provide a way to precalculate the needed height for a UITextView with a given width and text. Oh well.
// HOW THE FUCK TALL DOES MY TEXT VIEW NEED TO BE?!?
@interface UITextView (WhatFuckingSize)
+ (CGSize)sizeThatFuckingFits:(CGSize)size withAttributedText:(NSAttributedString *)attributedText textContainerInsets:(UIEdgeInsets)textContainerInsets;
@end
static UITextView *FuckingTextView;
@implementation UITextView (WhatFuckingSize)
@cmezak
cmezak / Scene.h
Last active January 3, 2016 02:09
@interface MyScene : SKScene
// this is the node that will be scrolled and zoomed
@property (nonatomic, strong) SKSpriteNode *nodeToScroll;
@property (nonatomic) CGFloat zoomScale;
@end
#!/usr/bin/env ruby
puts(lambda{|q|until(!(c||=Hash.new{|e,o|e[o]=[o<((q<=3) ? 2*q :
((q)*(p||=Proc.new{|l|Math.log(l)})[q]+q*p[p[q]])),true]})[(t||=2)][0])do
while((c[s||=(t**2)][1]=false)!=c[(s+=t)-t][0])do{}end unless(!c[t][1])
t,s=t+1;end;c.select{|w,j|j[1]}.keys.first(q)}[ARGV.last.to_i])