Author: Mark

  • Using Reduce

    Reduce is used somewhat similar to ‘map’ Zero is set as the initial value and then it goes through the array and adds each value (in this example the currentScore) to the totalScore which becomes the new ‘previousScore’. Here’s a more useful example:

  • Checking a video to play it

    This was from a long time ago. I think it had something to do with browser compatibility or device compatibility. Leaving it here in case it’s useful in the future.

  • How to conditionally wrap an element in React

    The ConditionalWrap component checks the condition (in this example the element.url) and if it exists put the wrapper around the children, otherwise just render the children. The wrapper in this example is a link. You can put whatever content you want where the comment is to be put inside the link.

  • How to undo a pushed merge in Git

    First use “git log –oneline” to find the commit that you want to go back to and copy it somewhere. Then use You are now reset back to a previous commit. To finish, do force push.

  • Close the iOS video player with jQuery

    An example when you could use this is when the video has ended to automatically close the video player and go back to the website.

  • Adding a blur function in React

    An example is to hide a menu if you click off it. This is an example function which changes the variable that affects the menu. Then just add the function to the menu container.

  • How to rebase in Git

    I’m not a GIt expert. This is just how I do it. 1st line fetches the latest code from the main repo. 2nd line resets your local branch the latest stage of the master branch 3rd line is just a regular commit 4th line is the force push. This will put all your changes into…

  • Stop a page from redirecting

    Put this in the console: This is useful if you want to inspect a page that auto redirects.

  • Looping though arguments in a mixin

    Things to note here: The last argument ends with … which means it accepts any number of arguments and will put those arguments into a list. #{nth($items, $i + 1)} gets the argument from the list. You just specify the list and the index. Unlike arrays, the index of the first element is 1. The…

  • Turning a 2nd modem into an external Access Point

    I’ve done this a few times already so thought it would be a good idea to document it. What this does is basically make a 2nd wifi spot using your original wifi. Get the original modem’s ip address (usually 192.168.1.1) If not check by typing “ipconfig” in the command line on a computer that’s connected…