Jump to content

SamC

Members
  • Posts

    733
  • Joined

  • Last visited

  • Days Won

    9

Posts posted by SamC

  1. Now I haven't done any development for a number of months now, just kinda lost the mojo. Maybe it'll return, maybe not, but I still like to check out the forum once in awhile.

    I used repeater matrix a lot on one site. I think it's not only useful, but essential. If you have a page that has a lot of content in the form of title > paragraph > image > paragraph > quote > image > paragraph etc... good luck with doing that in either a huge single text field or multiple fields all cobbled together in a specific order that's awkward to change. I can't say I used the other included goodies as much, but repeater is worth its weight in gold, plus buying it supports an amazing project.

    • Like 2
  2. 4 hours ago, eurekaa said:

    Does the solution work??

    Did for me. Bluetooth is really dodgy on 10.14.5. Sometimes works with my headphones, sometimes hangs the whole laptop with that stupid spinning beach ball. It's really not acceptable on such a supposedly 'high end' product. But hey, I love this laptop so meh.

    • Like 1
  3. Ah yeah, I see your point. These dates are actually backdated. Hmmmm, I'll look at the other replies on here tomorrow and see if I can come up with something.

     

    @bernhard like:

    Journal (journal-index)
     - 2019/04/02 - Day 1 (journal-entry)
     - 2019/04/05 - Day 4 (journal-entry)
     - 2019/04/09 - Day 8 (journal-entry)
     - 2019/05/09 - Day 9 (journal-entry)
     - 2019/06/09 - Day 10 (journal-entry)
     - 2019/07/09 - Day 11 (journal-entry)
    etc...

     

  4. Hi everyone,

    I'm creating a journal style site. I have the templates journal-index and journal-entry (child), I wanted to see if there was a way that when I create a new blog entry, the title field will automatically be populated with [DATE] - [DAY n], for example:

    9th April 2019 - Day 1
    10th April 2019 - Day 2
    11th April 2019 - Day 3

    This is a local 'countdown from' site and I may publish it, haven't decided yet.

    Now, let's say this is possible. What would then be the way to change the format at a later date, say I wanted to change to '09/04/19 - Day 1 since...'.

    Would this be awkward? Is there a way to batch change all the titles like this after a bunch of pages have been created?

    Thanks.

    *NOTE* I'm open to other suggestion because this may suck a fair bit for SEO should this go live. Thing is, I don't have an actual title in mind for each page, there could be a lot of these. I was thinking in this case, a date actually makes more sense. Although, another problem could be the URL, it would be awesome to get something like 'site.com/09/04/2019/day-1'

  5. 11 hours ago, happywire said:

    Yeah, someone else also did highly recommend to do that course. Have been watching the first couple hours through this site http://learnwebdev.net/ and had so many concepts suddenly make a lot of sense. Window object, this, execution context, lexical scope. Just the first 2h of that cleared up a lot of what I was missing all this time.

    Nice one :) go get the full course, it's so worth it!

  6. 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 ? 

    581765625_Screenshot2019-03-14at09_48_30.thumb.png.39c44a28b2143d40da5bb963c8ea0cbc.png

    @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.

    • Like 2
  7. 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.

  8. 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:

    Quote

    In practice, this is how most of your objects should be resolved by the container.

    i.e. using a constructor: https://laravel.com/docs/5.7/container#automatic-injection

  9. 40 minutes ago, adrian said:

    That said, I like the OS nature of Gitlab and the unlimited collaborators, so it really depends on your needs and maybe these are project specific?

    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.

  10. 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.

  11. On 1/17/2019 at 2:34 PM, adrian said:

    Of course Gitlab has:

    "Unlimited private projects and collaborators" but this move by Github will probably have me move from Gitlab for most things.

    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?

  12. 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!

    • Like 2
  13. 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.

    54 minutes ago, wbmnfktr said:

    I started with Macs back when the iBook G4 was the latest (not so expensive) model and kept Macs on my desk until 2015. That year and that MBPr 15 made me switch back to Windows setups. First Windows 8.1 on Lenovo X1 and now on a MS Surface. Never looked back.

     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.

  14. 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...