Jump to content

SamC

Members
  • Content Count

    713
  • Joined

  • Last visited

  • Days Won

    5

SamC last won the day on July 21 2018

SamC had the most liked content!

Community Reputation

647 Excellent

3 Followers

About SamC

  • Rank
    Hero Member

Profile Information

  • Location
    Surrey, UK

Recent Profile Visitors

2,093 profile views
  1. Nice one :) go get the full course, it's so worth it!
  2. Had no idea about this: https://developer.mozilla.org/en-US/docs/Web/API/Performance/now Add web APIs to the bucket list...
  3. @Autofahrn that last post was awesome!
  4. Wow, there's some really great replies here, thanks everyone For clarity, the context is 'this' (quite literally): http://javascriptissexy.com/understand-javascripts-this-with-clarity-and-master-it/ That line came from this section on the page: 3. Fix this when method is assigned to a variable So what I've read previously in this thread and about bitwise OR, is this what happens? // Let's forget about the + 1 -1 stuff for now // Math random returns a float between 0-1 (not inclusive of 1) var randomNum = ((Math.random() * 2 | 0); // Once this float is multiplied by two (keeping the decimal places shorter) var randomNum = (1.6 | 0); // After forced type coercion to int and trucation (because of bitwise OR) var randomNum = (1 | 0); // Binary values are compared // Bitwise OR: 1 compared to 0 = 1 var randomNum = 1; // OR var randomNum = (0.7 | 0) // After forced type coercion to int and trucation (because of bitwise OR) var randomNum = (0 | 0); // Binary values are compared // Bitwise OR: 0 compared to 0 = 0 var randomNum = 0; Just did a super quick demo to try and solidify this in my head, if you don't use vscode and quokka plugin, try it, it's awesome @happywire if you're just starting out with JS, I can highly recommend this course: https://www.udemy.com/understand-javascript/ Anthony is an incredible teacher. This isn't just your usual "make a project with me" i.e. just code along, finish the project, learn next to nothing and not be able to implement anything you've learned in different scenarios kind of course. This is much more about the theory of how JS works.
  5. Hi everyone, got a random JS question. Could anyone explain to me how this line works? var randomNum = ((Math.random() * 2 | 0) + 1) - 1; It assigns either 0 or 1 to randomNum. What I don't get is the bitwise operator. I mean I get it compares two binary numbers, and two 0s is 0, 1 and 0 is 1, 1 and 1 is 1 etc.. but what happens with a decimal here? // Let's say Math.random() gives us 0.12005029823663982 var randomNum = ((Math.random() * 2 | 0) + 1) - 1; // So... ((0.12005029823663982 * 2) | 0) + 1) - 1; //... ((0.24010059647) | 0) + 1) - 1; // Now what? Do you even need the bit at the end? + 1) - 1; From what I've read (and tested), the output number from the between the first set of parenthesis alone will be 0 or 1. Not really sure what's going on. Any advice would be great, thanks.
  6. Awesome, thanks @szabesz I'm in JS land right now, this may come in very helpful, after I've completed the already massive todo list...
  7. SamC

    pwtuts.com - tutorials

    @bernhard nice! I'll update the tutorial (done now) and point to this module. I haven't had much time at ll to work on that site, been so busy trying to learn enough skills to call myself a dev one day...
  8. SamC

    Typography!

    This is a really nice font! Thanks for this
  9. Ah, ok, thanks guys. I did wonder one other thing, there seems to be numerous ways to achieve something, like, which approach would you use, inject into a method, or into the constructor? Both work in my case here (only showing one method, there are more, but they do not ALL need the Project class, create() for example just returns a view). So would you (the Laracasts showing me how to do this way): namespace App\Http\Controllers; use Illuminate\Http\Request; // Bring Project model into namepsace use App\Project; class ProjectsController extends Controller { public function show(Project $project) { return view('projects.show', compact('project')); } } ...OR (the way shown in @Wanze's link above from Laravel docs): namespace App\Http\Controllers; use Illuminate\Http\Request; // Bring Project model into namepsace use App\Project; class ProjectsController extends Controller { protected $project; // Inject Project model here instead of on multiple methods public function __construct(Project $project) { $this->project = $project; } public function show($id) { $project = $this->project->findOrFail($id); return view('projects.show', compact('project')); } } Would one way be considered 'better' than the other way? Does it just depend on how many methods actually need the other class? i.e. what's the point of instantiating in the constructor if 3 methods need it, and 3 methods don't. That kind of thing? Not sure I like compact() either, it's not obvious to me (lack of experience?) what's actually being passed to the view. I know there are other ways. If you use artisan to set this up automagically: php artisan make:controller ProjectsController -r -m Project ...it results with the former i.e. no constructor, which seems weird seeing as their docs say: i.e. using a constructor: https://laravel.com/docs/5.7/container#automatic-injection
  10. My needs are shall we say, basic. But CI/CD is something that interests me. I've seen a lot of travis files on various projects but no idea what they do tbh. I'm guessing it's like Buddy, but less point and click. I use buddy to sync files between a staging and production site, for pushing code from a gitlab repo > staging site (automatically when pushed from vscode) > production site (on a button click in buddy web UI). I'm guessing I can do all the same things with github. One concern would be them sucking me in with a 'free' promise, then start charging for it, like what And.co just did for my invoicing! And gravit.io just did the same... except they didn't just add a premium version, they took features OUT the free one and started charging for them. I didn't use github because it wasn't free for private repos, it was as simple as that. I tried bitbucket but IMHO, the UI was awful. Gitlab was much nicer, but I prefer Github. Now it's free, maybe I can try it out some more... and learn what travis does.
  11. Still not sure whether 'dev talk' means talk about just PW or anything else?! Anyway, been working with Laravel for a bit now but still a bit confused about a certain thing. For example: namespace App\Http\Controllers; // Bring Project model into namepsace use App\Project; class ProjectsController extends Controller { /** * Save new project */ public function store() { $project = new Project(); // <<<<<< NEW OBJECT $project->title = request('title'); $project->description = request('description'); $project->save(); // A GET request by default return redirect('/projects'); } } ... but I've since found out that you don't need to instantiate a new object in a method, you can type hint like so: /** * Update existing project */ public function update(Project $project) { // Update and save $project->title = request('title'); // <<<<<< OBJECT IS AVAILABLE LIKE MAGIC $project->description = request('description'); $project->save(); // A GET request by default return redirect('/projects/' . $project->id); } What I'm confused with is how type hinting creates a Project object that is then available in the update() method. Isn't type hinting simply saying "this method expects param 1 to be an Object of type Project"? i.e. nothing to do with dependency injection. Any hints would be awesome, thanks.
  12. Hi Adrian I'm using GitLab for all my private stuff, worked fine so far. It also integrates nicely with Buddy (which is good for me because I don't know how to set up CI stuff manually). Why would this move by Github have you move from Gitlab? What would make Github a better choice for you?
  13. After trying @wbmnfktr suggestion of turning off bluetooth (I also deleted wifi and re-set it up), the wifi seems to be working fine for the last couple of days.... fingers crossed. Although crossing fingers and hoping for the best is no substitute for it actually working like it should!
  14. I've been on windows since about win95 and I've never had any issues. Other than the ancient looking (IMHO) explorer and those yellow folders, I really enjoy it, now on win10 on the desktop. I actually had a surface laptop on order, then got all paranoid about the material staining up (I have eczema so my hands can be greasy with moisturizer). The order fell through when they failed to deliver it on time so I cancelled and got my money back, and bought the 2015 macbook. What do you use as a terminal on win10? I'm using cmder at the moment which seems to do the job. Mind you, I've got no idea what actually happened behind the scenes on initial setup.
  15. Mine's a 2015 13" MBP. @ryan, thanks but I don't have the android file transfer installed. The only things I leave running are postgres server, docker and onedrive. I actually never turn the thing off because every time I did, I got this: https://jeroenmols.com/blog/2017/12/26/macosupdate/ on startup. I wasn't trying to upgrade or anything, just restarting. Actually, not sure if upgrade is the right word. Doesn't that imply something that's better? I started using a macbook in 2012 and never had any problems, now the number of issues seems to be creeping up and up. I guess I could quit moaning and buy a windows laptop but I expect more from such an expensive bit of gear. Anyway, I'll try the bluetooth suggestion tomorrow. Not sure what'll happen when I need to use my external (bluetooth) keyboard though.
×
×
  • Create New...