Skip to content

Instantly share code, notes, and snippets.

View srm's full-sized avatar

Sam McLaughlin srm

View GitHub Profile
@srm
srm / keybase.md
Created September 9, 2019 23:39
keybase.md

Keybase proof

I hereby claim:

  • I am srm on github.
  • I am mcsam (https://keybase.io/mcsam) on keybase.
  • I have a public key ASAW8uJGGQWjiWZ8kEEWv5elGhR4KYhNE9vT9pkIjoHrowo

To claim this, I am signing this object:

@srm
srm / style.css
Created April 9, 2014 02:30
Better HR tag with CSS radial gradients
body { margin: 30px; }
hr {
border: none;
border-top: 1px solid #eee;
height: 5px;
background: -webkit-radial-gradient(50% 0%, 50% 5px, #aaa 0%, white 100%);
}
@srm
srm / bindings.xml
Created November 29, 2012 21:10
Better Dart Editor Key bindings for OSX
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<dartKeyBindings version="1">
<!--The format is straightforward, consisting of two attributes plus one that is optional.
The required attributes are the command name, which is the same as it appears in
menus, and the key sequence, which is all uppercase. The optional attribute is the
name of the platform to which the binding applies if it is not universal.-->
<keyBinding commandName="Backward History" keySequence="ALT+ARROW_LEFT"/>
<keyBinding commandName="Backward History" keySequence="ALT+COMMAND+ARROW_LEFT" platform="cocoa"/>
<keyBinding commandName="Backward History" keySequence="COMMAND+[" platform="cocoa"/>
<keyBinding commandName="Close" keySequence="COMMAND+W"/>
@srm
srm / gist:4150517
Created November 26, 2012 20:47
Fixing Apple's UIPageViewControllerDatasource mess
-(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{
if ([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]){
NSLog(@"Velocity: %f",[(UIPanGestureRecognizer*)gestureRecognizer velocityInView:self.pageViewController.view].x);
if ([(UIPanGestureRecognizer*)gestureRecognizer velocityInView:self.pageViewController.view].x > 0.0) {
return [self isThereAPrevArticle];
}
else if ([(UIPanGestureRecognizer*)gestureRecognizer velocityInView:self.pageViewController.view].x < 0.0) {
return [self isThereANextArticle];
@srm
srm / FLOCow+isMilkable.h
Created August 12, 2012 19:05
Storing data in Categories
#import "FLOCow.h"
@interface FLOCow (isMilkable)
- (BOOL) milkable;
- (void) setMilkable:(BOOL)canMilk;
@end
FLOCow+isMilkable
@srm
srm / gist:3154424
Created July 21, 2012 03:12
Preventing UIWebView Navigation
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
BOOL someOtherCondition = [request.URL.scheme isEqualToString:@"http"];
if((navigationType == UIWebViewNavigationTypeLinkClicked)&&(someOtherCondition)){
return NO;
}
else {
return YES;
}
@srm
srm / gist:3154326
Created July 21, 2012 02:52
Disabling Scrolling in a UIWebView
self.webView.scrollView.scrollEnabled = NO;
self.webView.scalesPageToFit = NO;
@srm
srm / gist:3154285
Created July 21, 2012 02:39
Getting the height of a UIWebView
-(void)webViewDidFinishLoad:(UIWebView *)webView{
//Get the height of the web view, and change it's size to fit the content it's displaying.
[webView setFrame:CGRectMake(webView.frame.origin.x,
webView.frame.origin.y,
320,
[webView stringByEvaluatingJavaScriptFromString:@"document.body.offsetHeight;"].intValue)];
//Change the scrollview's contentSize to accommodate the new height of the webView.
self.scrollView.contentSize = CGSizeMake(320, webView.frame.size.height+webView.frame.origin.y);
}