Skip to content

Instantly share code, notes, and snippets.

View andrey-str's full-sized avatar

Andrey Streltsov andrey-str

View GitHub Profile
@andrey-str
andrey-str / UIColor+Hex.h
Last active August 29, 2015 14:12
Convert hex color to UIColor
//
// UIColor+Hex.h
// Gists
//
// Created by Andrey Streltsov on 24 Dec 2014.
// Copyright (c) 2014 Scopicsoftware. All rights reserved.
//
#import <UIKit/UIKit.h>
@andrey-str
andrey-str / NSString+Additions.h
Created December 25, 2014 09:14
String with format macros
#define $S(format, ...) [NSString stringWithFormat:format, ## __VA_ARGS__]
@andrey-str
andrey-str / NSURL+Additions.h
Created December 25, 2014 09:16
NSURL with format [Macros]
#define $URL(format, ...) [NSURL URLWithFormat:format, ## __VA_ARGS__]
@andrey-str
andrey-str / UIFont+ContentSize.h
Created December 25, 2014 09:42
UIFont + Custon font with Dynamic Sizes
#import <UIKit/UIKit.h>
extern NSString* const UIFontTextStyleBoldBody;
@interface UIFont (ContentSize)
+ (UIFont*)preferredSystemFontForTextStyle:(NSString*)textStyle;
@end
@andrey-str
andrey-str / loadres_mac.h
Created January 7, 2015 10:53
Convinient macroses for resources loading
#define $loadResource(res, ext) [[NSBundle mainBundle] pathForResource:res ofType:ext]
@andrey-str
andrey-str / CMRotationMatrix+SCNQuaternion.mm
Last active August 29, 2015 14:14
a bit of quaternions algebra;
SCNQuaternion CalculateRotation(CMRotationMatrix a){
SCNQuaternion q;
float trace = a.m11 + a.m22 + a.m33; // I removed + 1.0f; see discussion with Ethan
if( trace > 0 ) { // I changed M_EPSILON to 0
float s = 0.5f / sqrtf(trace + 1.0f);
q.w = 0.25f / s;
q.x = ( a.m32 - a.m23 ) * s;
q.y = ( a.m13 - a.m31 ) * s;
#!/bin/bash
# https://gist.github.com/949831
# http://blog.carbonfive.com/2011/05/04/automated-ad-hoc-builds-using-xcode-4/
# command line OTA distribution references and examples
# http://nachbaur.com/blog/how-to-automate-your-iphone-app-builds-with-hudson
# http://nachbaur.com/blog/building-ios-apps-for-over-the-air-adhoc-distribution
# http://blog.octo.com/en/automating-over-the-air-deployment-for-iphone/
# http://www.neat.io/posts/2010/10/27/automated-ota-ios-app-distribution.html
@andrey-str
andrey-str / isup.py
Last active August 29, 2015 14:17 — forked from andrix/isup.py
#!/usr/bin/env python
import re
import sys
from urllib import urlopen
def isup(domain):
resp = urlopen("http://www.isup.me/%s" % domain).read()
return "%s: %s" % (domain, "UP" if re.search("It's just you.", resp,
re.DOTALL) else "DOWN")
@andrey-str
andrey-str / lldb_qt.py
Last active August 29, 2015 14:23 — forked from wmanth/lldb_qt.py
import lldb
def __lldb_init_module(debugger, internal_dict):
debugger.HandleCommand('type summary add QString -F lldb_qt.QString_summary')
debugger.HandleCommand('type summary add QUuid -F lldb_qt.QUuid_summary')
print 'lldb_qt.py has been loaded and is ready for use.'
def QString_summary(value, internal_dict):
name = value.GetName()
deref = '->' if value.TypeIsPointerType() else '.'
@andrey-str
andrey-str / datediff.mm
Last active August 29, 2015 14:28
Absolute time to relative time(e.g. 2 days ago)
QString dateDiff(const QString&origDate) {



NSDateFormatter* df = [$CE dateFormatter]; 

NSDate *convertedDate = [df dateFromString:origDate.toNSString()]; 


NSDate *todayDate = [NSDate date]; 

double ti = [convertedDate timeIntervalSinceDate:todayDate]; 

ti = ti * -1;