Skip to content

Instantly share code, notes, and snippets.

View OdNairy's full-sized avatar

Roman Gardukevich OdNairy

View GitHub Profile
@OdNairy
OdNairy / gist:4635181
Created January 25, 2013 15:21
Rotation 4 iOS 6
@implementation UINavigationBar(Rotation)
-(BOOL)shouldAutorotate{
return [[self.viewControllers lastObject] shouldAutorotate];
}
-(NSUInteger)supportedInterfaceOrientations{
return [[self.viewControllers lastObject] supportedInterfaceOrientations];
}
@OdNairy
OdNairy / Object.m
Created February 20, 2013 21:34
NSObject source code
/*
* Copyright (c) 1999-2007 Apple Inc. All Rights Reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
@OdNairy
OdNairy / NSObject.mm
Created February 20, 2013 21:44
NSObject.mm from 10.8.3
/*
* Copyright (c) 2010-2012 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
@OdNairy
OdNairy / S.cpp
Created February 21, 2013 06:59
Fucking test on exam
class S{
public:
static int i;
S(){++i;}
S(const S& ob){++i;}
};
int S::i = 0;
int main(int argc, char* argv[]){
@OdNairy
OdNairy / habr_40404.rb
Last active December 15, 2015 18:38
Ruby-скрипт для фоловинга 40404-ым =)
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'twitter'
require File.join(File.dirname(__FILE__), 'apn.rb')
Twitter.configure do |config|
@OdNairy
OdNairy / gist:5575157
Created May 14, 2013 10:59
Реализация retain
- (id)retain
__attribute__((aligned(16)))
{
if (OBJC_IS_TAGGED_PTR(self)) return self;
SideTable *table = SideTable::tableForPointer(self);
if (OSSpinLockTry(&table->slock)) {
table->refcnts[DISGUISE(self)] += 2;
OSSpinLockUnlock(&table->slock);
#include <iostream>
using namespace std;
class A{
protected:
int i;
public:
#import <iostream>
using namespace std;
class S{
public:
static int i;
S(){++i;}
S(const S& ob){++i;}
};
@OdNairy
OdNairy / main.m
Last active December 21, 2015 00:28
// Source: https://devforums.apple.com/message/866487#866487
typedef int (*PYStdWriter)(void *, const char *, int);
static PYStdWriter _oldStdWrite;
int __pyStderrWrite(void *inFD, const char *buffer, int size)
{
if ( strncmp(buffer, "AssertMacros: queueEntry", 24) == 0 ) {
return 0;
@OdNairy
OdNairy / gist:7547418
Created November 19, 2013 15:48
Autoincrement
cd $SRCROOT
bN=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
bN=$((0x$bN))
bN=$(($bN + 1))
bN=$(printf "%X" $bN)
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $bN" "$INFOPLIST_FILE"