Skip to main content

How to add code sample in your Blog

When I started blogging about code examples or sample projects the issue that I use to face was adding the code to my blog. I use to directly copy and paste code in the blog making my blog appear Clumsy.

Behold! Gist is here

Gist is by GitHub for sharing the code and its the best thing that I have seen so far. You can integrate you gist post in the blog and your blog looks clean

Here is an example of how my code looks when I copy and paste directly to the blog

 /* loading spinner */
    .loading {
        position: fixed;
        z-index: 999;
        height: 2em;
        width: 2em;
        overflow: show;
        margin: auto;
        top: 0;
        left: 0;
        bottom: 0;
        right: 0;

    /* :not(:required) hides these rules from IE9 and below */
    .loading:not(:required) {
        /* hide "loading..." text */
        font: 0/0 a;
        color: transparent;
        text-shadow: none;
        background-color: transparent;
        border: 0;

Its clumsy and not appealing

Here is how it looks when I integrate Gist


  1. Go to GIST
  2. Paste your code there 
  3. Its important to give the file extension 
  4. Click on Create public gist button
  5. Copy the script src located on the top 
  6. Add it to your blog (in the HTML code)
  7. Boom your code in your blog looks neat and clean 


Popular posts from this blog

Adding loading spinner to JSP Page using pure CSS and JS

I wanted to add loading spinner to the web application that I was working on. This application is a legacy application and I was looking into a way to add the loading spinner whenever the user performs certain actions such as the following Clicks a button which behind the scene performs CRUD operation When user request data  As the web application was based of JSP and I was looking for a way to adding it to the webpage and finally came across the following solution  Create a div  Add the CSS for the div Create a JS function which gets called on button click.  Here is the code HTML JS      CSS

Simple IOT Project - Electric Imp Led Light Controller

Recently I went to IBM IOT Hackathon and got Electic IMP device and thought of playing with it and this is the first application I created LED Light controller using Electric IMP device and REST webservice. Overview Skill Level: Beginner Below are detailed steps on how to connect an Electric Imp with environmental sensors to the Watson IoT Platform in order to visualize and monitor your refrigerator in real time. Ingridients   Your WIFI *network name* and *password*  A computer with a web browser  Smartphone with the Electric Imp app I OS  or Android A free Electric Imp developer account    An Electric Imp Explorer kit - purchase from Amazon    Three AA batteries STEP BY STEP  Step 1 - What is demonstrated in this example? Use an Electric Imp to switch on/off light sensor and change the color of light using combination of RGB.  Step 2 - Connect your Electric Imp to the Internet  Set Up Hardware  Plug the Imp001 into the Explorer Kit Board .Power up y

Attaching remote debugger in Netbeans

I am working on a web application based on Ant,Struts and Java. I wanted a way to debug the live application in my local environment and I found out that attaching remote debugger is the best option. It helps in debugging live application. What is Remote Debugging? The client/server design of the Java  debugger  allows you to launch a Java program from computer on your network and  debug  it from the workstation running the platform. This is particularly useful when you are developing a program for a device that cannot host the development platform [source: eclipse community] How to enable it in Netbeans Open Netbeans IDE Go to Debug option  Click on Attach Debugger  Enter the host name and port number Click OK Note: Make sure you start the application first before attaching the remote debugger