Skip to content

Instantly share code, notes, and snippets.

View dimohamdy's full-sized avatar
🏠
Working from home

Dimo Hamdy dimohamdy

🏠
Working from home
View GitHub Profile
@hramos
hramos / CGRectPrintFrame
Created December 27, 2010 19:34
Print CGRect frame to console
#define PrintFrame(frame) NSLog(@"F X:%f Y:%f W:%f H:%f", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);

Objective-C Coding Convention and Best Practices

Most of these guidelines are to match Apple's documentation and community-accepted best practices. Some are derived some personal preference. This document aims to set a standard way of doing things so everyone can do things the same way. If there is something you are not particularly fond of, it is encouraged to do it anyway to be consistent with everyone else.

This document is mainly targeted toward iOS development, but definitely applies to Mac as well.

Operators

NSString *foo = @"bar";
@mcongrove
mcongrove / TiDrop.js
Created April 1, 2011 22:13
A quick and simple example of how to do drag+drop in Titanium
var TiDrop = {
touching: false,
position: {
elementYStart: 0,
elementXStart: 0,
yStart: 0,
xStart: 0,
yCurrent: 0,
xCurrent: 0
},
@shazron
shazron / gist:943736
Created April 27, 2011 04:55
About XCode 4 Project Template (How To Create Custom Project Template)
From: http://snipt.net/yonishin/about-xcode-4-project-template
XCode 4 Projects and Files Template Folder: /Developer/Library/Xcode/Templates
Examples:
/Developer/Library/Xcode/Templates/Project Templates/Base/Other/Empty.xctemplate
/Developer/Library/Xcode/Templates/Project Templates/Base/Base.xctemplate
/Developer/Library/Xcode/Templates/Project Templates/Mac/Mac Base.xctemplate
/Developer/Library/Xcode/Templates/Project Templates/Mac/Application/Command Line Tool.xctemplate
/Developer/Library/Xcode/Templates/Project Templates/Mac/Application/Cocoa Application.xctemplate
@mattheworiordan
mattheworiordan / drag.js
Created July 9, 2011 18:12
Drag and drop example for Titanium
var circle = Titanium.UI.createView({
height:200,
width:200,
borderRadius:50,
backgroundColor:'#336699',
top:10,
left:50
});
currentWindow.add(circle);
@sbhimavarapuAppc
sbhimavarapuAppc / app.js
Created September 29, 2011 18:47
Custom fonts in Webview - Android
// Make sure you have your custom font-file under Resources/fonts
var webview = Ti.UI.createWebView({
url: 'local_webview.html'
});
var window = Ti.UI.createWindow();
window.add(webview);
@ziggythehamster
ziggythehamster / 01.md
Created November 30, 2011 22:30
@ziggythehamster's #Titanium #Sucks Proofs

@Appcelerator #Titanium #Sucks no. 1: Child view wider than a parent view breaks out of the parent. It should get cut off by the parent.

Diagram

If you have a box that's 40x40, and position another 40x40 box within it, with top=20 and left=20, you expect to see a 40x40 box containing a 20x20 box, not two 40x40 boxes.

Titanium sucks because...

If you put a view within a view on any widget toolkit, HTML, etc. and then move the subview around within its parent, the subview should never extend beyond the boundaries of its parent. That is, it should be clipped by its parent. At least by default. This is all OK if it's supposed to work this way, but several Q&A posts suggest this exact method as a way to crop a photo. So did it get broken at some point? Are there not unit tests to determine when behavior like this is reversed? Is some way that I'm inserting this view causing it not to work consistently? Why do I see code that is exactly equal to mine

@benbahrenburg
benbahrenburg / Sample 2
Created January 30, 2012 01:02
Referencing the bencoding.network module
Ti.API.info("Create a new Carrier Info Object");
var carrierInfo = benCodingNetwork.createCarrierInfo();
Ti.API.info("Get carrier name => " + carrierInfo.carrierName);
Ti.API.info("Get mobile country code => " + carrierInfo.mobileCountryCode);
Ti.API.info("Get mobile network code => " + carrierInfo.mobileNetworkCode);
Ti.API.info("Get ISO country code for cellular service provider => " + carrierInfo.isoCountryCode);
Ti.API.info("Mobile service provider supports VOIP => " + carrierInfo.allowsVOIP);
@iamleeg
iamleeg / main.mm
Created March 24, 2012 00:23
Using operator overloading with Objective-C. Erm, ++.
#include "objc_id.hpp"
int main(int argc, const char * argv[])
{
@autoreleasepool {
NSString *s1 = @"hello";
NSString *s2 = [@"hell" stringByAppendingString: @"o"];
if ((objc_id(s1) == objc_id(s2))) {
NSLog(@"win");
@raulriera
raulriera / PagingControl.js
Created April 19, 2012 02:13
Custom paging control for scrollableViews for Titanium Appcelerator
// I was unhappy about there was close to no control over the "pageControl"
// in scrollableViews, so I hacked my own
// -----
// Configuration
var pageColor = "#c99ed5";
PagingControl = function(scrollableView){
var container = Titanium.UI.createView({
height: 60