Quitar tildes a una cadena

private function quitar_tildes($cadena) {
        
        $no_permitidas= array ("á","é","í","ó","ú","Á","É","Í","Ó","Ú","ñ","À","Ã","Ì","Ò","Ù","Ù","à ","è","ì","ò","ù","ç","Ç","â","ê","î","ô","û","Â","Ê","ÃŽ","Ô","Û","ü","ö","Ö","ï","ä","«","Ò","Ï","Ä","Ë");
        $permitidas= array ("a","e","i","o","u","A","E","I","O","U","n","N","A","E","I","O","U","a","e","i","o","u","c","C","a","e","i","o","u","A","E","I","O","U","u","o","O","i","a","e","U","I","A","E");
        $texto = str_replace($no_permitidas, $permitidas ,$cadena);
        
        return $texto;
        
    }

$nuevaCadena = quitar_tildes($cadena);

 

Google URL Shortener

Acortar URLs.

  • Petición: https://www.googleapis.com/urlshortener/v1/url?key=API_KEY
  • Parámetro longURL con la URL a acortar

JSON obtenido:

{
    id = "https://goo.gl/C5ZWB2";
    kind = "urlshortener#url";
    longUrl = "https://github.com/copanonga";
}

Petición:

-(void)getURLShortener {
    
    // URL: https://www.googleapis.com/urlshortener/v1/url?key=API_KEY
    
    NSString *URL_BASE = [NSString stringWithFormat:@"https://www.googleapis.com/urlshortener/v1/url?key="];
    NSString *API_KEY = [NSString stringWithFormat:@"API_KEY"];
    NSString *URL = [NSString stringWithFormat:@"%@%@",URL_BASE, API_KEY];
    
    NSString *longURL = [NSString stringWithFormat:@"https://github.com/copanonga"];
    
    NSArray *campos = [NSArray arrayWithObjects:@"longUrl",nil];
    NSArray *valores = [NSArray arrayWithObjects:longURL, nil];
    NSDictionary *parametros = [NSDictionary dictionaryWithObjects:valores forKeys:campos];
    
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    
    [manager POST:URL parameters:parametros progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        NSError* error;
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:responseObject
                                                           options:0
                                                             error:&error];
        
        NSDictionary* json = [NSJSONSerialization
                              JSONObjectWithData:jsonData
                              options:kNilOptions
                              error:&error];
        
        NSLog(@"JSON: %@", json);
        NSLog(@"Short URL: %@", [json objectForKey:@"id"]);
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSLog(@"Error getURLShortener: %@", error);
    }];
    
}

Código completo: https://github.com/copanonga/GoogleURLShortener

Pulsar botón y modificar estado del led

Componentes:

  • Arduino
  • Push button
  • Resistencia de 220 ohm

Código fuente:

int pushButton = 7;
int ledPin = 13;

void setup(){
   Serial.begin(9600);
   pinMode(ledPin, OUTPUT);
   pinMode(pushButton,INPUT);
}

void loop(){
  
   Serial.println( );

   if(digitalRead(pushButton) == HIGH) {
      Serial.println("Button 1");
      digitalWrite(ledPin, LOW);
   } else {
      Serial.println("Button 0");
      digitalWrite(ledPin, HIGH);
   }

   delay(200);
  
}