Skip to content

Instantly share code, notes, and snippets.

@mluton
mluton / gist:2164628
Created March 22, 2012 21:14
A Git Ignore file for Xcode projects
.DS_Store
*.swp
*~.nib
build/
*.pbxuser
.xcodeproj/ !*.xcodeproj/project.pbxproj
*.xcworkspacedata
xcuserdata
*.mode1v3
*.mode2v3
@mluton
mluton / gist:2363126
Created April 11, 2012 22:17
Example of link_to with query parameters.
<%= link_to 'root', root_path(:foo => 'bar') -%>
@mluton
mluton / gist:2426309
Created April 20, 2012 05:32
Load a local HTML file in a UIWebView
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"snakehead" ofType:@"html"] isDirectory:NO]]];
<%= link_to video_path({:id => @item.video_id, :name => @item.video_url}.merge(@utm_params)), :target => '_blank' do %>
@mluton
mluton / gist:2486954
Created April 25, 2012 05:58
Set a tiled background image for a view.
textView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"stripe"]];
@mluton
mluton / gist:2822786
Created May 29, 2012 05:30
Set border properties of a UIView.
#import "QuartzCore/QuartzCore.h"
view.layer.borderColor = [UIColor redColor].CGColor;
view.layer.borderWidth = 3.0f;
@mluton
mluton / gist:2893755
Created June 8, 2012 05:23
Get a reference to a UITableViewCell given a UITableView and NSIndexPath
UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath]
@mluton
mluton / gist:3301514
Created August 9, 2012 06:08
Create NSString from Unicode
[NSString stringWithFormat:@"%C", (unsigned short)0x0021]
@mluton
mluton / gist:3363973
Created August 15, 2012 21:44
Remove EOF character from string in Ruby
gsub(/\x0A/, '')
@mluton
mluton / gist:3364025
Created August 15, 2012 21:52
Remove EOL characters from a string in Ruby
# This will work no matter where the characters appear in the string.
gsub(/\r\n?/, '')