Showing posts with label line. Show all posts
Showing posts with label line. Show all posts

2015-01-18

Level Up - Blogger: How to add formatted code to post (with highlighting)

In many of my posts, I like to add code snippets. Blogger doesn't have good native support for displaying code with syntax and line highlighting, so I found a way to add that feature using GitHub Gists and gist-embed project on GitHub.

The following steps can mostly be used with any blog.

Step 1: Include jQuery and gist-embed within your header tags.

<head>
  ...
  <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/gist-embed/2.0/gist-embed.min.js"></script>
</head>


Step 2: Add a code element to where you want your Gist code to appear.

<code data-gist-id=""></code>


Example:



Source:
<code data-gist-file="PrimeNumbers.cpp" data-gist-hide-footer="true"
   data-gist-highlight-line="9,12,35-42" data-gist-id="5789439"></code>


Nice features also included, but not shown above:

  • Ability to show GitHub footer
  • Remove line numbers
  • Load multiple files from a Gist
  • Load a signal file from a Gist
  • Show only certain lines from a file


This article was mainly written for myself in the future, but I hope others can benefit from it, as well.

Links:



~ Danial Goodwin ~



2014-03-11

Level Up - Puzzles: Connect a 4x4 Grid of Dots With 6 Contiguous Lines (Solution)

Before reading this post, you should read my last one which introduces the puzzles better.

A common brain teaser is to connect a 3 by 3 grid of dots with four straight lines without picking up the pencil. After solving a 3x3, try to solve a 4x4, 5x5, etc. I have a proof that all of them have a solution.
Click read more to see the solutions and explanations:

2014-03-08

Level Up - Puzzles: Connect a 4x4 Grid of Dots With 6 Contiguous Lines (5x5 w/8, 6x6 w/10)

(TLDR: After solving a 3x3, try to solve a 4x4, 5x5, etc. I have proof that all of them have a solution.)

A common brain teaser is to connect a 3 by 3 grid of dots with four straight lines without picking up the pencil. See image below:

2014-02-02

Level Up - Windows 8: How to Create a Batch File

Batch (*.bat) files are useful because they allow you to save and reuse commands for the command prompt (or CLI, command-line interface). Also, it is easier to send multiple commands at once, fix typos, and edit the commands.

Batch files are available for Windows 7, 8, and 8.1. Any command that you can put in the CLI, you should be able to put into the BAT file.


Method 1:
- Right-click on your desktop (or in File Explorer), and select New->Text Document. Now, rename the file to something ending with .bat.


Method 2:
- Open Notepad, then when you save the file, make sure to end it with ".bat".

Saving a Batch file requires a .bat ending.
Test the Batch file:
Now that you have the BAT file, you can easily test that it works by putting in the following code, then double-click to run the file.
echo Hello, World!


Here's some more things you can try out: Windows Command Prompt Cheat Sheet


Note: If method 1 didn't work for you, then try method 2.

~ Danial Goodwin ~