Wednesday, May 25, 2011

Bundler installing gems in a wrong/different directory

1 comments
So I managed to liven up my experience playing with rails and all it's friggin magics. So I was doing this bundle install stuff and I noticed it was installing in a different directory.

[18:30:04] blah$ bundle
[install]
[install]
[install]
[non stop installing]
[.. aaand]
Your bundle is complete! It was installed into ./postgres


What the!? postgres. I tried digging for configs or stuff on the project but most postgres words wasn't about bundle and postgres. I don't know what I did though to get this situation but I managed to dig something with duckduckgo and found this site (though it's down) and we had a similar problem, though mine was not spork - it was postgres.

Thinking about it, I might have also done something like bundle install postgres.

So I'll also state it here that the way to fix this is

bundle install --system
And then

[18:30:04] blah$ bundle
[non stop installation again.. aand]
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.


Nice!

Wednesday, April 13, 2011

Trying Photoshop

0 comments
So I was kinda engaged in a few projects where I, me, myself need to design the site. Heck. I've only read/studied design principles and some usability stuff for purposes of translating them into HTML/CSS but I haven't designed one from scratch myself.

But yah. I think I'm gonna give it a try as some circumstances demands it right now. So now I've been playing quite a while with photoshop, maybe I'll try out making website templates in PS, or maybe do some wallpaper or stuff like that to get a good feel with photoshop.

Anyways, new thing to learn!

Wednesday, April 6, 2011

New accessory!

2 comments
Haha! Got me self a new accessory to wear. New glasses! Yeah. Hehe.

But I'm actually having problems with my new glass. The lens and frame is very different from before and now I'm feeling a bit dizzy if I'm looking down. I'm also having vertigo. ~___~

Doc said though that this is normal. She said that it would take around a week or so. I hope it really is.

* Alec looted a new accessory
* Alec gets +3 vision but now has vertigo effect
* Alec gets a new weakness: going down a flight of stairs

Friday, February 25, 2011

Need opinion for SureScene

0 comments
Guys I need some opinions for SureScene.

My design for listing events goes something likes this -
 
Normal listing (even when you're not registered) 

It showcases the banners of events. I think it's better this way cause I know how many puts a lot of effort to their banners so it's better to display it than just a simple list. Per date could fit around 5-6 banners of events then it goes down (same like the front page of SureScene).

Now, I did this on the dashboard but my problem is when the events gets a lot it won't fit better than the previous img because of the side panel on the right. See -
Dashboard (where you get updates of event organizers you "follow") 

So you get only around half the space realty of the previous one cause of the side panel.

Now I am trying to redesign the dashboard for this and it came out like this-
Dashboard (where you get updates of event organizers you "follow") 

When you click on banner, it blows up like below 


So now I have kinda fixed it, but it brings me back to a normal listing where the banner is not so visible(well it still displays the banners but in thumbnail and one-click view)...

I also have a few arguments more like cause they are of two different purpose, one is for the normal listing (search/normal view) and the other is for dashboard (where you get updates and stuff). So, What do you guys think I should implement?

Wednesday, February 23, 2011

Computer Science Advices

0 comments
Read on first, it's kinda long but you can first read around the few paragraphs of each of his points to get started (I haven't read everything as well).

http://www.joelonsoftware.com/articles/CollegeAdvice.html

Don't think of reading it in a one sided way. I almost did. I almost said that I don't need to write and stuff like that while I was reading it. But all of what he said has a point.

Heck. His first point is about "writing"! Writing!? I write yes. Not to brag but I can say I write proper English (not talk though), but I can't convey the things I need to. I can say I was really hit by this one single point, I am having a hard time conveying SureScene's point. Struggling because I can't write wittily to event organizers, or even friends. This I have to improve.

But the rest, I would have to say I really agree with him. And as for giving advices, I would have to say I too have a hard time there. But he has given it a bit of thinking, and with good writing skill (I'm still practicing that).

Though the document is a bit old, advices never do. So I think it's a good read.

A little problem, a little opportunity

0 comments
So I have my day job on a little problem lately. We're fixing it. It's nothing new. I think I've gotten used to this kinda problems. Yes I really hate it happening, over and over again. I can say it's fun though. Don't think of me as some masochist, I'm not. I just find the ups-and-downs fun. Hehe.

Anyway, I always find something good on a lot of things happening umn... not good. So I got to spend a lot of time now to work on my personal project SureScene. Got some big updates up and a lot of bug fixes like stuff. Well, if you have some comments, suggestion or problems need action immediately, now's the time to bring them up. :)

Friday, February 4, 2011

MongoDB Error

0 comments
If you happen to pass by this error

[02:33:05] mongodb$ mongo
MongoDB shell version: 1.6.3
connecting to: test
Sat Nov 13 02:33:10 Error: couldn't connect to server 127.0.0.1 (anon):1137
exception: connect failed


Check if your mongo is running by issuing "mongod" command. If you get something like this,

Sat Nov 13 02:30:41 MongoDB starting : pid=294 port=27017 dbpath=/data/db/ 64-bit
Sat Nov 13 02:30:41 db version v1.6.3, pdfile version 4.5
Sat Nov 13 02:30:41 git version: 278bd2ac2f2efbee556f32c13c1b6803224d1c01
Sat Nov 13 02:30:41 sys info: Darwin erh2.10gen.cc 9.6.0 Darwin Kernel Version 9.6.0: Mon Nov 24 17:37:00 PST 2008; root:xnu-1228.9.59~1/RELEASE_I386 i386 BOOST_LIB_VERSION=1_40
Sat Nov 13 02:30:41 exception in initAndListen std::exception: dbpath (/data/db/) does not exist, terminating
Sat Nov 13 02:30:41 dbexit:

Sat Nov 13 02:30:41 shutdown: going to close listening sockets...
Sat Nov 13 02:30:41 shutdown: going to flush oplog...
Sat Nov 13 02:30:41 shutdown: going to close sockets...
Sat Nov 13 02:30:41 shutdown: waiting for fs preallocator...
Sat Nov 13 02:30:41 shutdown: closing all files...
Sat Nov 13 02:30:41 closeAllFiles() finished

Sat Nov 13 02:30:41 dbexit: really exiting now


You can see a lot of things to do here but you should probably check on your log file to see some errors while your mongo wouldn't start. When I tailed my logs, I saw a different error stated like so

**************
old lock file: /usr/local/mongodb/data/mongod.lock. probably means unclean shutdown
recommend removing file and running --repair
see: http://dochub.mongodb.org/core/repair for more information
**************


And yes I did came from a crash. So I checked and removed the file and it automatically ran again based on my existing tail on the logs and it was back again.

Hope this helps somebody else as well.

Thursday, December 16, 2010

We finished moving

0 comments
Hi guys. I'm back! Wasn't able to post anything before cause we were planning on moving, our 1 year contract on our place ended and we decided to move to a different place as well. Hehe.
So yah, now were finished moving but the place looks like a storage area for now. Haven't unpacked anything yet, will do it maybe on the weekends.
The place looks nice, a bit smaller than our previous place but I think it's much cooler and it's on tiles, much colder floor, Yeah :]!
And my muscles ache like hell right now. We've been moving stuff from our place downwards (2nd floor), then moving them back up (3rd floor) to the place we moved in. Haha. So me and my friends were like dead tired after moving all our stuff. >_<

Well as for my project surescene, I've done a few updates a while back and I got it back and running again.

Friday, September 17, 2010

Ramaze and Mongo(DB and mapper): Day 2

1 comments
I've read on most documents before, that when using the NoSQL world it is still better to use it with RDBMS. Correct me if I'm wrong with this one, is it better to use them together or use them apart. If you have documents or links discussing this one, leave them in the comments, I'd love to read them. Also if so,
I'd like to know more is how should I separate them? Like what tables/collections would/should be this NoSQL or SQL?

So I tried testing with MongoDB and Sequel to make them play together and it was quite easy. If you have been using Ramaze before with Sequel, just do the same thing as before then just add configurations for the Mongo (which I also forgot to write configurations on my first part).

Configuration
with both MongoDB and Sequel
require 'rubygems'
require 'ramaze'
require 'yaml'

require 'bson'
require 'mongo_mapper'
require 'sequel'
require 'erubis'

MongoMapper.database = 'mongoplay'

Ramaze.options.layouts = '/view/layout'
Ramaze.options.mode = :dev

Ramaze.options.roots = [__DIR__] # Make sure that Ramaze knows where you are

Sequel.mysql(
  'mongoplay',
  :user => 'uname',
  :password => 'pword',
  :host => localhost
)

# Acquire controllers and models and other utilities
Ramaze.acquire 'util/*'
Ramaze.acquire 'model/base.rb', 'model/*'
Ramaze.acquire 'controller/base.rb', 'controller/*'
Ramaze.acquire 'config/routes.rb'


In the previous post on this topic, I was using a messaging/posting system and in here, I added a users table on a MySQL so we could tie some posts to a user if ever they wanted to register (I won't discuss here how to register/authenticate the user for now but you could use this link if so ever, that's what I used before). So the same model would apply ordinarily. I was using the user helper here.

User model
class User < Sequel::Model
  def self.register(email, password)
    User.create :email => email, :password => encrypt(password, salt), :salt => Digest::SHA1.hexdigest("--#{Time.now.to_f}--#{email}--")
  end

...


And now to insert posts and tie them to a certain user. You can also define the key in the message model or don't and you'd still insert them the same like so:
...
  if logged_in?
    Message.create :name => user.username, :body => request[:body], :user_id => user.id
  else
    Message.create :name => request[:name], :body => request[:body]
  end
...

And I just basically did the same with the comments section.

Now, now, to pull all the messages that a certain user has made:
class UsersController < Ramaze::Controller
  map '/users'

  def index(id)
    @msgs = Message.all :user_id => id.to_i
  end
end

If ever you were using a different model, just query first in the SQL table then query in the Mongo or vice-versa. :D

Wednesday, September 8, 2010

Ramaze and Mongo(DB and mapper): Day 1

0 comments
Edit ** I forgot to mention here how you would write a configuration file but you can check out my next post which mentions a small config for mongoDB and also for Sequel.

Okay. So day 1. I've chosen to use MongoMapper for now over the other two I've provided last post. MongoMapper is quite good, I haven't read/delved into their code but he said it was readable so looking forward to it. I just hope they don't make MongoMapper too rails-specific.

Okay, so moving on. I've started with the basics of most apps that is "Inserting data" on a "Collection". And having a "One to Many" relationship. This is just a basic app where you could post and comment to demonstrate. I assume here that you already have working applications and just want to start out using MongoDB.

The model would look like this.
Message Model
class Message
  include MongoMapper::Document

  key :name, String, :require => true
  key :body, String, :require => true
  timestamps! # This would create a "created_at" and "updated_at" keys on create

  many :comments
end

Take note that I have defined keys in the model. The keys can have typecast but it doesn't require you to have one. Also, you need not to define every key in the model as documents are schema-less, that's also one of the reasons of using MongoDB (unkown unknowns).

So for example you have a key :blah.
Test Model
class Test
  include MongoMapper::Document

  key :blah
end
Test.create :blah => 42
# => { "_id" : ObjectId("..."), "blah" : 42 }

Test.create :blah => "the answer"
# => { "_id" : ObjectId("..."), "blah" : "the answer" }

Test.create :blah => 42, :answer => "ultimate question"
# => { "_id" : ObjectId("..."), "blah" : 42, "answer" => "ultimate question" }

Okay. Going back to inserting records (but I think I've shown that already in the test). I only have basic information for now but here is a snippet of posting.
  def post
    if request.post?
      Message.create :name => request[:name], :body => request[:body]
      redirect r(:/)
    end
  end

Upon posting a message here, the data would look something like this.
{ "_id" : ObjectId("..."), "name" : "Post 2", "created_at" : "Tue Sep 07 2010 18:31:45 GMT 0800 (PHT)", "body" : "Test Body!", "updated_at" : "Tue Sep 07 2010 18:31:45 GMT 0800 (PHT)" }
Now I'd like to step on to relations, embedded documents.
Did you notice the last line before ending the MessageModel? It is a many relationship to comments. A comment model would look like this:
Comment Model
class Comment
  include MongoMapper::EmbeddedDocument

  key :name, String, :require => true
  key :body, String, :require => true
end

Note on the line 2 EmbeddedDocument would embed this document on the Message document. To try it out:
Per post snippet
  def posts(id = nil)
    id = id || request[:id]
    redirect r(:/) unless @msg = Message.find(id)

    if request.post?
      @msg.comments << Comment.new(:name => request[:name], :body => request[:body])
      @msg.save
    end
  end

This would produce a record like this
{ "_id" : ObjectId("4c8618b6be9294085d000001"), "name" : "Post 3", "created_at" : "Tue Sep 07 2010 18:49:26 GMT 0800 (PHT)", "comments" : [
    {
        "name" : "Tester",
        "body" : "Comment Yah!",
        "_id" : ObjectId("4c862781be929409d100000a")
    }
], "body" : "Another test body!", "updated_at" : "Tue Sep 07 2010 19:52:33 GMT 0800 (PHT)" }

Then when you pull the data from the "Per post snippet". You could iterate on the comments like so:
  <% @msg.comments.each do |c| %>
    <%= c.name %><br />
    <%= c.body %><br />
  <% end %>

This app and idea is far from perfect as it would still require validations and some form of filter to remove scripts but you get the gist of it. Also, I didn't include the views as I haven't written them completely as well, they are just basic forms with inputs and textareas and iterations for display but I think you all get what they would look like. If you need to see it, post a comment and I'll email it to you.

I don't know if I have written it awesome for now but I would like to hear how others are doing with Ramaze with MongoDB and MongoMapper.

Also, here is a complete code of the controller:
class MessagesController < Ramaze::Controller
  map '/'

  def index
    @msgs = Message.all
  end

  def post
    if request.post?
      Message.create :name => request[:name], :body => request[:body]
      redirect r(:/)
    end
  end

  def posts(id = nil)
    id = id || request[:id]
    redirect r(:/) unless @msg = Message.find(id)

    if request.post?
      @msg.comments << Comment.new(:name => request[:name], :body => request[:body])
      @msg.save
    end
  end
end

Monday, September 6, 2010

MongoDB start!

0 comments
I'll be playing around with MongoDB in the coming years and I think changing to this schema-less style works.

Installation


I've followed this link to install MongoDB on Snow Leopard. If you happen to get some errors here, make sure that all paths stated in the that document are created or else you'll get nasty errors. I was trying to mimic the errors I had before but I can't seem to get them again. Anyway, afterward, install the ruby driver to use here.

And now I'm looking at some mappers to use. I'm looking at MongoMapper or Candy or looking also at mongomatic while looking at tutorials and documents to play with mongoDB.

If you guys have any suggestions to help me out, please post on the comments.

Manipulating HTML checkbox using jQuery

0 comments
A small simple example or tutorial on how to manipulate HTML checkboxes with javascript with the help of jQuery (v1.4.2).

Here, I've given a sample on how to
  • select (check) checkboxes
  • deselect (uncheck) checkboxes
  • reverse select (check/uncheck)
  • do something with your selected checkboxes

Hope anyone finds it useful as I have.

Here is the HTML of the selectors and the group of checkbox. A textbox is written below as I will use it to sample what you have selected.
<div>
  <a id="select_all">Select all</a> | <a id="deselect_all">Deselect all</a> |
  <a id="reverse_select">Reverse</a> | <a id="submit_select">Submit</a>
</div>
<ul id="checkbox_container">
  <li>
    <input id="checkbox_1" type="checkbox" value="1" />
    <label for="checkbox_1">Checkbox 1</label>
  </li>
  <li>
    <input id="checkbox_2" type="checkbox" value="2" />
    <label for="checkbox_2">Checkbox 2</label>
  </li>
  <li>
    <input id="checkbox_3" type="checkbox" value="3" />
    <label for="checkbox_3">Checkbox 3</label>
  </li>
  <li>
    <input id="checkbox_4" type="checkbox" value="4" />
    <label for="checkbox_4">Checkbox 4</label>
  </li>
</ul>
<input id="write_to_me" type="text" />

Here is the Javascript (jQuery) to use.
$(document).ready(function() {
  $("#select_all").click(function() {
    $("#checkbox_container").find(':checkbox').attr('checked', 'checked');
  });

  $("#deselect_all").click(function() {
    $("#checkbox_container").find(':checkbox').removeAttr('checked');
  });

  $("#reverse_select").click(function() {
    $("#checkbox_container").find(':checkbox').each(function() {
      if (this.checked)
        $(this).removeAttr('checked');
      else
        $(this).attr('checked', 'checked');
    });
  });

  $("#submit_select").click(function() {
    checks = new Array();
    $("#checkbox_container").find(':checked').each(function() { checks.push($(this).val()); });
    $("#write_to_me").val(checks.join(','));
  });
});

Good luck!

Saturday, September 4, 2010

Just a quick update on Traxier

0 comments
Traxier is having a party at Las Vegas at the Palms today and tomorrow their time.

Thursday, September 2, 2010

Traxier's been posted at CNBC

0 comments
Yey!! We've been posted to news already at CNBC. Check out this link to see the news. Hehe! See yah there.

Monday, August 23, 2010

A taste of Mongo

0 comments
I'm having a lot of things to do lately. Lots of projects I'm thinking of doing, on top of projects I really have to do, and that is aside from my day job, Traxier (which I/we have to focus on for now because hard launch is approaching, early September this year I think).

So aside from Traxier, I'm trying to finish up alpha stage of SureScene as I want to get surescene something to do aside from just posting and sharing events and scenes.
I also have to learn design, webdesign. I have to come up with a nice design for a media site my friends and my brother are wanting their own site. Haha! I even bought a mouse to use just for designing (or maybe for playing SC2 when I get the chance to buy the game). :P Well layout-ing is easy as I've already got the taste of HTML and CSS, but playing with what color or image or design to do is harder than I thought, my designs always end up bland for my taste. XD

I also want to try and play with MongoDB right now. I'm trying to think of a simple app that could use the MongoDB so I could get a taste of how it works, and also get a feel of how NoSQL (schema-free / Document oriented DB's) works. I've already read and heard many things about it and just started installing it on Ayie.
Maybe after a few tries of MongoDB and getting the hang of what should be RDBMS and not in an application. I'll try implementing it on SureScene and see what it can do and maybe I'll get more involved in it.

And now I also want to try out HTML5's websocket, I bet this will change a lot for webdevelopment which was "usually" just one way.

Thursday, August 12, 2010

An awesome day

0 comments
Haha! I know I made this blog to write stuff but I got a bit busy over work.

We were actually on lock down at our office in Boni. We had to finish one whole site in around 1-2 weeks but man, it's so worth it. With the power of isaw on sticks and bacchus cans, we pushed to finish it on time. I'm already having shivers right now. We have our site up now, today, aug12'10, for soft launch but it is live now. Visit Traxier to check out our hardwork. It's still wip but it's there now! Yey and proud!

O and also been doing my personal project Surescene and it's working great. Would be having some updates but please do check it out. It's a local site (for now) that's suppose to post search and share events and scenes around Manila and what-not.

Anyway, we're having a meeting now. Be back with stuff next time. :D

Friday, July 23, 2010

A (not so) little introduction about my blog

2 comments
Hi guys. Alec Guintu here. A ruby/ramaze web developer in the Philippines. Not much of a blogger yet (it's my second time actually, I forgot about the first one) but I'll see what I can do about that. I've heard that blogging helps. I get to share what I want to say, listen to what others thinks about it and get to learn some new things as well. It's also a good way to socialize with different people who maybe shares a common interest.

My first intention on blogging was so that I'd have a help-myself-guide on things I do. A reference. Something to look back to when I need it again when some things go wrong. And while thinking about it, maybe it can also help others like it has helped me.

Well mostly I'd be blogging about technical stuff. Firstly would be ruby, a programming language I chose not much long ago. It started when we had to use a new one back at my first job, and you could say it was love at first sight then. I was using Ruby on Rails before but when I tested out Ramaze I chose this one. I feel much comfortable with it and it doesn't have much of those auto-magic stuff. So yah, mostly this blog would contain things I learn about ruby/ramaze and things related to them.

Another would be about "Ayie", my Macbook. It would mostly contain installation instructions for me and what I did with Ayie. So maybe when I reinstall or maybe upgrade Ayie, I'd have an easy reference on what I need to do.

And maybe while I'm at it, I'd also be posting some things about me. Hehe! My adventures and stuff. I don't know, this is just a big maybe.

So yah. There I think I got one down. Though it kinda feels awkward typing about trying to talk to an audience (or you don't even know if they exist). Hehe. Maybe I'll get the hang of this sometime.