• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

How to post code on the forum - For absolute beginners

Scheduled Pinned Locked Moved Troubleshooting
26 Posts 10 Posters 18.9k Views 9 Watching
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.
  • M Offline
    Mykle1 Project Sponsor Module Developer
    last edited by Mykle1 Jul 18, 2017, 10:08 PM Jun 28, 2017, 11:40 PM

    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
    • C Offline
      cowboysdude Module Developer
      last edited by Jun 28, 2017, 11:51 PM

      Great post!!!!!

      M 1 Reply Last reply Jun 29, 2017, 12:02 AM Reply Quote 1
      • M Offline
        Mykle1 Project Sponsor Module Developer @cowboysdude
        last edited by Jun 29, 2017, 12:02 AM

        @cowboysdude

        Just trying to contribute my friend!

        Thanks!

        Create a working config
        How to add modules

        1 Reply Last reply Reply Quote 3
        • A Offline
          Anhalter42
          last edited by Jun 29, 2017, 12:07 AM

          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.

          C M 2 Replies Last reply Jun 29, 2017, 12:16 AM Reply Quote 1
          • C Offline
            cowboysdude Module Developer @Anhalter42
            last edited by cowboysdude Jun 29, 2017, 12:17 AM Jun 29, 2017, 12:16 AM

            @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

            M 1 Reply Last reply Jun 29, 2017, 12:18 AM Reply Quote 1
            • M Offline
              Mykle1 Project Sponsor Module Developer @cowboysdude
              last edited by Mykle1 Jun 29, 2017, 12:33 AM Jun 29, 2017, 12:18 AM

              @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
              • paviroP Offline
                paviro Admin
                last edited by Jun 29, 2017, 6:20 AM

                Thanks @Mykle1! Pinned the post to the top :)

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

                – The Doctor

                M 1 Reply Last reply Jun 29, 2017, 11:01 AM Reply Quote 3
                • M Offline
                  Mykle1 Project Sponsor Module Developer @paviro
                  last edited by Jun 29, 2017, 11:01 AM

                  @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
                  • M Offline
                    Mykle1 Project Sponsor Module Developer @Anhalter42
                    last edited by Jul 1, 2017, 12:34 AM

                    @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 Offline
                      s199
                      last edited by Jul 18, 2017, 10:07 PM

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

                      thanks a lot !

                      M 2 Replies Last reply Jul 18, 2017, 10:14 PM 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 Sam, technical setup by Karsten.
                      This forum is using NodeBB as its core | Contributors
                      Contact | Privacy Policy