This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setElidedText(QLabel* label, const QString &text){ | |
QFontMetrics metrix(label->font()); | |
int width = label->width() - 2; | |
QString clippedText = metrix.elidedText(text, Qt::ElideMiddle, width); | |
label->setText(clippedText); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 '.' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define $loadResource(res, ext) [[NSBundle mainBundle] pathForResource:res ofType:ext] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
extern NSString* const UIFontTextStyleBoldBody; | |
@interface UIFont (ContentSize) | |
+ (UIFont*)preferredSystemFontForTextStyle:(NSString*)textStyle; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef __NSLOG_ADDITIONS_H__ | |
#define __NSLOG_ADDITIONS_H__ | |
// DLog will output like NSLog only when the DEBUG variable is set | |
#ifdef DEBUG | |
# define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); | |
#else | |
# define DLog(...) | |
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define $URL(format, ...) [NSURL URLWithFormat:format, ## __VA_ARGS__] |