Skip to content

Instantly share code, notes, and snippets.

View venkatd's full-sized avatar

Venkat Dinavahi venkatd

View GitHub Profile
#import "ScaledImageView.h"
#import "UIImageView+WebCache.h"
@implementation ScaledImageView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
@venkatd
venkatd / rotate_view.m
Created July 6, 2012 19:07
Rotate a UIView on the iPhone
// rotate view by 45 degrees
myUIView.transform = CGAffineTransformMakeRotation(M_PI/4);
@venkatd
venkatd / gist:3094937
Created July 12, 2012 01:06
New rails project with RVM
reate and use the new RVM gemset
$ rvm use --create 1.9.3@awesome_rails_project
# install rails into the blank gemset
$ gem install rails
# generate the new rails project
$ rails new awesome_rails_project
# go into the new project directory and create an .rvmrc for the gemset
@venkatd
venkatd / iphone_screen_dimensions.m
Created July 13, 2012 00:43
iphone screen dimensions
CGRect rect;
// Get screen dimensions
rect = [[UIScreen mainScreen] bounds];
NSLog(@"Bounds: %1.0f, %1.0f, %1.0f, %1.0f", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
// Get application frame dimensions (basically screen - status bar)
rect = [[UIScreen mainScreen] applicationFrame];
NSLog(@"App Frame: %1.0f, %1.0f, %1.0f, %1.0f", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
// Get status bar frame dimensions
rect = [[UIApplication sharedApplication] statusBarFrame];
NSLog(@"Statusbar frame: %1.0f, %1.0f, %1.0f, %1.0f", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
@venkatd
venkatd / gist:3308217
Created August 9, 2012 21:30
Animate tabBarController custom
NSInteger controllerIndex = 2;
UIView *fromView = self.tabBarController.selectedViewController.view;
UIView *toView = [[self.tabBarController.viewControllers objectAtIndex:controllerIndex] view];
// Get the size of the view area.
CGRect viewSize = fromView.frame;
BOOL scrollRight = controllerIndex > self.tabBarController.selectedIndex;
// Add the to view to the tab bar view.
[fromView.superview addSubview:toView];
Opal.class('DateTime', {
'hours': function() {
return this._hours;
},
'hours=': function(v) {
this._hours = v;
}
});
Greeter = Opal.class('Greeter', {
'initialize': function(name) {
this.set_first_name(name);
},
'greet': function() {
this.puts('Hi, ' + this.first_name());
},
'first_name': function() {
return this._first_name;
},
var mapOptions = {
center: new google.maps.LatLng(-34.397, 150.644),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
mapOptions);
ActiveRecord::Base.class_eval do
class_attribute :no_serialize_update
self.no_serialize_update = false
end
ActiveRecord::AttributeMethods::Dirty.class_eval do
# Serialized attributes should always be written in case they've been
# changed in place.
def keys_for_partial_update
<?xml version="1.0"?>
<gpx version="1.1" creator="Xcode">
<wpt lat="40.7475" lon="-73.9725">
<name>Murray_Hill</name>
</wpt>
</gpx>