Skip to content

Instantly share code, notes, and snippets.

@jchavarri
jchavarri / UIView+EasyFrame.h
Created February 10, 2014 09:40
UIView+EasyFrame
#import <UIKit/UIKit.h>
@interface UIView (EasyFrame)
@property (nonatomic) CGFloat left;
@property (nonatomic) CGFloat top;
@property (nonatomic) CGFloat right;
@property (nonatomic) CGFloat bottom;
@property (nonatomic) CGFloat width;
@jchavarri
jchavarri / gist:5135277
Created March 11, 2013 16:00
iOS preprocessor constants
#define DOCUMENTS_PATH [NSHomeDirectory() stringByAppendingString:@"/Documents/"]
#ifdef DEBUG
# define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
# define DLog(...)
#endif
// ALog always displays output regardless of the DEBUG setting
#define ALog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
@jchavarri
jchavarri / UIShadowButton.h
Last active December 14, 2015 20:49
UIShadowButton - A button that moves and changes its shadow when it gets pressed.
//
// UIShadowButton.h
//
// Created by Javier Chavarri on 12/03/13.
//
#import <UIKit/UIKit.h>
@interface UIShadowButton : UIButton
@jchavarri
jchavarri / iOS - FontRetrieve
Created March 16, 2013 15:48
Retrieve fonts installed on iOS, both family name and font name
NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];
NSArray *fontNames;
NSInteger indFamily, indFont;
for (indFamily=0; indFamily<[familyNames count]; ++indFamily)
{
NSLog(@"Family name: %@", [familyNames objectAtIndex:indFamily]);
fontNames = [[NSArray alloc] initWithArray:
[UIFont fontNamesForFamilyName:
[familyNames objectAtIndex:indFamily]]];
for (indFont=0; indFont<[fontNames count]; ++indFont)
@jchavarri
jchavarri / app.coffee
Created January 18, 2016 23:56 — forked from jemgold/app.coffee
class-based Framer prototypes
# An example with classes building components.
# This stuff is a little fiddly to get set up,
# but once it's working it's great - you can just
# add new instances of the components, and each
# components holds references to all of its
# children. You can set defaults & states for each
# component separately.
#
# (try clicking on the post author, and then on each
# of the comments on a post)
@jchavarri
jchavarri / machine.re
Created September 21, 2017 21:39
Triggers a bad error parsing
type token =
| OpenParen
| CloseParen
| Number string
| String string;
type state =
| Init
| ParsingNumber
| ParsingString;
@jchavarri
jchavarri / beatles.re
Last active September 27, 2017 22:03
Reason: simple variant type
type beatle =
| John
| Paul
| George
| Ringo;
let drummer = Ringo;
@jchavarri
jchavarri / shape.re
Last active September 27, 2017 23:50
Reason: variant type
type shape =
| Circle float
| Rectangle float float
| Prism float float float;
let rect = Rectangle 2.5 5.0;
@jchavarri
jchavarri / token.re
Created September 29, 2017 23:12
Reason: lexer types
type token =
| OpenParen
| CloseParen
| Number string
| String string
| Name string;
@jchavarri
jchavarri / automaton.re
Created September 29, 2017 23:15
Reason tutorial: automaton
type tokenMachine = {
current: option token,
parsed: list token
};
let machine = {current: None, parsed: []};