Skip to content

Instantly share code, notes, and snippets.

Tim Carlson timgcarlson

Block or report user

Report or block timgcarlson

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@timgcarlson
timgcarlson / javascript.json
Last active Jul 5, 2018
Visual Studio Code - Snippets for Javascript (Babel), React, Redux, React Router, JSX - (This file is always being updated)
View javascript.json
/** TODO:
* - Add shortcut acronyms to each prefix
* - Remove empty div and return placeholders from component snippets
* - Add prop-types to all new file components
*/
{
// Component snippets
"New Class Component": {
"prefix": "new class component",
"body": [
@timgcarlson
timgcarlson / ShapeCutout.swift
Last active May 25, 2017
Using the non-zero winding rule to cutout the path of a shape (uses bezierPathByReversingPath)
View ShapeCutout.swift
UIGraphicsBeginImageContextWithOptions(CGSize(width: 200, height: 200), false, 0.0)
let context = UIGraphicsGetCurrentContext()
let rectPath = UIBezierPath(roundedRect: CGRectMake(0, 0, 200, 200), cornerRadius: 10)
var cutoutPath = UIBezierPath(roundedRect: CGRectMake(30, 30, 140, 140), cornerRadius: 10)
rectPath.appendPath(cutoutPath.bezierPathByReversingPath())
UIColor.orangeColor().set()
outerForegroundPath.fill()
@timgcarlson
timgcarlson / drawText:inFrame:withFont:textColor:alignment:verticalAlignment
Created Mar 13, 2015
Method to draw text to the current Core Graphics context (missing vertical alignment ability)
View drawText:inFrame:withFont:textColor:alignment:verticalAlignment
- (void)drawText:(NSString *)textToDraw inFrame:(CGRect)frameRect withFont:(UIFont *)originalFont textColor:(UIColor *)textColor alignment:(PDFTextAlignment)alignment verticalAlignment:(PDFTextVerticalAlignment)verticalAlignment {
if (!textToDraw) {
// If nil, give it an empty value to draw
textToDraw = @"";
}
// Prepare font
CTFontRef font = [self ctFontRefFromUIFont:originalFont];
@timgcarlson
timgcarlson / Get specific view of a UIBarButtonItem from a UINavigationController
Created Jan 14, 2015
Get the view of the bar button item with respect to the right most item on the navigation bar. Useful for when you want to the frame of a UIBarButtonItem on a UINavigationBar
View Get specific view of a UIBarButtonItem from a UINavigationController
/** Get the view of the bar button item with respect to the right most item.
@param viewsFromRight The index of the button on the navigation controller from the right side. Pass 0 if the right most view is desired.
@param navController The UINavigationController where the bar button item exists.
@returns A UIView of the item on the navigation bar provided, x number of views from the right side (where x is the viewsFromRight property.
*/
- (UIView *)barItemViewFromRight:(NSUInteger)viewsFromRight ofNavController:(UINavigationController *)navController {
UINavigationBar *navBar = navController.navigationBar;
UIView *rightView = nil;
UIView *desiredView = nil; // The right-most view to hold and eventually return
@timgcarlson
timgcarlson / gist:11407446
Last active Aug 29, 2015
HTML to prevent pinch-to-zoom on touch screen devices.
View gist:11407446
<meta name="viewport" content="width=1000px; user-scalable=0;" />
You can’t perform that action at this time.