ohffs

ohffs

Glasgow

Member Since 3 Years Ago

Experience Points 268,680
Experience
Level
Lessons Completed 989
Lessons
Completed
Best Reply Awards 294
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

18 Jan
10 hours ago

ohffs left a reply on Screencast Software

I've seen a lot of youtube/twitch coding tutorials using OBS

15 Jan
3 days ago

ohffs left a reply on When To Use Something Like Aws S3?

@SHADRIX - I've never used them - but I've heard of them quite a few times without any horror stories - up to you which one you use really. I guess whichever is cheaper/easier for your app :-)

ohffs left a reply on When To Use Something Like Aws S3?

If you're dealing with images, then something like cloudinary might be worth a look rather than spaces/S3. The free tier might be enough for you too. It'll let you upload the image and also take care of things like resizing & optimising the images. They will also tie in with the big CDN's so your images will get served up to your users from a nearby location rather than hitting your server - maybe on the other side of the world.

I think a lot of people default to S3 as there are good, well-tested, well-documented libraries for it and it's been around a long time. DO's spaces are a bit newer and a bit simpler.

07 Jan
1 week ago

ohffs left a reply on What Is A Good Way To Keep Track Of Cart Quantity Across Different Pages?

You could also use the browser's LocalStorage so store the cart. You'd have to do a little fancy footwork if you wanted to allow people to come back to the site with a different device and see their cart though.

01 Jan
2 weeks ago

ohffs left a reply on Audio To Code In Js Output

@SKYCODER - Glad to help - hope you have a great new year too :-)

ohffs left a reply on Audio To Code In Js Output

Wes Bos has a free tutorial on it over on youtube - that might help get your head around it :-)

31 Dec
2 weeks ago

ohffs left a reply on Is There A Shorthand To Schedule Commands To Be Queued?

Why not extract the logic of your export/ftp to it's own class - then just call that from both your artisan command and queued job?

29 Dec
2 weeks ago

ohffs left a reply on Can't Use Composer On Mac Mojave

@HJORTUR17 - Glad you got it working :-)

ohffs left a reply on Can't Use Composer On Mac Mojave

