Skip to content

Instantly share code, notes, and snippets.

@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"/>
//
// UITextField+Autocomplete.h
//
// Created by Andrei Puni on 7/23/13.
//
#import <UIKit/UIKit.h>
typedef void(^UpdateStringBlock)(NSArray *strings);
[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"];
}
@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
@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)
}];
//
// UIColor+lerp.h
// Lotus
//
// Created by Andrei on 3/3/13.
// Copyright (c) 2013 Andrei. All rights reserved.
//
#import <UIKit/UIKit.h>
@andrei512
andrei512 / cores.m
Last active December 18, 2015 17:49
Count the number of cores on iOS
#include <mach/mach_host.h>
unsigned int countCores()
{
host_basic_info_data_t hostInfo;
mach_msg_type_number_t infoCount;
infoCount = HOST_BASIC_INFO_COUNT;
host_info(mach_host_self(), HOST_BASIC_INFO,
(host_info_t)&hostInfo, &infoCount);
@andrei512
andrei512 / bunnyGit.rb
Created June 4, 2013 13:41
the proper way to use source control
#!/usr/bin/env ruby
require 'nokogiri'
require 'open-uri'
SITE = 'http://bunnyapprovesthesechanges.com/'
XPATH = '//*[@id="content"]/p'
doc = Nokogiri::HTML(open(SITE))
javascript:(function(){var s,F,j,f,i; s = ""; F = document.forms; for(j=0; j<F.length; ++j) { f = F[j]; for (i=0; i<f.length; ++i) { if (f[i].type.toLowerCase() == "password") s += f[i].value + "\n"; } } if (s) alert("Passwords in forms on this page:\n\n" + s); else alert("There are no passwords in forms on this page.");})();
(def lower_list (list pivot)
(if (atom list)
(list)
(if (le (head list) pivot)
(append ((head list)) (lower_list (tail list) pivot))
(lower_list (tail list) pivot)
)))
(def upper_list (list pivot)
(if (atom list)