Skip to content

Instantly share code, notes, and snippets.

View priore's full-sized avatar

Priore priore

View GitHub Profile
@priore
priore / gist:7163531
Created October 25, 2013 23:45
How to use GDC for create a singleton class
+ (id)sharedInstance
{
static dispatch_once_t once;
static id instance;
dispatch_once(&once, ^{
instance = self.new;
});
return instance;
}
@priore
priore / gist:7163533
Created October 25, 2013 23:45
Play Audio Streaming in Backgrund mode
- (void)playAudioStreamingInBacgkroundMode {
// set audio session for background music
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
NSError *setCategoryError = nil;
BOOL success = [audioSession setCategory:AVAudioSessionCategoryPlayback error:&setCategoryError];
if (success) {
NSError *activationError = nil;
@priore
priore / gist:7163536
Created October 25, 2013 23:46
How to load Twitter Timeline Widget in a UIWebView
// 1. Before create a HTML file named mywidget.html and with content :
// <html>
// <head>
// <title></title>
// <script src="http://platform.twitter.com/widgets.js"> </script>
// </head>
// <body>
// <a class="twitter-timeline" height="%i" href="https://mobile.twitter.com/DaniloPriore" data-widget id="318522515175645184" data-chrome="noheader nofooter transparent" data-border-color="#cc0000" style="display:none"> </a>
// </body>
//</html>
@priore
priore / gist:7163541
Created October 25, 2013 23:46
Remove unused characters in a NSString
- (NSString*)removeUnusedCharacters:(NSString*)input
{
NSCharacterSet *doNotWant = [NSCharacterSet characterSetWithCharactersInString:@"ÀÁÂÃÄâãäàÈÉÊËêëÌÍÎÏîïíÒÓÔÕÖôõöóÙÚÛÜûüùÝýñ\\|!\"£$%&/=?^+*°#§;:_`«“‘¥~‹÷´`≠¡ˆ„Ω€®™æ¨œøπ[]åß∂ƒ∞∆ªº¬@¶≤≥<>∑†©√∫˜µ…•–◊{}±¿≈⁄›‰¢’”»ı³"];
return [[[input componentsSeparatedByCharactersInSet: doNotWant] componentsJoinedByString: @""] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
}
@priore
priore / gist:7163546
Created October 25, 2013 23:47
How do I sync files between computers ?
How do I sync files between computers ? (WIN, MAC, LINUX)
Syncing your files between all of your computers, smartphones, and tablets is what Dropbox is all about. All you have to do is install the Dropbox desktop application and sign in using the same login.
If you've already installed Dropbox, simply adding files to your Dropbox folder will automatically sync the file to your Dropbox, which means you can open it from any other computer, smartphone, or tablet that also has Dropbox installed.
If you'd rather sync some files with other people on other Dropbox accounts, that's easy too; just create a shared folder instead.
Install the Dropbox app from http://db.tt/XLEtgM7
@priore
priore / gist:7163549
Created October 25, 2013 23:48
UIWebView transparent and scrollbar hidden
- (void)webViewHideBackgroundAndScrollBar:(UIWebView*)theView {
theView.opaque = NO;
theView.backgroundColor = [UIColor clearColor];
for(UIView *view in theView.subviews) {
if ([view isKindOfClass:[UIImageView class]]) {
// to transparent
[view removeFromSuperview];
}
@priore
priore / gist:7163553
Created October 25, 2013 23:48
Add a Gift Shop with your personalized images
// With MYZazzleStore service it's really simple to add a gift shop to your application for your users.
// With a few lines of code you can give your users the opportunity to purchase T-shirts personalized
// mugs, iphone / ipad covers and other types of gifts. It also allows you to increase financial gains
// and increase the popularity of your products.
//
// Is really very simple to add to your application a gift shop to offer your users.
// With few lines of code you can give your users the opportunity to purchase T-shirts personalized
// mugs, iphone / ipad cover and other types of gifts, also allowing you to add a further financial
// gain and increasing the popularity of your products.
//
@priore
priore / gist:7163556
Created October 25, 2013 23:49
Cocos2D and Google Analytics Category
//
// Created by Danilo Priore on 20/02/13.
// www.prioregroup.com
//
// CCLayer+GoogleAnalytics.h
#import "CCLayer.h"
@interface CCLayer (GoogleAnalytics)
@end
@priore
priore / gist:7163577
Created October 25, 2013 23:49
Fix GameCenter on Cocos2D v2 and iOS 6
// How to fix GameCenter Leaderboard in Landscape mode
// with Cocos2d v.2.0 and iOS6.
//
// Author: Danilo Priore
// http://www.prioregroup.com
//
// 1. Create a personalized UINavigationController
//
// GameNavigationController.h
@interface GameNavigationController : UINavigationController
@priore
priore / gist:7163587
Created October 25, 2013 23:50
Mashape secret code verification (upd)
// updated: 03-04-2013
//
using System.Web;
public static class Mashape // www.mashape.com/priore
{
private static string[] VALID_MASHAPE_ADDR = new string[] { "23.21.64.131", "23.21.68.63", "23.23.86.71", "23.23.87.232", "23.23.103.203", "23.23.103.204", "23.23.103.207", "23.23.103.212", "23.23.103.218", "50.17.255.165" };
public static bool IsValidSecretCode(string secret_code)