Skip to content

Instantly share code, notes, and snippets.

View fcy's full-sized avatar

Felipe Cypriano fcy

View GitHub Profile
@mbinna
mbinna / UIViewController+MBSensitiveInformationInScreenshotPrevention.h
Created June 12, 2011 13:00
Prevent sensitive information from appearing in the screenshot that is automatically taken when the application transitions from the foreground to the background and vice-versa.
//
// UIViewController+MBSensitiveInformationInScreenshotPrevention.h
//
// Created by Manuel Binna on 05.05.11.
// Copyright 2011 Manuel Binna. All rights reserved.
//
@interface UIViewController (MBSensitiveInformationInScreenshotPrevention)
@iamleeg
iamleeg / README.md
Created February 3, 2012 18:16
Causing methods generated by AppCode to throw exceptions

Go to "File Templates" in the Preferences window, then under the 'code' tab choose "OC implemented method body" and paste the template method in there. This then causes AppCode to generate methods like this:

- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender {
    [[NSException exceptionWithName:NSInternalInconsistencyException reason:@"Unimplemented method" userInfo:nil] raise];
    return 0;
    //To change the template use AppCode | Preferences | File Templates.
    
}

Another approach would be to use the usual forwarding approach by putting this as the first line:

@rafaelp
rafaelp / gist:1976687
Created March 5, 2012 04:55
A solution to a more obscure problem related to the "vulnerability" of mass assignment:
# account.rb
class Account < ActiveRecord::Base
has_many :users
has_many :services
end
# user.rb
class User < ActiveRecord::Base
belongs_to :account
end
anonymous
anonymous / gist:3430707
Created August 22, 2012 23:57
Pragmatic Thinking and Learning: Refactor Your Wetware

When you are not very skilled in some area, you are more likely to think you’re actually pretty expert at it.

In the paper “Unskilled and Unaware of It: How Difficulties in Recognizing One’s Own Incompetence Lead to Inflated Self-Assessments” [AUOIHDIROOILTIS] , psychologists Kruger and Dunning relate the unfortunate story of a would-be thief who robbed a bank in broad daylight. He was incredulous at his prompt arrest, because he was under the impression that wearing lemon juice on your face would make you invisible to security cameras.

The “lemon juice man” never suspected that his hypothesis was, er, suspect. This lack of accurate self-assessment is referred to as second-order incompetence, that is, the condition of being unskilled and unaware of it.

This condition is a huge problem in software development, because many programmers and managers aren’t aware that better methods and practices even exist. I’ve met many younger programmers (one to five years of experience) who never have been on a successful

@NicholasPeterson
NicholasPeterson / gist:5122235
Last active December 14, 2015 17:28
Simple mask iteration. Does not care about subsets.
// Use NS_OPTIONS for some compiler sugar.
//
// Use a type that fits your struct but consider using
// types directly to avoid 32/64bit width inconsistencies.
typedef NS_OPTIONS(UInt16, MaskType) {
MaskTypeOptionNone = 0,
MaskTypeOptionOne = 1 << 0,
MaskTypeOptionTwo = 1 << 1,
};
@boredzo
boredzo / wwdc2013index-redacted.txt
Last active December 18, 2015 12:59
Script to rename WWDC videos and slides PDFs to include the session title in the name. Also included: A list of the session numbers and (redacted where necessary) titles, in TSV format, for use with this script.
100 Keynote
101 Platforms State of the Union
102 Apple Design Awards
109 Painting the Future
200 Accessibility in OS X
201 Building User Interfaces for iOS 7
202 Accessibility in iOS
203 What’s New in Cocoa Touch
204 What’s New with Multitasking
205 What’s New in Cocoa
@mpospese
mpospese / CGRectIntegralScaled.m
Created February 28, 2013 03:34
Pixel aligns rectangles, taking the device's screen scale into account.
CGRect CGRectIntegralScaledEx(CGRect rect, CGFloat scale)
{
return CGRectMake(floorf(rect.origin.x * scale) / scale, floorf(rect.origin.y * scale) / scale, ceilf(rect.size.width * scale) / scale, ceilf(rect.size.height * scale) / scale);
}
CGRect CGRectIntegralScaled(CGRect rect)
{
return CGRectIntegralScaledEx(rect, [[UIScreen mainScreen] scale]);
}
@boctor
boctor / BaseViewController.m
Created May 5, 2011 02:08
A base view controller class that when running on the simulator in debug mode, will auto simulate a memory warning every time the view controller's viewDidAppear is called
//
// BaseViewController.m
//
// Created by Peter Boctor on 5/4/11.
//
// Copyright (c) 2011 Peter Boctor
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
@matthewmccullough
matthewmccullough / gist:47267
Created January 15, 2009 05:15 — forked from halbtuerke/gist:31934
Show Git dirty status in your Unix bash prompt (symbols not compatible with CygWin)
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[0;34m\]"
LIGHT_RED="\[\033[1;31m\]"
LIGHT_GREEN="\[\033[1;32m\]"
WHITE="\[\033[1;37m\]"
LIGHT_GRAY="\[\033[0;37m\]"
COLOR_NONE="\[\e[0m\]"
@nfarina
nfarina / NSDate+Drawing.h
Created November 17, 2011 15:49
Useful functions for drawing NSDate in the exact style of Apple's iOS Mail app.
/*
The MIT License
Copyright (c) 2010 Nick Farina
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is