This file contains 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
<?php | |
// IMPORTANT: this is a reduced version of ezdb1.php | |
// Its purpose is SPEED, only SPEED, use ezdb1.php if you want debug information. | |
// YOU HAVE BEEEN WARNED. | |
// -- ricardo galli | |
// | |
// ================================================================== | |
// Author: Justin Vincent (justin@visunet.ie) | |
// Web: http://php.justinvincent.com | |
// Name: ezSQL |
This file contains 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
<?php | |
class HZip | |
{ | |
/** | |
* Add files and sub-directories in a folder to zip file. | |
* @param string $folder | |
* @param ZipArchive $zipFile | |
* @param int $exclusiveLength Number of text to be exclusived from the file path. | |
*/ |
This file contains 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
1.- Evitar la creación innecesaria de objetos, Lazy Initialitation | |
La creación de objetos en Java es una de las operaciones mas costosas en términos de uso de memoria e impacto en el performance. Esto es evitable creando o inicializando objetos solo en el momento en que serán requeridos en el código. | |
public class Paises { | |
private List paises; | |
public List getPaises() { | |
//se inicializa solo cuando es requerido |
This file contains 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 urllib2 | |
for i in range(5000): | |
name = str(i) + '.png' | |
try: | |
url = 'http://www.example.com/%s' % name | |
response = urllib2.urlopen(url) | |
output = open('folder/' + name, 'wb') | |
output.write(response.read()) | |
output.close() |
This file contains 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
NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"database.db"]; | |
FMDatabase *database = [FMDatabase databaseWithPath:path]; | |
[database open]; | |
[database executeUpdate:@"INSERT INTO table (field1, field2) VALUES (?, ?)", value1, value2]; | |
[database close]; |
This file contains 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
// version 1 | |
- (UIImage *)imageWithImage:(UIImage *)image scaledToFillSize:(CGSize)size | |
{ | |
CGFloat scale = MAX(size.width / image.size.width, size.height / image.size.height); | |
CGFloat width = image.size.width * scale; | |
CGFloat height = image.size.height * scale; | |
CGRect imageRect = CGRectMake((size.width - width)/2.0f, (size.height - height)/2.0f, width, height); | |
UIGraphicsBeginImageContextWithOptions(size, NO, 0); | |
[image drawInRect:imageRect]; |
This file contains 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)saveImage:(UIImage *)image | |
{ | |
if (image != nil) { | |
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); | |
NSString *documentsDirectory = [paths objectAtIndex:0]; | |
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"test.png"]; | |
NSData *data = UIImagePNGRepresentation(image); | |
[data writeToFile:path atomically:YES]; | |
} | |
} |
This file contains 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
- (UIImageView *)loadImageWithUrl:(NSString *)stringUrl | |
{ | |
UIImageView *imageView = [[UIImageView alloc] init]; | |
NSURL *url = [NSURL URLWithString:stringUrl]; | |
NSURLRequest *request = [NSURLRequest requestWithURL:url]; | |
UIImage *placeholder = [UIImage imageNamed:@"placeholder"]; | |
__weak UIImageView *weakImageView = imageView; | |
[imageView setImageWithURLRequest:request placeholderImage:placeholder success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) { |
This file contains 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
// set delegate on header file | |
// <UINavigationControllerDelegate, UIImagePickerControllerDelegate> | |
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo | |
{ | |
// set on a UIImageView | |
self.selectedImage.image = image; | |
[self dismissModalViewControllerAnimated:YES]; | |
} |
This file contains 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
view.layer.cornerRadius = 5.0f; | |
view.layer.masksToBounds = YES; |
OlderNewer