MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord

    How to post code on the forum - For absolute beginners

    Troubleshooting
    10
    26
    11007
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Mykle1
      Mykle1 Project Sponsor Module Developer last edited by Mykle1

      How to post code on the forum. For absolute beginners.

      I’m going to walk you through this. Why? Well, someone always helped me when I was new.
      What better way to repay them? By helping others, that’s how.

      At some point . . .

      You’re going to be asked to post some of your code so that it can be looked at by
      the people here on the forum. It helps them to help you.

      Some of the reasons.

      • MagicMirror is telling you to create a config.js file, but you already did.

      • You added a module and now MagicMirror won’t load.

      • One of your modules just says “Loading…” on your mirror, but never does.

      • You get a black, or white, or blank screen on your mirror.

      • You get a syntax error reported in your terminal or console

      The wrong way

      If you just copy and paste your code into a topic on the forum, the result will look
      something like this. Not too easy to look at, right? It loses its formatting.
      0_1498693087832_wrong.JPG

      Worse than that

      If someone copies the code that you posted (the wrong way) there is an anomaly that often occurs. Some characters will be changed when pasted, causing the code to fail, and leaving you wondering why because you might not notice what characters were
      changed. The most common unwanted changes concern quotes ', double quotes "
      and the comma ,. Can you say, “Syntax error?”

      The right way

      • The secret is . . . the “back-tick”.

      • If you enter one back-tick at the beginning of a word or words and one back-tick at the end of a word or words, you get “inline code” for that word or words.
        Try it in a post. It should look like this. Or, it can look like this.

      You’ll like this

      • Now we want to post a portion (or all) of our config.js file (or any code) in the forum so that it can be viewed easily (and properly) by the people trying to help us.

      • You use three back-ticks before the code AND three back-ticks after the code. That is how you “fence” blocks of code. You will love the result!

      Remember that code posted above?

      • Well, this is how it looks when you “fence” it in with three back-ticks, before AND
        after the code. Tell me you don’t like this better? 😉
      {
          module: 'MMM - PrayerTime',
          position: 'top_left',
              config: {
              apiVersion: '1.0',
              lat: 12.089796,
              lon: -56.807734,
              timezone: 'EST',
              method: 5,
              playAdzan: ['fajr', 'dhuhr', 'asr’, 'maghrib', 'isha'],
              notDisplayed: ['midnight', 'sunset'],
              useUpdateInterval: true,
              updateInterval: 86400 * 1000,
              animationSpeed: 2.5 * 1000,
              language: "en",
              showAdzanAlert: true,
              alertTimer: 15000
          }
      },
      

      Is it a big deal?

      • No, it’s not, but for the sake of conformity we should all post code this way. You’ll like it better (because it looks nicer) and the people reading it will like it better (because it looks better) and we’ll all be one happy forum family.

      • And besides, it’s the way we’re supposed to be doing it. Climb aboard!

      So, where is the back-tick key on my keyboard?

      • On U.S. QUERTY keyboards it’s to the left of the 1 key (not the Numeric keys)

      0_1498693191442_querty.JPG

      But I don’t use a U.S. QWERTY keyboard!

      • You’ll have to determine where yours is if you use a different keyboard.

      • This is the internet. Look it up. You want me to do everything for you?

      An even easier way.

      • Why did I put you through all that? I don’t know. I had to learn it that way so that’s how I teach it.

      • Just do this and forget everything I said above! Simply clicking the icon indicated by the red arrow will place the correct back-ticks in the correct place, with a highlighted //your code here showing you where to paste your code.0_1498859951243_33.JPG

      Peace! 🙂

      Create a working config
      How to add modules

      1 Reply Last reply Reply Quote 14
      • cowboysdude
        cowboysdude Module Developer last edited by

        Great post!!!!!

        Mykle1 1 Reply Last reply Reply Quote 1
        • Mykle1
          Mykle1 Project Sponsor Module Developer @cowboysdude last edited by

          @cowboysdude

          Just trying to contribute my friend!

          Thanks!

          Create a working config
          How to add modules

          1 Reply Last reply Reply Quote 2
          • A
            Anhalter42 last edited by

            Maybe it should be added that when you have problems finding the correct “back tick” character, you can also use the </> button right above the input field to insert a code-formatted block.

            cowboysdude Mykle1 2 Replies Last reply Reply Quote 1
            • cowboysdude
              cowboysdude Module Developer @Anhalter42 last edited by cowboysdude

              @Anhalter42 said in How to post code on the forum. - For absolute beginners.:

              Maybe it should be added that when you have problems finding the correct “back tick” character, you can also use the </> button right above the input field to insert a code-formatted block.

              Ok noted

              Mykle1 1 Reply Last reply Reply Quote 1
              • Mykle1
                Mykle1 Project Sponsor Module Developer @cowboysdude last edited by Mykle1

                @Anhalter42 said in How to post code on the forum. - For absolute beginners.:

                when you have problems finding the correct “back tick” character,

                Really?

                Create a working config
                How to add modules

                1 Reply Last reply Reply Quote 0
                • paviro
                  paviro Admin last edited by

                  Thanks @Mykle1! Pinned the post to the top 🙂

                  We're all stories in the end. Just make it a good one, eh?

                  – The Doctor

                  Mykle1 1 Reply Last reply Reply Quote 3
                  • Mykle1
                    Mykle1 Project Sponsor Module Developer @paviro last edited by

                    @paviro said in How to post code on the forum - For absolute beginners:

                    Thanks @Mykle1! Pinned the post to the top 🙂

                    That’s fantastic! Thank you, too!

                    Create a working config
                    How to add modules

                    1 Reply Last reply Reply Quote 2
                    • Mykle1
                      Mykle1 Project Sponsor Module Developer @Anhalter42 last edited by

                      @Anhalter42 said in How to post code on the forum - For absolute beginners:

                      you can also use the </> button right above the input field to insert a code-formatted block.

                      Added to the tutorial!

                      Create a working config
                      How to add modules

                      1 Reply Last reply Reply Quote 0
                      • S
                        s199 last edited by

                        i love your "absolute beginners" guides, keep them coming!
                        

                        thanks a lot !

                        Mykle1 2 Replies Last reply Reply Quote 2
                        • 1
                        • 2
                        • 3
                        • 1 / 3
                        • First post
                          Last post
                        Enjoying MagicMirror? Please consider a donation!
                        MagicMirror created by Michael Teeuw.
                        Forum managed by Paul-Vincent Roll and Rodrigo Ramírez Norambuena.
                        This forum is using NodeBB as its core | Contributors
                        Contact | Privacy Policy