Posts

KOWTS #3

Image
"To live with no regrets is to live happily."

Generate Random Quotes from a Text File

So to do that, you need a text file full of quotes. HAHAHA Separated by new line. DEMO $('#btn_modal').click(function () { var num = 0; $.ajax({ url: "https://dl.dropboxusercontent.com/u/75734877/taglines.txt", type: "GET", dataType: "text", beforeSend: function () { $('#kowts').show().html('<img src="http://www.feelol.com/Content/images/Loading.gif" />'); }, success: function (t) { var lines = t; var lineArr = lines.split('\n'); num = Math.floor(Math.random() * lineArr.length); $('#kowts').show().text(lineArr[num]); }, error: function(){ alert('Error') } }); }); Split the quotes from text file by "\n" (new line), then get its length and generate a random number between 0 to maximum length. Then use the generated number a...

Kowts #2

Image
This song keeps me awake during office hours. :)

Using Bootstrap Multiselect Values in Django Query

Image
Read the documentation of Bootstrap Multiselect  . Anyway, just include all the files in you html page (head section), you will need these following files (JS and CSS files): //ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js https://dl.dropboxusercontent.com/u/75734877/bootstrap-multiselect.css https://dl.dropboxusercontent.com/u/75734877/bootstrap-multiselect.js Copy and save the files if you want to serve it with your own, and use it like this in your template: <script type="text/javascript" src="{% static "js/bootstrap-multiselect.js" %}"></script> Then refer to this JSFiddle for demo.  Let's say you have this select element in your page with the id, "bldg_type" <select class="form-control" id="bldg_type" multiple="multiple">...

Kowts #1

Image
I have nothing to say here..HAHA :3

All You Have To Do...

Image
...is savor the moment. I think just this time, I'll stop being so pessimistic of the things that is not yet happening. I'm happier now, not because of a TV show or an episode of an anime series but because of a GIRL . I described  her as a cute human being like a puppy or kitten. I love her smile, I love seeing her smile. I love her eyes and the rest of her face ( like Tim to Mary ). HAHA It's awkward seeing myself  of being this much happy. ( grammar eh?!! ) LOL I can't even stop smiling while listening to the song above. Tim: We're all traveling through time together, every day of our lives. All we can do is do our best to relish this remarkable ride. I think, I'll just be "Tim" for a while. It helps. :D

Typeahead Implementation in PHP/MySQL

DEMO First, you need to include all the necessary files for this to work. Place these three files in the head section of your page.. jquery-1.10.2.min.js  bootstrap.min.js bootstrap3-typeahead.min.js Then, this script: $(document).ready(function () { var objects = []; var map = {}; $('#person').typeahead({ source: function (query, process) { $.ajax({ url: 'get_person.php', type: 'POST', dataType: 'JSON', async: true, success: function (data) { objects = []; //resets the objects map = {}; //to avoid duplication $.each(data, function (i, object) { map[object.full_name] = object; objects.push(object.full_name); }); process(objects); } }); }, //end source ...