Skip to content

Instantly share code, notes, and snippets.

View priore's full-sized avatar

Priore priore

View GitHub Profile
@priore
priore / gist:7163594
Created October 25, 2013 23:50
Convert picture in to Objctive-C source code
# Convert picture in to Objctive-C source code.
# for example, to include an image in a static library.
# original post : http://t.co/JqZmPyg4 @adnanced
#
# First step :
# 1. Create a text file named pic2code.sh, and save it in your Documents folder.
# 2. In the content of new text file, write script below:
#!/bin/sh
echo "// Byte array generated from file $1"
@priore
priore / gist:7163603
Created October 25, 2013 23:51
Facebook Token to exchange app information
// Facebook Token to exchange app information.
// Can use the token to authenticate an application for a web service.
//
// Created by Danilo Priore on 27/11/12.
+ (NSString*)getAppAccessTokenWithAppId:(NSString*)appId cosumerSecret:(NSString*)secret
{
// get application access token
NSString *link = [NSString stringWithFormat:@"https://graph.facebook.com/oauth/access_token?client_id=%@&client_secret=%@&grant_type=client_credentials", appId, secret];
NSURL *url = [NSURL URLWithString:link];
@priore
priore / gist:7163607
Created October 25, 2013 23:52
Get file list with NSPredicate
// get file list with NSPredicate
NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
NSFileManager *fm = [NSFileManager defaultManager];
NSArray *dirContents = [fm contentsOfDirectoryAtPath:bundlePath error:nil];
NSPredicate *fltr = [NSPredicate predicateWithFormat:@"self like '*.jpeg'"];
NSArray *fileNames = [[dirContents filteredArrayUsingPredicate:fltr] retain];
@priore
priore / gist:7163626
Created October 25, 2013 23:53
Add text to UIImage
//
// Created by Danilo Priore on 18/08/12.
// Copyright (c) 2012 Prioregroup.com. All rights reserved.
//
- (UIImage*)addTextToImage:(UIImage*)img text:(NSString*)text1 XPos:(int)xpos YPos:(int)ypos fontName:(NSString*)fontName fontSize:(CGFloat)fontSize fontColor:(UIColor*)fontColor {
int w = img.size.width;
int h = img.size.height;
@priore
priore / gist:7163627
Created October 25, 2013 23:54
Generate random password from GUID
// generate random password from GUID
string password = string.Empty;
string guid = Guid.NewGuid().ToString().Replace("-", string.Empty);
Random random = new Random(DateTime.Now.Millisecond);
for (int i = 0; i < 8; i++)
password += guid.Substring(random.Next(0, guid.Length - 1), 1);
@priore
priore / gist:7163631
Created October 25, 2013 23:54
DataReader AsEnumerable (LINQ) with fields name
// create a static class
public static class DataReaderExtension
{
public static IEnumerable<Dictionary<string, object>> AsEnumerable(this System.Data.IDataReader source)
{
if (source == null)
throw new ArgumentNullException("source");
while (source.Read())
{
@priore
priore / gist:7163636
Created October 25, 2013 23:55
cocos2d: menu level in Angry Birds style
//
// Created by Danilo Priore on 10/06/12.
// Copyright 2012 Prioregroup.com. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@priore
priore / gist:7163642
Created October 25, 2013 23:56
Add a gift shop to your ASP.NET application
// With MYZazzleStore Library for ASP.NET it's really simple to add a gift shop to your ASP.NET 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.
//
// look for source code : https://github.com/priore/MYZazzleStore-for-ASP.NET
//ASP.NET page
<%@ Register Assembly="Priore.Web.MYZazzleStore"
@priore
priore / gist:7163646
Created October 25, 2013 23:56
Add a gift shop to your iOS application
// With MYZazzleStore SDK 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.
MYZazzleStore myStore = [[MYZazzleStore alloc] initWithFrame:CGRectMake(0, 50, 320, 410)];
myStore.imageLink = @"http://www.my-domain.com/my-image.png";
// your Zazzle ID, this will allow you to earn referral on purchases (optional)
myStore.accountId = 1234567890;
[myStore reload];
@priore
priore / gist:7163654
Created October 25, 2013 23:58
Get binary files from SQL
--
-- Created by Danilo Priore.
-- Copyright (c) 2012 Prioregroup.com. All rights reserved.
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions: