Skip to content

Instantly share code, notes, and snippets.

//
// UIColor+lerp.h
// Lotus
//
// Created by Andrei on 3/3/13.
// Copyright (c) 2013 Andrei. All rights reserved.
//
#import <UIKit/UIKit.h>
@andrei512
andrei512 / notifcations
Created July 9, 2013 13:36
print all notfications
[[NSNotificationCenter defaultCenter] addObserverForName:nil
object:nil
queue:[NSOperationQueue mainQueue]
usingBlock:^(NSNotification *notification) {
PO(notification)
}];
@andrei512
andrei512 / to_objc.rb
Last active December 19, 2015 19:38
converts JSONish structures from ruby to objective-c code
require 'json'
def tabspaces indent_level
return " " * indent_level
end
def to_objc object, indent_level = 0, ignore_first = false
first_indent = ignore_first ? "" : tabspaces(indent_level)
indent = tabspaces indent_level
if object.is_a? Array
[APUtils benchmark:^{
for (int i = 0; i < 1000000; ++i) {
self.testing = @(i);
}
} name:@"self.testing = @(i);"];
[APUtils benchmark:^{
for (int i = 0; i < 1000000; ++i) {
[self setValue:@(i) forKey:@"testing"];
}
//
// UITextField+Autocomplete.h
//
// Created by Andrei Puni on 7/23/13.
//
#import <UIKit/UIKit.h>
typedef void(^UpdateStringBlock)(NSArray *strings);
@andrei512
andrei512 / feeds.xml
Created July 26, 2013 13:12
cool feeds
<?xml version="1.0" encoding="utf-8"?>
<opml version="1.0">
<head>
<title>My feedly feeds</title>
</head>
<body>
<outline text="iOS Programming">
<outline text="Cocoa Is My Girlfriend" htmlUrl="http://www.cimgf.com" type="rss" xmlUrl="http://www.cimgf.com/feed/"/>
<outline text="iDevBlogADay" htmlUrl="http://idevblogaday.com" type="rss" xmlUrl="http://feeds.feedburner.com/idevblogaday"/>
javascript: alert($('#_ctl3_uphone_uphwl').css('color'))
@andrei512
andrei512 / gist:6306023
Created August 22, 2013 11:22
The true Objective-C singleton
+ (id)alloc {
static dispatch_once_t onceToken;
static SettingsViewController *singleton = nil;
dispatch_once(&onceToken, ^{
singleton = [super alloc];
});
return singleton;
}
- (id)init {
@andrei512
andrei512 / metamacros.c
Created September 9, 2013 19:11
metamacros 101 :P
/**
* Macros for metaprogramming
* ExtendedC
*
* Copyright (C) 2012 Justin Spahr-Summers
* Released under the MIT license
*/
#ifndef EXTC_METAMACROS_H
#define EXTC_METAMACROS_H
@andrei512
andrei512 / APRuntime.json
Last active December 22, 2015 18:09
runtime_doc.rb
[
{
"name": "class_addIvar",
"abstract": "Adds a new instance variable to a class. ",
"abstract_xml": "<p class=\"abstract\">Adds a new instance variable to a class. </p>\n",
"declaration": "\nBOOL class_addIvar(Class cls, const char *name, size_t size, uint8_t alignment, const char *types)\n",
"declaration_xml": "<pre class=\"declaration\">\nBOOL class_addIvar(Class cls, const char *name, size_t size, uint8_t alignment, const char *types)\n</pre>\n",
"return_value": "Return ValueYES if the instance variable was added successfully, otherwise NO (for example, the class already contains an instance variable with that name).",
"return_value_xml": "<div class=\"return_value\">\n<h5 class=\"tight\">Return Value</h5>\n<p><code>YES</code> if the instance variable was added successfully, otherwise <code>NO</code> (for example, the class already contains an instance variable with that name).</p>\n</div>",
"api_discussion": "DiscussionThis function may only be called after objc_allocat