Is your composer file renamed to 'composer' or is it 'composer.phar'? Try and do an ls -l /path/to/your/composer file (or composer.phar) and make sure the permissions (first column) is something like -rwxr-xr-x. If you don't see the x's then do a `chmod +x /path/to/your/composer' and try running composer again.

28 Dec
3 weeks ago

ohffs left a reply on Under Docker Error Call To Undefined Function Intervention\Image\Gd\imagecreatefromjpeg

@MSTDMSTD - It looks like that should only happen if you're loading a webp file (from a quick look at the sourcecode). There is a stackoverflow answer that might help get webp installed which might get the error to go away though ;-)

ohffs left a reply on Under Docker Error Call To Undefined Function Intervention\Image\Gd\imagecreatefromjpeg

I've got a docker image with GD installed - try this part :

FROM php:7.2-apache

RUN apt-get update && \
    apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev libgmp-dev libldap2-dev netcat sqlite3 libsqlite3-dev && \
    docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && \
    docker-php-ext-install gd pdo pdo_mysql pdo_sqlite zip gmp bcmath pcntl ldap sysvmsg exif \
&& a2enmod rewrite

If that doesn't help - try doing a call to phpinfo() and see if GD is showing has having jpeg support - I seem to remember it can be a bit picky about the order you do things in :-/

26 Dec
3 weeks ago

ohffs left a reply on Yarn.lock Is Causing Npm Run Dev To Fail

@bobbybouwmann this hit me recently too in slightly different circumstances. If mix sees a yarn.lock file it will try and run yarn - even if it's not installed (as far as I can tell). It hit me doing a CI build after I'd been debugging npm issues (again) and had used yarn as a test - then inside the CI build it didn't have yarn and started to crash.

I think some part of doing a laravel new triggers a yarn.lock file to be created too - so I'd guess it's related to the way mix works. I meant to put an issue on the mix github but then started drinking & eating all the food on earth in the run up to xmas ;-)

25 Dec
3 weeks ago

ohffs left a reply on How To Compact + Uglify + Strip Unused CSS And JS For Production Deploys?

If you're using mix v4 I think you can pass an option to 'terser' to mangle all the js/css. Might be as easy as :

mix.options({
  terser: {
    mangle: true
  }
});
24 Dec
3 weeks ago

ohffs left a reply on Using Redis Throttling For Sending Queued E-mails

When you're using throttle I seem to remember you're supposed to pass it the name of a new, temporary 'queue' - rather than the one you're trying to throttle? So in this case it would be something like :

Redis::throttle('throttled.send.newletter')->....

I might be wrong though :-) If you're chunking your results you might need to make a 'throttled' per-job too - like :

$jobId = Redis::incr('throttles');
Redis::throttle("throttled.{$jobId}.send.newsletter")->...

As I say - I might be 100% wrong though :-)

22 Dec
3 weeks ago

ohffs left a reply on Return Api() !!!!

I guess someone's added a helper function that is just a shorthand for return response()->json([]);

ohffs left a reply on Vue Js, Restrict Length Of <input />

Would a simple filter do? Or you could use a watcher on the value and just trim the length? Either that or bind the value and input events separately and do it in the event handler I guess.

21 Dec
4 weeks ago

ohffs left a reply on Are Long Waiting Times A Must Or Bad Development?

This comes back to mind... ;-)

20 Dec
4 weeks ago

ohffs left a reply on How To Prevent Revealing Used Technologies Name And Versions

Does running your js stuff through terser help? I haven't tried it with mix v4 yet - but it's something like :

mix.options({
    terser: {mangle: true},
});

maybe ;-)

ohffs left a reply on Get Image/video Metadata From Stream

Can you post some of your code here so if anyone else is trying to do the same thing they will be able to see how to do it? :-)

19 Dec
4 weeks ago

ohffs left a reply on Add Up/Down Vote Instead Of Best Reply

@CMDOBUENO - > What this is about, is people that barely understand what they are doing, thinking they know the right way, spreading a plague of misinformation.

I don't think I've ever heard the internet described so well ;-)

ohffs left a reply on Add Up/Down Vote Instead Of Best Reply

Maybe something like allowing the thread creator to pick the best reply (as now) but also a 'community best reply' award that was the most liked/favourited/upvoted one?

I also dislike the idea of downvoting as it often leads to 'in crowds' just downvoting people they don't like (see Reddit for instance).

There's also the issue of things that were 'best' when they were awarded now being out of date - I quite often see people replying to old threads saying they've tried some advice that was for Laravel 4.x or something and not understanding why they can't see the files mentioned. How you go about that without relying on people manually marking them is another matter though - some advice is (relatively) timeless - some goes out of date in a few weeks (javascript - I'm looking at you... ;-)

It's a hard problem to solve I think - look at Stackoverflow for instance - they've been pretty much dedicated to the issue for years and it's still full of out-dated 'best replies' that are wildly out of date or just wrong.

ohffs left a reply on Purpose Of $commands In Kernel.php (Task Scheduling)

It was used in previous releases (I think until 5.5 maybe) - then the framework added the ability to automagically find the commands. It's still there partly for backwards compatibility and also handy if you want to put your commands in a different directory.

As for output - it'll only print something to the console if the command has something like $this->info('Starting...') inside it.

17 Dec
1 month ago

ohffs left a reply on If You See A Post Again. Laravel Counts It As A View :)

@AURAWINDSURFING - I think they mean the view count for threads on the forum - not 'laravel' :: shrugs ::

ohffs left a reply on Low Request Per Second With Laravel, Docker, And AWS

You could also try using something like blackfire - there's a free trial which might be enough to get you narrowing down the problem.

ohffs left a reply on Low Request Per Second With Laravel, Docker, And AWS

If you really can't bring up a test copy for whatever reason, can you install something like php-spx - it might help you narrow down where the time is being spent - but it'll only show you it for the php part - if the problem is elsewhere (docker/aws/nginx/whatever) you'll still be in the dark :-/

ohffs left a reply on Low Request Per Second With Laravel, Docker, And AWS

@BEERBUDDHA - I've edited my reply with a few other pointers :-)

ohffs left a reply on Low Request Per Second With Laravel, Docker, And AWS

@BEERBUDDHA - I think what @markotitel and I are suggesting is to try it (just as a quick test) on another environment (outside of docker) just to check if docker is contributing to the problem. Not to replace your whole production setup :-) The reason I was suggesting running it outside of AWS was again, just to check another possible reason it could be going slow. AWS is much more complicated animal than, say, Digital Ocean - there are all sorts of things that can be combined that could be having a side-effect.

If you add a route to your code that does something like :

Route::get('/whatever', function () {
    phpinfo();
});

then it should tell you if opcache is enabled and what the settings are (there is a section labelled 'Zend OPcache'). Maybe also start up another container on a different port using the base php image. I usually use php:7.2-apache so I don't have to bother setting up fpm/nginx as well for instance. Just do a laravel new test-project and build it inside the container and see how many requests it can handle. Something like this should do it :

FROM php:7.2-apache

RUN apt-get update && \
    apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev libgmp-dev libldap2-dev netcat sqlite3 libsqlite3-dev && \
    docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && \
    docker-php-ext-install gd pdo pdo_mysql pdo_sqlite zip gmp bcmath pcntl sysvmsg exif \
    && a2enmod rewrite

COPY vhost.conf /etc/apache2/sites-available/000-default.conf

EXPOSE 80

COPY . /var/www/html

RUN chown -R www-data:www-data /var/www/html/storage
RUN chown -R www-data:www-data /var/www/html/bootstrap/cache

CMD ["apache2-foreground"]
// vhost.conf
<VirtualHost *:80>
    DocumentRoot /var/www/html/public

    <Directory "/var/www/html/public">
        AllowOverride all
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
15 Dec
1 month ago

ohffs left a reply on Low Request Per Second With Laravel, Docker, And AWS

I was just meaning to try it on bare metal as a quick test - if that was possible :-) Just to rule out that docker was the issue :-) Docker 'nat' in particular can hit you with a 50% performance overhead :-/ We're moving towards docker swarm/kubernetes too so I've been digging into the networking quite a lot recently :-) I'm not an AWS user so can't offer any advice on that side of things sadly :-/

I don't know if you can try it - but if you have a swarm available - see if you can deploy multiple copies of the app and let something like traefik take care of wiring it all up so requests are split over multiple containers - that's what we're doing just now. But I'm really not sure that would help if you're seeing 100% cpu load across all your cores anyway. In my little raspberry pi test I could only get the 4 ARM cores to max-out at about 80%.

Your app isn't logging a lot of stuff, is it? Or using disk for session/cache? A lot of disk I/O could slow things down a lot too :-/

ohffs left a reply on Low Request Per Second With Laravel, Docker, And AWS

As a quick test - I just did a basic benchmark against a little laravel app I have running on a raspberry pi (it uses Redis/Sqlite-on-disk and performs an API lookup to another service on localhost) and I can get 100req/sec with 100 concurrent users - so with your hardware you should be able to handle way, way more than that. It's very odd :-/ Is it possible to try your app on another server outside of a docker container? Some of dockers network modes can have a very big impact on network performance :-/

ohffs left a reply on Low Request Per Second With Laravel, Docker, And AWS

I think you should be able to handle a lot more traffic than that given the box you have. Does your docker image have xdebug enabled, maybe? Is the DB running on the same box as the application?

It might be worth looking through the deployment guide and Chris's other video series on scaling with forge might give you some tips (he has a paid one too).

Without seeing exactly what your app does, how it's configured etc - nothing else is coming to mind I'm afraid :-/

13 Dec
1 month ago

ohffs left a reply on What's The Best Way To Go About Caching User Generated Content?

@ZENITH2012 - No worries at all :-) Enjoy digging more into laravel and maybe vue - it's a very productive combination when you need it down the line :-)

09 Dec
1 month ago

ohffs left a reply on Get Image/video Metadata From Stream

@CGUY - I think it would have to read the whole file through memory - yeah. I'm not sure if there's a better way without storing the file temporarily I'm afraid. Maybe someone else will chip in though :-)

ohffs left a reply on Get Image/video Metadata From Stream

Your best option might be to run ffprobe against the file once it has finished being ::put() to the remote server. I think mpeg streams have to be read as a whole (or rather the stream info can be anywhere in the file) to figure out what they contain - so I don't think you could just use a chunk or stream to get the info - I might be very wrong though! I have vague memories of trying to do this a few years ago by just storing the first few kb/mb of the file - but it never worked :-/

ohffs left a reply on What's The Best Way To Go About Caching User Generated Content?

@CORBIN - Redis is pretty efficient - but it'll depend on your own data I'm afraid - try building up a few thousand fake threads with a few hundred replies each and storing them in your redis cache and see how it goes. You can also use Redis's expireat to automatically clear data out of the cache after a certain amount of time if no-one has looked at them (you need to re-set the expire time if someone views it again of course) - that way threads that have faded from the 'front page' (in what-ever sense) don't take up memory. You'll have to figure out what makes sense for your site again though - maybe you only trigger caching on 'hot'/'popular' threads if you're really constrained.

But when you're thinking about caching pretty much text content - remember that the complete works of Shakespeare as html only take up about 6mb, so it's surprising how much you can cache in a small amount of RAM :-)

In my case I just cached a data structure that the JS was expecting to get so there was no processing to do - but you could take it a step further and render out the html and cache that.

If I were you I'd see how you get on without caching at all though - mysql/postgres etc are pretty efficient themselves and will cache a lot of queries for you, so you might not need all the complexity. If you've got your actual app running on one small box, and the DB server on another you'd be really surprised at how much traffic you can handle without doing much work :-)

But try creating a decent amount of fake data and then see what something like apache ab says when running with lots of simultaneous page-views. There are more thorough load testing tools like gatling too which can simulate 1000's of users viewing, posting, clicking around etc.

08 Dec
1 month ago

ohffs left a reply on What's The Best Way To Go About Caching User Generated Content?

@zenith2012 if it failed I just popped up an error as per usual on the page using JS along with a little 'retry?' button (pretty much just the .catch() block in axios). Not exactly the best UX as if they left the page before it happened they wouldn't know - but it wasn't really that critical. To me anyway ;-)

I actually just this week implemented much the same thing for a different site but with a much nicer system using the new laravel websockets package and vue-toasted that will alert them of a problem even if they've left the page. It's fairly easy to do now thankfully! :-)

ohffs left a reply on What's The Best Way To Go About Caching User Generated Content?

You might find this post on dev.to useful. They also list their stack on their github page which might give you some ideas.

For a site I had to look after where there were a lot of posts/channels/threads etc - I eventually made it so when a user posted a reply to a thread it was inserted into the UI right away via JS so the user got immediate feedback - and sent an ajax post off to the server which actually saved it to the DB and updated a cached version of the thread via little background job. Seemed to work ok and cut down the database load quite a lot.

It's the kind of thing you have to try out for a particular scenario and see what cost/speed/effort trade-offs you can make. Maybe for something like a forum/thread/replies set-up it makes more sense to use something like MongoDB and just insert the reply into the post object for instance. Sometimes it might be better to cache using sharded redis if you're really busy. As usual - 'it depends' :-)

07 Dec
1 month ago

ohffs left a reply on Secure Links In Laravel

'Signed URL's' might be what you're after : https://laravel.com/docs/5.7/urls#signed-urls

ohffs left a reply on Add Playing Time To Episode List?

@jlrdw it looks like this to me - no playing time : https://imgur.com/a/BCO6zOG

06 Dec
1 month ago

ohffs started a new conversation Add Playing Time To Episode List?

Is there any chance the playing time could be added to the episode list? It's not a big deal - but it's handy when you see new videos to be able to quickly think 'oh, that's 10 minutes - I'll watch that while waiting on pasta cooking' or 'oh, that's 40 minutes of watching - I'll watch that while I wait on that curry cooking' :-)

And yes - I do a lot of video watching while cooking ;-)

ohffs left a reply on Does This Email API Exists? Laravel > Json > External Email Service

Something like mailgun or mailchimp might be what you're after?

05 Dec
1 month ago

ohffs started a new conversation Laravel Websockets

This looks like it might be very useful when you cant or don't want to use Pusher and avoid the hassles of the node echo-server :

https://murze.be/introducing-laravel-websockets-an-easy-to-use-websocket-server-implemented-in-php#pair-programming-is-fun

26 Nov
1 month ago

ohffs left a reply on Send Email Alert At 90% Usage Only Once (best Practise?)

@DR.BOB - no worries - hope you get it working ok :-)

24 Nov
1 month ago

ohffs left a reply on Send Email Alert At 90% Usage Only Once (best Practise?)

@DR.BOB - I think @cronix means that your event listener would do something like :

if ($user->isOverSomeLimit()) {
  $user->sendSomeWarning();
}
User.php:
public function sendSomeWarning()
{
  if ($this->hasBeenRecentlyNotified()) {
    return;
  }
  $this->notify(...);
  $this->recordNotification();
}

The hasBeenRecentlyNotified and recordNotification methods could either look up/update a DB table - or you could use Redis and use it's 'expire'/ttl facility as a kind of 'expiring flag', eg :

// hasBeenRecentlyNotified()
return $redis->exists("userwarned:{$this->id}");

// recordNotification()
$ttl = 60 * 60 * 24; // ie, one day in seconds
$redis->set("userwarned:{$this->id}", true));
$redis->expire("userwarned:{$this->id}",$ttl);

ohffs started a new conversation Resume/multipart S3 File Storage?

I've got a little app that copies video files from on raspberry pi to another via wifi using an S3-compatible server (minio). The wifi is pretty erratic sadly, so sometimes the connection drops.

At the moment the code that does the Storage::put is wrapped in a try/catch that retries upto three times before giving up. But each retry is starting the upload from scratch - so what I'd like to do is have it try and resume the upload rather than start again to increase the chance of it completing each try. I can see the AWS S3 SDK supports it - but I can't see anything about accessing it via the Laravel Storage facility.

Does anyone have any pointers? If it's not exposed I'll just drop down to using the AWS code itself - but if I'm just missing a little flag or something it'd be nice to stick with the existing Storage:: methods :-)

20 Nov
1 month ago

ohffs left a reply on Side Projects???

I wouldn't say it was as 'grand' as a side-project, but I've been working away on a little app that monitors a queue of torrents downloading on a raspberry pi, and can queue+copy them to a kodi server in another room once their finished :-) It started out as a tiny basic static blade/html/post-the-form thing and has kind of ended up as a vue SPA thing with lots of ajax and Redis usage with tailwind for the css - which has turned out to be quite a fun learning experience.

Just the other day I managed to add a whole new 'feature' that makes it crash the raspberry pi - so that's something else to work on... ;-)

18 Nov
2 months ago

ohffs left a reply on Vue V3

@bobbybouwmann no - it was more a 'this might be interesting to you' post :-)

17 Nov
2 months ago

ohffs started a new conversation Vue V3

Seeing as a lot of us use Vue - thought some of these slides about what's coming in V3 might be of interest. Double the speed and half the memory usage sounds quite nice for one ;-)

https://docs.google.com/presentation/d/1yhPGyhQrJcpJI2ZFvBme3pGKaGNiLi709c37svivv0o/preview#slide=id.p

I think elsewhere they've said the API for developers will stay pretty much the same so no big re-writes for us either - which would be very welcome :-)

ohffs left a reply on Blade In Javascript

I've been working with fullcalendar a lot recently (and some other JS libraries that need data in specific formats) and have been using api resources to map the data into the right format - so your JS part ends up just being as easy as :

events: {{ $myData->toJson() }}

It has the side-benefit of being able to write quick tests that your data is coming back in the format you expect too :-). I think for one set of data I've got about five different resources defined as it's sometimes viewed in a table, sometimes as a calendar, sometimes as a graph, etc :

App\Http\Resources\...
  Bookings\FullCalendarResource
  Bookings\ApexChartResource
  Bookings\....

Which makes it nice and quick to find the place the data is coming from too. But it's probably overkill if you've just got one set of data and one calendar :-). As @edoc says - just go with what you've got if it works :-)

16 Nov
2 months ago

ohffs left a reply on Docker, Laravel And A Production Server With Apache Running

@ALESSANDROBELLI - Not in version number terms - is 'version 1, release number 8' greater than 'version 1, release number 23' :-)

Hope your boss gets someone to help :-) I found this video series really helpful to get up and running with it - if your boss wants to pay out a little money : https://serversforhackers.com/shipping-docker

14 Nov
2 months ago

ohffs left a reply on Docker, Laravel And A Production Server With Apache Running

@ALESSANDROBELLI - Your docker-compose is 1.8? I think you'll have to update it to a newer version.