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);
@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);
@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");
@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
},
@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);
IFS=$'\n'
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${PROJECT_DIR}/${INFOPLIST_FILE}")
versionNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${PROJECT_DIR}/${INFOPLIST_FILE}")
PATH=${PATH}:/usr/local/bin
function checkFileExists () {
if [[ ! -e "$1" ]]; then
echo "Required file unable to be found: $1"
exit 1
fi
@asiviero
asiviero / child_window.js
Created November 7, 2013 01:43
Open a child window on Alloy/Titanium
$.child_window.open();
@arnoappenzeller
arnoappenzeller / appbuilders_2016_slides
Last active May 11, 2016 06:44
Link to all slides from App Builders 2016 (On going)
https://speakerdeck.com/jpsim/sourcekit-and-you ("SourceKit and you" by @jpsim)
https://speakerdeck.com/icanzilb/appbuilders-non-technical-ways-to-be-a-better-developer ("Non-technical ways to be a better developer" by @icanzlib)
https://speakerdeck.com/cesarvaliente/refactoring-wunderlist-for-android-episode-i-the-presentation-layer ("Refactoring Wunderlist for Android" by @CesarValiente)
https://speakerdeck.com/akosma/being-a-developer-after-40 ("Being a developer after 40" Medium Post:https://speakerdeck.com/akosma/being-a-developer-after-40 by @akosma)
http://seriot.ch/resources/talks_papers/20160426_error_handling.pdf ("Error Handling" by @nst021)
https://speakerdeck.com/vixentael/upgrading-approaches-to-the-secure-mobile-architectures ("Upgrading approaches to the secure mobile architecture" by @vixental)
http://de.slideshare.net/JohnSundell/dynamic-native-backenddriven-uis-app-builders-2016 ("Dynamic, native, backend-driven UIs" by @johnsundell)
https://speakerdeck.com/smashingmag/dirty-tricks-from-the
@thebrankoo
thebrankoo / TBAsyncOperation.swift
Last active June 14, 2016 15:19
Simple custom NSOperation subclass that handles piece of work with completion block
import UIKit
typealias TBAsyncBlock = (completionHandler: dispatch_block_t ) -> Void
class TBAsyncOperation: NSOperation {
private var block : TBAsyncBlock!
private var _executing : Bool = false
override var executing : Bool {
@DenTelezhkin
DenTelezhkin / gist:beab675d853fcd2fd464
Created July 22, 2014 15:02
Multipart-form PUT request for image upload. NSURLSession, iOS 7
+(void)uploadUserPhoto:(UIImage *)image
success:(void (^)(void))success
failure:(FailureBlock)failure
{
GTSessionManager * manager = [GTSessionManager manager];
NSString* tmpFilename = [NSString stringWithFormat:@"%f", [NSDate timeIntervalSinceReferenceDate]];
NSURL* tmpFileUrl = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:tmpFilename]];
NSString * query = [NSString stringWithFormat:@"%@user?auth_token=%@",[manager.baseURL absoluteString],[[UserManager shared] authToken]];