iOS Simulator + Charles Web Debugging Proxy

Um SSL Datenverkehr aus dem iOS Simulator auf dem Charles Web Debugging Proxy zu monitoren muss das Charles Zertifikat auf dem Simulator als „vertrauenswürdig“ eingestellt werden.

Dafür speichert man das Zertifikat auf dem Rechner und zieht es danach auf den Simulator

Wichtig: Wenn das Zertifikat abgelaufen Seitn sollte, muss man über „Reset Charles Root Certificate…“ im gleichen Menü ein neues erstellen und auf alle Clients aktualisieren!

PHP MP4 Video für Safari ausliefern

Safari spielt Videos, welche man plain versucht auszugeben, nicht ab. Das scheint mit der Pufferung zu tun zu haben. Dafür funktioniert folgendes Skript:

$fp = fopen($filepath, "rb");
    $size = filesize($filepath);
    $length = $size;
    $start = 0;
    $end = $size - 1;
    header('Content-type: video/mp4');
    header("Accept-Ranges: 0-$length");
    if (isset($_SERVER['HTTP_RANGE'])) {
        $c_start = $start;
        $c_end = $end;
        list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2);

        if (strpos($range, ',') !== false) {
            header('HTTP/1.1 416 Requested Range Not Satisfiable');
            header("Content-Range: bytes $start-$end/$size");
            exit;
        }

        if ($range == '-') {
            $c_start = $size - substr($range, 1);
        } else {
            $range = explode('-', $range);
            $c_start = $range[0];
            $c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] : $size;
        }

        $c_end = ($c_end > $end) ? $end : $c_end;

        if ($c_start > $c_end || $c_start > $size - 1 || $c_end >= $size) {
            header('HTTP/1.1 416 Requested Range Not Satisfiable');
            header("Content-Range: bytes $start-$end/$size");
            exit;
        }

        $start = $c_start;
        $end = $c_end;
        $length = $end - $start + 1;
        fseek($fp, $start);
        header('HTTP/1.1 206 Partial Content');
    }

    header("Content-Range: bytes $start-$end/$size");
    header("Content-Length: ".$length);

    $buffer = 1024 * 8;

    while(!feof($fp) && ($p = ftell($fp)) <= $end) {
        if ($p + $buffer > $end) {
            $buffer = $end - $p + 1;
        }
        set_time_limit(0);
        echo fread($fp, $buffer);
        flush();
    }

    fclose($fp);
    exit;Code-Sprache: PHP (php)

Quelle

Entfernung über SQL

Über die Haversine Formel kann man sich für latitude und longitude Werte die Entfernung per SQL ausrechnen lassen:

SELECT *, (((acos(sin(([LATITUDE]*pi()/180)) * sin((`lat`*pi()/180)) + cos(([LATITUDE]*pi()/180)) * cos((`lat`*pi()/180)) * cos((([LONGITUDE]- `lng`) * pi()/180)))) * 180/pi()) * 60 * 1.1515 * 1.609344) as distance
FROM [TABLE] HAVING distance<4 ORDER BY distance

MySQL Connect funktioniert nicht mit SequelPro

  • Configuration liegt unter/usr/local/etc/my.cnf
  • Go to my.cnf file and in section [mysqld] add line:default-authentication-plugin=mysql_native_password
  • Login to mysql server from terminal: run mysql -u root -p, then inside shell execute this command (replacing [password] with your actual password):ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '[password]';
  • exit from mysql shell with exit and run brew services restart mysql.

 

Quelle

Git Merge Branches

git checkout better_branch
git merge --strategy=ours master # keep the content of this branch, but record a merge
git checkout master
git merge better_branch # fast-forward master up to the merge

Um die Historie besser nachvollziehen zu können:

git merge --strategy=ours --no-commit master
git commit # add information to the template merge message

Quelle: Stackoverflow

System.Net.WebException: „Die Anfrage wurde abgebrochen: Es konnte kein geschützter SSL/TLS-Kanal erstellt werden..“

Sofern die Software auf älteren Systemen als Windows 10 verwendet wird, muss aktiv C#-Code:

ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

gesetzt werden, denn der default Type des Protokolls setzt das Betriebssystem – und .NET verwendet dann das default gesetzte.

 

Quelle: mycsharp.de