Skip to content

Instantly share code, notes, and snippets.

View matrixfox's full-sized avatar

Matrixfox matrixfox

View GitHub Profile

Objective-C Coding Convention and Best Practices

Most of these guidelines are to match Apple's documentation and community-accepted best practices. Some are derived some personal preference. This document aims to set a standard way of doing things so everyone can do things the same way. If there is something you are not particularly fond of, it is encouraged to do it anyway to be consistent with everyone else.

This document is mainly targeted toward iOS development, but definitely applies to Mac as well.

Operators

NSString *foo = @"bar";
@matrixfox
matrixfox / git-bisect.md
Last active August 29, 2015 14:11
git bisect

git bisect

  1. Binary search through revision history
  2. You may not need it often
  3. Saves a ton of time!

Commands

1. Start git bisect

@matrixfox
matrixfox / NSCoding
Last active August 29, 2015 14:11
NSCoding
NSCoding
===
- (void)viewDidLoad
{
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc]
initWithItems:[NSArray arrayWithObjects:
@"Segm 1",
@"Segm 2",
@"Segm 3",
@"Segm 4", nil]];
[segmentedControl setFrame:CGRectMake(20, 20, [UIScreen mainScreen].bounds.size.width - 40, 30)];
[segmentedControl setSelectedSegmentIndex:0];
@matrixfox
matrixfox / xcode-6-empty-application-template.m
Last active August 29, 2015 14:10
Xcode 6 Empty Application Template
// Xcode 6 - Empty Application Template
//
// 1. Create a new "Single View Application" template.
// 2. Delete said files "Main.storyboard", "ViewController.h", "ViewController.m".
// 3. Remove the "Main storyboard file base name" entry from "Info.plist" file.
// 4. Open AppDelegate.m, and edit applicationDidFinishLaunchingWithOptions with this snippet.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
<?php
/**
* Loop Add to Cart
*/
global $product;
if( $product->get_price() === '' && $product->product_type != 'external' ) return;
?>
@matrixfox
matrixfox / fakemail.js
Last active August 29, 2015 13:57
You suck at social attacks.school
var nodemailer = require("nodemailer");
// create reusable transport method (opens pool of SMTP connections)
var smtpTransport = nodemailer.createTransport({
service: "Gmail",
auth: {
user: "*******************",
pass: "*******************"
}
});
<?php
$html = "";
$url = "http://ws.audioscrobbler.com/2.0/user/matrixfox/topartists.xml";
$xml = simplexml_load_file($url);
for($i = 0; $i < 10; $i++){
$title = $xml->artist[$i]->image['3'];
$title = str_replace("http://userserve-ak.last.fm/serve/252/","",$title);
$html .= "<img src='http://userserve-ak.last.fm/serve/252/$title'>";
}
echo $html;
/ ==================================================
/ BOOTSTRAP NAVBAR DEFAULT HAML
/ http://getbootstrap.com/components/#navbar-default
/ ==================================================
%nav{'class' => 'navbar navbar-default', 'role' => 'navigation'}
/ Brand and toggle get grouped for better mobile display
%div.navbar-header
%button{'type' => 'button', 'class' => 'navbar-toggle', 'data-toggle' => 'collapse', 'data-target' => '#bs-example-navbar-collapse-1'}
%span.sr-only Toggle navigation
%span.icon-bar