Thursday, June 19, 2014

The shy Ion-Delete-Button in Ionic Framework

Took me a while to figure this out. I was trying out Ionic framework for one of my mobile side projects. The learning curve was fairly low if you know a bit of AngularJS-- I got stumped on a simple UI issue however.

I wanted to put a delete button beside the items of my list so my code was like:

<div ng-app="jsApp">
    <div ng-controller="Ctrl1">
        <ion-content>
            <ion-list >
                <ion-item>
                    <ion-delete-button class="ion-minus-circled"></ion-delete-button>Hello, list item!</ion-item>
            </ion-list>
            
        </ion-content>
    </div>
</div>




Hmm.. where's the delete button? Turns out you had to use show-delete="1" directive in the tag.


<div ng-app="jsApp">
    <div ng-controller="Ctrl1">
        <ion-content>
            <ion-list show-delete="1" >
                <ion-item>
                    <ion-delete-button class="ion-minus-circled"></ion-delete-button>Hello, list item!</ion-item>
            </ion-list>
            
        </ion-content>
    </div>
</div>






the source code http://jsfiddle.net/rebooting/5BSNE/

That being said I enjoyed using Ionic Framework a lot, it's a very clean framework.

Wednesday, June 18, 2014

Stop command from being commited to BASH History

I haven't seen this in the older bash environments before so I guess it must be fairly recent. To prevent commands from being committed to history, simply add a space in front of the command. 

Couldn't be more simpler!



Monday, June 16, 2014

Golang: Serving static content using Gorilla

Using the identical directive from ServeMux  "http.Handle("/static/", http.FileServer(http.Dir("./static/")))" for Gorilla to serve static files wasn't working - the directory listing works but clicking on any of the files listed would produce a 404.

There seems to be two ways to configure the mux to serve static content in Gorilla Mux(highlighted in blue)

package main

import (
    "github.com/gorilla/mux"
    "net/http"
)

func main() {
    r := mux.NewRouter()
    r.HandleFunc("/", HomeHandler)

    //This won't work
    //http.Handle("/static/", http.FileServer(http.Dir("./static/")))

    //These will work
    //first alternative
    http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static"))))


    //second alternative
    
    r.PathPrefix("/images/").Handler(http.StripPrefix("/images/",
            http.FileServer(http.Dir("images/"))))
    
    http.Handle("/", r)

    http.ListenAndServe(":3000", nil)
}

func HomeHandler(rw http.ResponseWriter, req *http.Request) {

    rw.Write([]byte("You are at /"))
}







Thursday, June 12, 2014

Misplaced semiconlon and debugging fun in Javascript

This is frustrating and funny at the same time. I've been stuck at this simple condition statement wondering my nulled variable didn't check out true ... for about 5 minutes.

Turns out I totally missed ';' at the end of the if statement, which ended the condition and executed the next block of code anyway.


listview_tasks=null;


...


if(!listview_tasks);
{
    Ti.API.info("why am I here?");

}

Argh.

I blame the tiny font I'm using on my IDE. 

Time for a break me thinks.