Skip to content

Instantly share code, notes, and snippets.

View fmundaca's full-sized avatar

Felipe Mundaca fmundaca

View GitHub Profile
#define MINIMUM_ZOOM_ARC 0.003 //approximately 1 miles (1 degree of arc ~= 69 miles)
#define ANNOTATION_REGION_PAD_FACTOR 1.1
#define MAX_DEGREES_ARC 360
+(MKCoordinateRegion)adjustZoomMapView:(NSArray*) locations {
int count = [locations count];
MKMapPoint points[count]; //C array of MKMapPoint struct
for( int i=0; i<count; i++ ) //load points C array by converting coordinates to points
[_mapView setRegion:[_mapView regionThatFits:[self adjustZoomMapView:locationPoints]] animated:YES];
@fmundaca
fmundaca / ModelExample
Last active December 12, 2015 01:38
Example of a Models
var Colaborators = new Schema({
rut : {type: String, unique: true, index: true }
,name : {type: String }
});
var Enterprises = new Schema({
icono : String
,identifier : {type: String, unique: true, index: true }
,name : {type: String, unique: true, index: true }
,description : String
models.Enterprises.find({'colaborators.rut':userRut}, callback);
models.Enterprises.find({'colaborators.rut':userRut}, "colaborators", callback);
@fmundaca
fmundaca / gist:4758078
Created February 11, 2013 22:10
Poner una imágen como título de una UINavigationBar
// Create your image
UIImage *image = [UIImage imageNamed: @"logo.png"];
UIImageView *imageview = [[UIImageView alloc] initWithImage: image];
// set the text view to the image view
self.navigationItem.titleView = imageview;
@fmundaca
fmundaca / gist:4771335
Last active December 12, 2015 12:19
Ejecutar un bloque de código con un pequeño delay.
// NSObject+PWObject.h
#import <Foundation/Foundation.h>
@interface NSObject (PWObject)
- (void)performBlock:(void (^)(void))block afterDelay:(NSTimeInterval)delay;
@end
/* NSObject+PWObject.m */
- (BOOL)isValidLocation:(CLLocation *)newLocation
withOldLocation:(CLLocation *)oldLocation
{
// Filter out nil locations
if (!newLocation)
{
NSLog(@"No es valido newLocation is Nil");
return NO;
}
@fmundaca
fmundaca / gist:5416408
Last active December 16, 2015 09:58
pollo's question
public function insertarNuevoTicket($usuario=null, $servicio=null, $componente=null, $finicio=null, $descripcion=null, $tipo_ticket=null, $nuevo_id=null) {
$stm=$this->pdo->prepare("INSERT INTO tickets VALUES( ".$nuevo_id.", '".$usuario."', '".$descripcion."', ".$tipo_ticket.", now(), ".$servicio.", ".$componente.", timestamp IS NULL, 0, 1, 0, 0);"); $query = "INSERT INTO tickets VALUES( ".$nuevo_id.", '".$usuario."', '".$descripcion."', ".$tipo_ticket.", now(), ".$servicio.", ".$componente.", NULL, 0, 1, 0, 0)";
echo "<br>".$query."<br>";
$stm->execute();
$row=0;
$row=$stm->rowCount();
return $row;
}
@fmundaca
fmundaca / gist:3cc60b861160c55437e4
Last active August 29, 2015 14:16
Algoritmo resuelto
function playing(list,times){
var newArray = [];
var x = 0;
for(i=0;i<list.length;i++){
// console.log(list.length);
if(times > 0){
if(list.length%2 == 1){
// impar debemos eliminar desde el 0