Jump to content

SamC

Members
  • Posts

    733
  • Joined

  • Last visited

  • Days Won

    9

Posts posted by SamC

  1. 37 minutes ago, wbmnfktr said:

    Turn off Bluetooth entirely.

    Restart (keep Bluetooth disabled) and watch if behaviour changed.

    I'll try that thanks. Didn't even know it was on tbh, I must have left it on after connecting to Sphero.

    • Like 1
  2. Title says it all really. Is anyone else having trouble with the wifi on OSX Mojave? It's becoming a huge pita, It's fine, then it's super slow, then sometimes it's 'cant connect' on webpages, then it's fine again 5mins later. It just hung on a gIt push and I was like panic mode.

    It looks like some sort of DNS issue but not so good at troubleshooting on OSX. When it goes pear shaped, I check my android phone and the wifi is totally fine, the downstairs desktop (ethernet) is fine also.

    Anyone got any ideas or had similar problems? Thanks.

  3. 1 hour ago, LostKobrakai said:

    This seems to be an index page. Are you sure the error happens on the first item of the collection? In other words did you check all items for that key as you‘ve only posted one here.

    Doh! You're totally right. Just found one right at the end:

    [45] => Array
    (
        [character] => Humpty Dumpty
        [credit_id] => 52fe4cbcc3a36847f823c93b
        [vote_count] => 2
        [video] => 
        [popularity] => 1.49
        [original_language] => en
        [vote_average] => 0.5
        [id] => 167867
        [title] => Happily Ever After: Fairy Tales for Every Child Mother goose big book of Rhymes
        [original_title] => Happily Ever After: Fairy Tales for Every Child Mother goose big book of Rhymes
        [backdrop_path] => 
        [genre_ids] => Array
            (
            )
    
        [adult] => 
        [overview] => Fairy tales have always been a source of family pleasure, for parents and children alike. Now, some of the best-loved classics are being re-told in this vibrantly original and musical animated series, Happily Ever After: Fairy Tales For Every Child. Each tale features a hip, contemporary all-star cast of voices and all-new songs the entire family will enjoy! Classic fairy tales become fresh and fun, told as if for the very first time. So share the magic and wonder with your children as we invite you to enter the wonder-filled world of Happily Ever After. Includes the following Fairy Tales:  Mother Goose, A Rappin' & Rhymin' Special  Pinocchio  The Golden Goose  The Pied Piper
        [poster_path] => /rSJSZiwyAVl165lmRXgNoUp4VWy.jpg
        [custom_image_path] => http://image.tmdb.org/t/p/w185/rSJSZiwyAVl165lmRXgNoUp4VWy.jpg
    )

    How this works is that I query the TMDB with a name (from the form), from that, you get the actor ID, from there the ID is used to get details about the actors, and everything they've starred in/directed etc.... there's no database involved at all (although in the future, I'd like it to build dynamically as the searches happen to cut down on API requests. You can only query 4 times a second at TMDB).

    The results from TMDB don't seem to be very consistent. With this 'release_date' key, it's either:

    1) Exists and has value
    2) Exists but no value
    3) Doesn't exit at all

    I think, based on what I've already said, that I need to check values exist first before doing anything. Thanks @LostKobrakai

  4. So I know this is a PW forum but this is the off topic section so hopefully is ok. I've been learning Laravel for the past couple of weeks and hoping someone can help me out with this, it's driving me nuts! I built a small movie app using a 'diy MVC framework' from a Udemy course which was awesome. Now I'm porting it over to Laravel, and using Guzzle to query TMDB API to see how I can better organise my code (and learn Laravel at the same time). 

    I'm getting an error on the page:

    http://movies.local/movies/list?name=denzel+washington

    ...which is:

    Undefined index: release_date (View: /Users/sam/www/movies.local/resources/views/movies.blade.php)

    ...pointing at this (on the laravel error page):

    <p>Release date: <?php echo e($movie['release_date']); ?></p>

    I'm outputting from my view thus (inside a loop, $movie represents a single movie in an array):

    <pre>
        <?php var_dump($movie); ?>
    </pre>
    
    <h3>{{ $movie['title'] }}</h3> <?php // THIS WORKS ?>
    <p>ID: {{ $movie['id'] }}</p> <?php // AND THIS... ?>
    <p>Release date: {{ $movie['release_date'] }}</p> <?php // THIS LINE IS BAD FOR SOME REASON... ?>
    <p>{{ $movie['overview'] }}</p> <?php // AND THIS... ?>

    ... when I remove the 'Release date' line, the page loads ok and the var_dump() spits out:

    array(17) {
      ["character"]=>
      string(13) "Robert McCall"
      ["credit_id"]=>
      string(24) "5588a41ec3a3683d500009cb"
      ["poster_path"]=>
      string(32) "/cQvc9N6JiMVKqol3wcYrGshsIdZ.jpg"
      ["id"]=>
      int(345887)
      ["video"]=>
      bool(false)
      ["vote_count"]=>
      int(1221)
      ["adult"]=>
      bool(false)
      ["backdrop_path"]=>
      string(32) "/z7noaCJ4KtmhwHw7QcNtnMMo4Qy.jpg"
      ["genre_ids"]=>
      array(3) {
        [0]=>
        int(28)
        [1]=>
        int(80)
        [2]=>
        int(53)
      }
      ["original_language"]=>
      string(2) "en"
      ["original_title"]=>
      string(15) "The Equalizer 2"
      ["popularity"]=>
      float(92.746)
      ["title"]=>
      string(15) "The Equalizer 2"
      ["vote_average"]=>
      float(6.2)
      ["overview"]=>
      string(183) "Robert McCall, who serves an unflinching justice for the exploited and oppressed, embarks on a relentless, globe-trotting quest for vengeance when a long-time girl friend is murdered."
      ["release_date"]=>
      string(10) "2018-07-20"
      ["custom_image_path"]=>
      string(63) "http://image.tmdb.org/t/p/w185/cQvc9N6JiMVKqol3wcYrGshsIdZ.jpg"
    }

    ...so it can be seen quite clearly that the key 'release_date' does in fact exist. And the other keys work ok, and they're on the same level.

    And it gets weirder, if I replace the Blade:

    <p>Release date: {{ $movie['release_date'] }}</p>

    ...with

    <p>Release date: <?= (isset($movie['release_date'])) ? $movie['release_date'] : 'No date'; ?></p>

    ...then everything works fine, the date is output as it should be. But surely I don't need to check each key? I know it exists as the movies listed inside this loop are one that have a release date, it's been checked earlier in the process.

    Like, if I chuck in:

    <p>Rating: {{ $movie['vote_average'] }}</p>
    <p>Credit ID: {{ $movie['credit_id'] }}</p>

    ...then they display ok too.

    What's so special about this 'release_date' key? Or do I have a really huge face palm moment typo that I just can't see?

    Thanks for any advice.

    ps the actual page looks like this (when I use the plain PHP code with isset() check to output the release date):

    78431542_ScreenShot2018-12-11at19_09_42.thumb.png.fffe5ff6aed3081479c9654fdec56142.png

  5. I'm looking to combine two images into a single one and could do with some advice, or just where to start tbh.

    Image 1 (base): 600px x 400px
    Image 2 (will change): 80px x 100px
    Result: Image 3, which is image 1 with image 2 overlayed, offset x,y (50px, 50px from top left)

    Now, I guess I have two options, take image 1, and place image 2 on top of it, or make part of image 1 transparent, and put image 2 underneath. Image 1 will be a base image, and image 2 will change for each new generated image (image 3). Think of galleries of web design that have a macbook 'frame' around images. That sort of thing. I'm not sure a CSS solution would be robust enough here, too many things could go wrong with positioning. So I was looking at physically making a third image from the original two.

    I've read a few posts about using imagemagick and a few using GD but just after suggestions here on how to go about something like this?

    Any advice would be awesome, thanks.

  6. On 12/26/2017 at 10:58 AM, LostKobrakai said:

    I don't think specifically learning jquery is needed anymore. I'd rather try to improve your skills of using plain js, which should result in using jquery being more or less "reading the docs" if you need it.

    6 months later on my journey and I completely agree with this.

    Had to modify some jQuery the other day and it was super easy with a relatively decent background in plain JS now.

  7. After a bit of research, I think this is one rabbit hole I'm not prepared to go down right now. Sticking to laragon on windows and mamp on osx. I'll go back over these suggestions when my current setup doesn't work for me anymore! But for now, my time is better spent carrying on with my programming.

    On 6/1/2018 at 7:41 PM, fbg13 said:

    I like the look of this ^^ though.

    Thanks everyone ?

  8. Thanks for the suggestions, I'll look into these this coming week ? 

    13 hours ago, Doug G said:

    I use a CentOS server hosting KVM virtual machine running CentOS and ispconfig3.  The VM is bridged on to my local LAN.

    Me reading that:
    2cflrq.jpg.ff92e4455674e2a9a9049ab04330b8ac.jpg

    • Like 1
    • Haha 3
  9. I use MAMP on OSX and Laragon on Windows but I've recently been looking at Vagrant and Docker because my life isn't complicated enough and I need more confusion and frustration. Seriously though, what do people here use? Do you have any recommendations and reasons why it would be worth switching from a more 'fixed' environment.

    I've read docker might be less resource hungry but is trickier to get set up but I don't know the truth in this. Bearing in mind this is just localhost stuff for now but in the future, I am more likely to be involved in a team. Well, it's not all localhost, I have two live sites that I need to work on locally.

    I'm comfortable enough in XAMPP, MAMP, WAMP, Laragon etc. but Vargrant/Docker looks like a conceptual switch. I do however like the idea of being able to mimic a production environment.

    I'm also realistic, being 4 months into my JS/PHP learning, is this something that I need right now? Would it be more recommended to stick to the tools I know i.e. just ditch MAMP and try AMPPS. Right now, I'm in a situation where I have nothing on OSX (other than "php -S localhost:8000"). I wanted to install PW and try a few things out which lead me to looking at alternatives.

    Thanks for any advice ?

  10. On 5/6/2018 at 4:46 AM, FrancisChung said:

    My advice is to have a look at the average ratings of the course, compare the score against other courses in the same domain, and also read the user reviews (both good/bad)  and make a decision.

    Yeah, and you can ignore things like "1 star of 5: didn't teach me how to make an facebook clone" in the comments for a 'Learn basic PHP' course.

    On 5/4/2018 at 9:41 PM, FrancisChung said:

    I'll start off with a course on teaching you how to learn. 

    https://www.coursera.org/learn/learning-how-to-learn

    ^ this. I have anxiety which gets much worse without clear direction or when burning out spending hours upon hours on problems without breaks. This course has helped me massively to break up my learning and provided different techniques to use which has made programming fun again and much less stressful for me which is awesome. So glad @FrancisChung recommended this one.

    • Like 3
  11. On 5/4/2018 at 6:03 PM, dragan said:

    Yeah, since then lots of people have gotten used to it.

    However: We have an in-house UX rule: Never display an icon without text. So yeah, it can't hurt to put "MENU" below the burger.

    I always do this:

    742317456_ScreenShot2018-06-01at18_19_35.thumb.jpg.424bcdfb92e22b2223d781ce05e2411c.jpg

    What grinds my gears is when hamburger menus are the only option on desktop sites (just for the sake of looking fancy), so I gotta click on it just to show the available options before I can choose something.

    • Like 3
  12. Don't you need to loop that page reference field (from your original example) if it's a list of tool pages? i.e.

    $lendoutpages = $pages->find("template=lendout, student_name=$page->id, sort=-lendout_time");	
    foreach($lendoutpages as $lendoutpage) {	
        echo "<li><a href='{$lendoutpage->url}'>{$lendoutpage->lendout_time}:</a>"; 
    	
        foreach ($lendoutpage->tool as $single_tool_page) {
          echo "<b>{$single_tool_page->title}</b>";
        }
        echo "</li>"; 
    }; 

    I'm not sure you need to use page->find() twice (as in your reworked example). Something like the above.

    This post may be useful:

     

  13. On 4/7/2018 at 1:29 PM, psy said:

    Rebuilt my own site recently using all the knowledge, tips & tricks I've learnt from the PW docs, forums etc, including adding PWA features. 

    Ran it through several publicly available audits and it passed OK - w3c validation, google page speed insights, google lighthouse, etc. Also engaged a digital marketing agency to audit it from a Google search POV.  Still some tweaking to do on content & backlink fronts.

    Overall though happy with the result which could never have been achieved without the help and support of the ProcessWire community. Thank each and everyone of you.

    https://www.clipmagic.com.au

    Very pleasing to the eye ? nice work!

    • Like 1
  14. Only just noticed the release_date key is either not there at all, or present, but empty for some movies e.g.:

    [97] => Array
        (
            [character] => Fred Rogers
            [credit_id] => 5a709346c3a36847e4012aaa
            [poster_path] => 
            [id] => 501907
            [video] => 
            [vote_count] => 0
            [adult] => 
            [backdrop_path] => 
            [genre_ids] => Array
                (
                    [0] => 18
                )
    
            [original_language] => en
            [original_title] => You Are My Friend
            [popularity] => 1
            [title] => You Are My Friend
            [vote_average] => 0
            [overview] => The story of Fred Rogers, the honored host and creator of the popular children's television program, Mister Rogers' Neighborhood (1968).
            [release_date] =>
        )

    Had to modify the  functions as checking for key existence was not enough:

    // Movies with release date
    function hasReleaseDate($movie) {
      // Has key with value
      if (array_key_exists('release_date', $movie) && !empty($movie['release_date'])) {
        return true;
      }
      return false;
    }
    
    // Movies without release date
    function noReleaseDate($movie) {
      // No key
      if (!array_key_exists('release_date', $movie)) {
        return true;
      }
      // Has key but no value
      if (array_key_exists('release_date', $movie) && empty($movie['release_date'])) {
        return true;
      }
      return false;
    }

    Seems to work now.

    • Like 1
  15. Did this now, code could most likely be improved, but it works:

    if ($movies) {
    
      // Movies with release date
      function hasReleaseDate($movies) {
        return (array_key_exists('release_date', $movies)) ? true : false;
      }
    
      // Movies without release date
      function noReleaseDate($movies) {
        return (!array_key_exists('release_date', $movies)) ? true : false;
      }
    
      // Generate arrays of movies with/without release date
      $movies_with_release_date = array_filter($movies, 'App\Controllers\hasReleaseDate');
      $movies_without_release_date = array_filter($movies, 'App\Controllers\noReleaseDate');
    
      // Sort by date - newest first
      function sortNewestFirst( $a, $b ) {
        return strtotime($b["release_date"]) - strtotime($a["release_date"]);
      }
      usort($movies_with_release_date, "App\Controllers\sortNewestFirst");
    
      // Append movies without release date
      $movies = array_merge($movies_with_release_date, $movies_without_release_date);
    
      View::renderTemplate('Actor/list-all.html', [
        'name' => $this->getFormattedName($name),
        'movies' => $movies
        ]
      );
    }
    else {
      View::renderTemplate('Actor/no-results.html');     
    }

    The more I move on with this, the more I see the importance of finding some kind of  structure. It's starting to confuse myself with where to put code, whether it goes in a model, a controller etc. Def need to work on this.

    However, all good for now :) thanks @arjen

    • Like 1
  16. 56 minutes ago, arjen said:

    You could use array_filter to create two arrays: one with and one without release dates. Sort the first one and append the second one.

    I'll give this a try, thanks.

    25 minutes ago, kongondo said:

    @SamC,

    Moderator Note

    FYI, you posted 3 other copies of this thread. I am guessing you were on mobile, or your computer was a bit wonky. I've deleted the other three.

    Thanks, had a problem submitting, 2mins+ with nothing haopening so I refreshed, waited, waited, redreshed, tried again. Third time submitted normally i.e. took seconds. Not sure what went wrong, maybe dodgy internet.

    • Like 1
  17. Hi,

    The array I'm working with (shortened example, the first three items) is:

    Array
    (
        [0] => Array
            (
                [character] => 
                [credit_id] => 5a26eac792514103360f3e03
                [release_date] => 2017-06-13
                [vote_count] => 5
                [video] => 
                [adult] => 
                [vote_average] => 7.6
                [title] => Celtics/Lakers: Best of Enemies
                [genre_ids] => Array
                    (
                        [0] => 99
                    )
    
                [original_language] => en
                [original_title] => Celtics/Lakers: Best of Enemies
                [popularity] => 3.191622
                [id] => 456788
                [backdrop_path] => 
                [overview] => A two-part series exploring the Celtics–Lakers rivalry, focusing mainly on the 1980s era of Larry Bird and Magic Johnson but also examining the entire history of the NBA through the rivalry.
                [poster_path] => /mF2ccs6AuGUvEIY9lfj8chFu6pW.jpg
            )
    
        [1] => Array
            (
                [character] => Performer
                [credit_id] => 5939ea8ec3a36823440029c4
                [release_date] => 2017-06-04
                [vote_count] => 1
                [video] => 
                [adult] => 
                [vote_average] => 1
                [title] => Comedy Central's Colossal Clusterfest
                [genre_ids] => Array
                    (
                        [0] => 35
                    )
    
                [original_language] => en
                [original_title] => Comedy Central's Colossal Clusterfest
                [popularity] => 1.651011
                [id] => 460340
                [backdrop_path] => /gsZT6wW4Oo7ApYD4TG5aZWby1Jj.jpg
                [overview] => Highlights from the inaugural Colossal Clusterfest that took place in San Francisco from June 2-4.
                [poster_path] => /ui1nZudYxcqJjFIZsiuTyqcV6PL.jpg
            )
    
        [2] => Array
            (
                [character] => 
                [credit_id] => 589119a092514103f000c00f
                [release_date] => 2017-03-10
                [vote_count] => 4
                [video] => 
                [adult] => 
                [vote_average] => 2.6
                [title] => G-Funk
                [genre_ids] => Array
                    (
                        [0] => 99
                    )
    
                [original_language] => en
                [original_title] => G-Funk
                [popularity] => 5.432522
                [id] => 438517
                [backdrop_path] => 
                [overview] => G-Funk is the untold story of three childhood friends from East Long Beach who helped commercialize hip hop by developing a sophisticated and melodic new approach – merging Gangsta Rap with elements of Motown, Funk, and R&B.
                [poster_path] => /lmByKQnHcMch8FkWzNquKtbFueN.jpg
            )
    )

    ...and I wanted to sort them by date, newest first. It's small class like this. The problem is outlined in the comments:

    <?php
    
    namespace App\Controllers;
    
    // Bring View class into current namespace
    use \Core\View;
    // Bring Actor model class into current namespace
    use App\Models\Actor;
    
    /**
     * About controller
     */
    class Actors extends \Core\Controller {
      public function list() {
    
        // Model 'Actor' just queries API and returns array
        $movies = Actor::getAll();
    
        // Sort by date - newest first
        function sortNewestFirst( $a, $b ) {
          return strtotime($b["release_date"]) - strtotime($a["release_date"]);
        }
        /**
         * **********************************************
         * usort() ERRORS IF 'release_date' does not exist
         * **********************************************
         */
        usort($movies, "App\Controllers\sortNewestFirst");
    
        View::renderTemplate('Actor/listAll.html', [
          'name' => $this->getFormattedName(),
          'movies' => $movies
          ]
        );
      }
    
      /**
       * Get the current name from URL
       */
      private function getFormattedName() {
        return ucwords(htmlspecialchars($_GET['name'], ENT_QUOTES | ENT_SUBSTITUTE, "UTF-8"));
      }
    }

    The error:

    Uncaught exception: 'ErrorException'
    Message: 'Undefined index: release_date'

    Unfortunately, the API has no release date for some movies, so my search works perfectly for some actors, but errors for others. I was trying to figure out how to get array_key_exists() into this somehow but I'm totally stuck. Being an array of arrays makes this more tricky. I was thinking of looping each one, if the key exists, add to a new array, but then the movie with the missing key would be completely absent. I was thinking of just chucking it at the bottom of the list.

    Hopefully this makes sense. Any help, hints or improvements would be awesome, thanks.

×
×
  • Create New...