March 26, 2012

WebPM Slider – Image Slider Plugin for WordPress

Image Slider Plugin for WordPress

webpm-slider

WebPM Gallery – Image Gallery Plugin for WordPress

First Version of my Image Gallery Plugin for WordPress.

webpm-gallery

February 2, 2011

Wireless Doesn’t Work in Ubuntu 10.10

For the longest time, I couldn’t figure out how to get my wireless to on my laptop. I could enable and disable my wireless card, but I could never scan and view available wireless channels. After searching many forums, I came across an article that suggested this.

rfkill unblock all

After you run this command, disable and enable your wireless card. If your problem was similar to mine, then you should be able to see wireless channels and connect. I’m not sure exactly why this works, but it worked for me. Feel free to explain if you know why this solution works. I am curious.

I hope this helps someone out. I’m very thankful I was able to come across the solution.

http://life.firelace.com/2010/10/tips-and-tricks-upgrading-to-ubuntu-10-10-wireless-fix/

February 1, 2011

Rename Files in Windows 7 using the Command Prompt

I came across a situation where a client of mine needed a whole batch of pictures renamed to display “underscores” instead of “dashes”. For example, I needed the following to be changed:

W-Lawther-4311-1263.jpg
W_Lawther_4311_1263.jpg

Going through each individual file and manually changing each dash to an underscore would be painstaking. I did some research and found a very simple solution to this problem.

ren ?-???????-????-????.jpg ?_???????_????_????.jpg

Open up the Command Prompt (Start->Run->Type: cmd)
Navigate to your directory using the ‘cd’ command and display the contents of your directory using the ‘dir’ command. Here is an example of the process I went through.

Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
 
C:\Users\Chris>dir
 Volume in drive C has no label.
 Volume Serial Number is BC3E-4FC9
 
 Directory of C:\Users\Chris
 
01/24/2011  08:22 AM    <DIR>          .
01/24/2011  08:22 AM    <DIR>          ..
01/24/2011  03:03 PM    <DIR>          Contacts
01/31/2011  05:54 PM    <DIR>          Desktop
01/28/2011  02:27 PM    <DIR>          Documents
01/31/2011  04:02 AM    <DIR>          Downloads
01/24/2011  03:03 PM    <DIR>          Favorites
01/24/2011  03:03 PM    <DIR>          Links
01/24/2011  03:03 PM    <DIR>          Music
02/01/2011  09:56 AM    <DIR>          Pictures
01/24/2011  03:03 PM    <DIR>          Saved Games
01/24/2011  03:03 PM    <DIR>          Searches
01/24/2011  03:03 PM    <DIR>          Videos
               0 File(s)              0 bytes
              13 Dir(s)  66,118,414,336 bytes free
 
C:\Users\Chris>cd Pictures
 
C:\Users\Chris\Pictures>dir
 Volume in drive C has no label.
 Volume Serial Number is BC3E-4FC9
 
 Directory of C:\Users\Chris\Pictures
 
02/01/2011  09:56 AM    <DIR>          .
02/01/2011  09:56 AM    <DIR>          ..
02/01/2011  10:11 AM    <DIR>          4311 W Lawther 550
09/18/2010  11:13 AM           242,056 Earth.jpg
               1 File(s)        242,056 bytes
               3 Dir(s)  66,118,414,336 bytes free
 
C:\Users\Chris\Pictures>cd "4311 W Lawther 550"
 
C:\Users\Chris\Pictures\4311 W Lawther 550>dir
 Volume in drive C has no label.
 Volume Serial Number is BC3E-4FC9
 
 Directory of C:\Users\Chris\Pictures\4311 W Lawther 550
 
02/01/2011  10:11 AM    <DIR>          .
02/01/2011  10:11 AM    <DIR>          ..
02/01/2011  10:11 AM    <DIR>          JPEG
01/20/2011  02:29 PM           190,939 W-Lawther-4311-1003.jpg
01/20/2011  02:29 PM           229,187 W-Lawther-4311-1011.jpg
01/20/2011  02:29 PM           362,945 W-Lawther-4311-1019.jpg
01/20/2011  02:29 PM           315,891 W-Lawther-4311-1025.jpg
01/20/2011  02:29 PM           324,793 W-Lawther-4311-1037.jpg
01/20/2011  02:29 PM           298,915 W-Lawther-4311-1054.jpg
01/20/2011  02:29 PM           311,920 W-Lawther-4311-1062.jpg
01/20/2011  02:29 PM           218,105 W-Lawther-4311-1069.jpg
01/20/2011  02:30 PM           284,679 W-Lawther-4311-1092.jpg
01/24/2011  03:50 PM           179,684 W-Lawther-4311-1097.jpg
01/24/2011  03:55 PM           215,851 W-Lawther-4311-1132.jpg
01/24/2011  03:53 PM           119,409 W-Lawther-4311-1183.jpg
01/24/2011  03:53 PM           121,753 W-Lawther-4311-1192.jpg
01/24/2011  03:53 PM           130,715 W-Lawther-4311-1201.jpg
01/24/2011  03:50 PM           191,201 W-Lawther-4311-1216.jpg
01/24/2011  03:50 PM           188,831 W-Lawther-4311-1225.jpg
01/24/2011  03:53 PM           163,884 W-Lawther-4311-1242.jpg
01/24/2011  03:51 PM           215,726 W-Lawther-4311-1251A.jpg
01/24/2011  03:53 PM           174,017 W-Lawther-4311-1263.jpg
01/24/2011  03:54 PM           170,680 W-Lawther-4311-1273.jpg
01/24/2011  03:54 PM           150,399 W-Lawther-4311-1283.jpg
01/24/2011  03:51 PM           189,790 W-Lawther-4311-1289.jpg
01/24/2011  03:51 PM           169,936 W-Lawther-4311-1307.jpg
01/24/2011  03:51 PM           171,228 W-Lawther-4311-1321.jpg
01/24/2011  03:54 PM           155,343 W-Lawther-4311-1333.jpg
01/20/2011  02:29 PM           319,921 W-Lawther-4311-2048.jpg
01/20/2011  02:30 PM           227,850 W-Lawther-4311-2081.jpg
01/24/2011  03:55 PM           168,058 W-Lawther-4311-2144.jpg
              28 File(s)      5,961,650 bytes
               3 Dir(s)  66,118,414,336 bytes free
 
C:\Users\Chris\Pictures\4311 W Lawther 550>ren ?-???????-????-????.jpg ?_???????
_????_????.jpg
 
C:\Users\Chris\Pictures\4311 W Lawther 550>dir
 Volume in drive C has no label.
 Volume Serial Number is BC3E-4FC9
 
 Directory of C:\Users\Chris\Pictures\4311 W Lawther 550
 
02/01/2011  10:35 AM    <DIR>          .
02/01/2011  10:35 AM    <DIR>          ..
02/01/2011  10:34 AM    <DIR>          JPEG
01/20/2011  02:29 PM           190,939 W_Lawther_4311_1003.jpg
01/20/2011  02:29 PM           229,187 W_Lawther_4311_1011.jpg
01/20/2011  02:29 PM           362,945 W_Lawther_4311_1019.jpg
01/20/2011  02:29 PM           315,891 W_Lawther_4311_1025.jpg
01/20/2011  02:29 PM           324,793 W_Lawther_4311_1037.jpg
01/20/2011  02:29 PM           298,915 W_Lawther_4311_1054.jpg
01/20/2011  02:29 PM           311,920 W_Lawther_4311_1062.jpg
01/20/2011  02:29 PM           218,105 W_Lawther_4311_1069.jpg
01/20/2011  02:30 PM           284,679 W_Lawther_4311_1092.jpg
01/24/2011  03:50 PM           179,684 W_Lawther_4311_1097.jpg
01/24/2011  03:55 PM           215,851 W_Lawther_4311_1132.jpg
01/24/2011  03:53 PM           119,409 W_Lawther_4311_1183.jpg
01/24/2011  03:53 PM           121,753 W_Lawther_4311_1192.jpg
01/24/2011  03:53 PM           130,715 W_Lawther_4311_1201.jpg
01/24/2011  03:50 PM           191,201 W_Lawther_4311_1216.jpg
01/24/2011  03:50 PM           188,831 W_Lawther_4311_1225.jpg
01/24/2011  03:53 PM           163,884 W_Lawther_4311_1242.jpg
01/24/2011  03:51 PM           215,726 W_Lawther_4311_1251.jpg
01/24/2011  03:53 PM           174,017 W_Lawther_4311_1263.jpg
01/24/2011  03:54 PM           170,680 W_Lawther_4311_1273.jpg
01/24/2011  03:54 PM           150,399 W_Lawther_4311_1283.jpg
01/24/2011  03:51 PM           189,790 W_Lawther_4311_1289.jpg
01/24/2011  03:51 PM           169,936 W_Lawther_4311_1307.jpg
01/24/2011  03:51 PM           171,228 W_Lawther_4311_1321.jpg
01/24/2011  03:54 PM           155,343 W_Lawther_4311_1333.jpg
01/20/2011  02:29 PM           319,921 W_Lawther_4311_2048.jpg
01/20/2011  02:30 PM           227,850 W_Lawther_4311_2081.jpg
01/24/2011  03:55 PM           168,058 W_Lawther_4311_2144.jpg
              28 File(s)      5,961,650 bytes
               3 Dir(s)  66,118,410,240 bytes free
 
C:\Users\Chris\Pictures\4311 W Lawther 550>cd JPEG
 
C:\Users\Chris\Pictures\4311 W Lawther 550\JPEG>dir
 Volume in drive C has no label.
 Volume Serial Number is BC3E-4FC9
 
 Directory of C:\Users\Chris\Pictures\4311 W Lawther 550\JPEG
 
02/01/2011  10:34 AM    <DIR>          .
02/01/2011  10:34 AM    <DIR>          ..
02/01/2011  10:11 AM            38,673 W-Lawther-4311-1003.jpg
02/01/2011  10:11 AM            39,929 W-Lawther-4311-1011.jpg
02/01/2011  10:11 AM            41,485 W-Lawther-4311-1019.jpg
02/01/2011  10:11 AM            39,100 W-Lawther-4311-1025.jpg
02/01/2011  10:11 AM            39,778 W-Lawther-4311-1037.jpg
02/01/2011  10:11 AM            38,511 W-Lawther-4311-1054.jpg
02/01/2011  10:11 AM            38,979 W-Lawther-4311-1062.jpg
02/01/2011  10:11 AM            36,873 W-Lawther-4311-1069.jpg
02/01/2011  10:11 AM            39,101 W-Lawther-4311-1092.jpg
02/01/2011  10:11 AM            36,034 W-Lawther-4311-1097.jpg
02/01/2011  10:11 AM            39,793 W-Lawther-4311-1132.jpg
02/01/2011  10:11 AM            34,166 W-Lawther-4311-1183.jpg
02/01/2011  10:11 AM            34,872 W-Lawther-4311-1192.jpg
02/01/2011  10:11 AM            33,423 W-Lawther-4311-1201.jpg
02/01/2011  10:11 AM            38,824 W-Lawther-4311-1216.jpg
02/01/2011  10:11 AM            38,824 W-Lawther-4311-1225.jpg
02/01/2011  10:11 AM            36,862 W-Lawther-4311-1242.jpg
02/01/2011  10:11 AM            39,910 W-Lawther-4311-1251.jpg
02/01/2011  10:11 AM            36,474 W-Lawther-4311-1263.jpg
02/01/2011  10:11 AM            35,538 W-Lawther-4311-1273.jpg
02/01/2011  10:11 AM            36,691 W-Lawther-4311-1283.jpg
02/01/2011  10:11 AM            42,598 W-Lawther-4311-1289.jpg
02/01/2011  10:11 AM            35,948 W-Lawther-4311-1307.jpg
02/01/2011  10:11 AM            36,512 W-Lawther-4311-1321.jpg
02/01/2011  10:11 AM            36,163 W-Lawther-4311-1333.jpg
02/01/2011  10:11 AM            39,918 W-Lawther-4311-2048.jpg
02/01/2011  10:11 AM            36,907 W-Lawther-4311-2081.jpg
02/01/2011  10:11 AM            37,046 W-Lawther-4311-2144.jpg
              28 File(s)      1,058,932 bytes
               2 Dir(s)  66,118,410,240 bytes free
 
C:\Users\Chris\Pictures\4311 W Lawther 550\JPEG>ren ?-???????-????-????.jpg ?_??
?????_????_????.jpg
 
C:\Users\Chris\Pictures\4311 W Lawther 550\JPEG>dir
 Volume in drive C has no label.
 Volume Serial Number is BC3E-4FC9
 
 Directory of C:\Users\Chris\Pictures\4311 W Lawther 550\JPEG
 
02/01/2011  10:36 AM    <DIR>          .
02/01/2011  10:36 AM    <DIR>          ..
02/01/2011  10:11 AM            38,673 W_Lawther_4311_1003.jpg
02/01/2011  10:11 AM            39,929 W_Lawther_4311_1011.jpg
02/01/2011  10:11 AM            41,485 W_Lawther_4311_1019.jpg
02/01/2011  10:11 AM            39,100 W_Lawther_4311_1025.jpg
02/01/2011  10:11 AM            39,778 W_Lawther_4311_1037.jpg
02/01/2011  10:11 AM            38,511 W_Lawther_4311_1054.jpg
02/01/2011  10:11 AM            38,979 W_Lawther_4311_1062.jpg
02/01/2011  10:11 AM            36,873 W_Lawther_4311_1069.jpg
02/01/2011  10:11 AM            39,101 W_Lawther_4311_1092.jpg
02/01/2011  10:11 AM            36,034 W_Lawther_4311_1097.jpg
02/01/2011  10:11 AM            39,793 W_Lawther_4311_1132.jpg
02/01/2011  10:11 AM            34,166 W_Lawther_4311_1183.jpg
02/01/2011  10:11 AM            34,872 W_Lawther_4311_1192.jpg
02/01/2011  10:11 AM            33,423 W_Lawther_4311_1201.jpg
02/01/2011  10:11 AM            38,824 W_Lawther_4311_1216.jpg
02/01/2011  10:11 AM            38,824 W_Lawther_4311_1225.jpg
02/01/2011  10:11 AM            36,862 W_Lawther_4311_1242.jpg
02/01/2011  10:11 AM            39,910 W_Lawther_4311_1251.jpg
02/01/2011  10:11 AM            36,474 W_Lawther_4311_1263.jpg
02/01/2011  10:11 AM            35,538 W_Lawther_4311_1273.jpg
02/01/2011  10:11 AM            36,691 W_Lawther_4311_1283.jpg
02/01/2011  10:11 AM            42,598 W_Lawther_4311_1289.jpg
02/01/2011  10:11 AM            35,948 W_Lawther_4311_1307.jpg
02/01/2011  10:11 AM            36,512 W_Lawther_4311_1321.jpg
02/01/2011  10:11 AM            36,163 W_Lawther_4311_1333.jpg
02/01/2011  10:11 AM            39,918 W_Lawther_4311_2048.jpg
02/01/2011  10:11 AM            36,907 W_Lawther_4311_2081.jpg
02/01/2011  10:11 AM            37,046 W_Lawther_4311_2144.jpg
              28 File(s)      1,058,932 bytes
               2 Dir(s)  66,118,402,048 bytes free
 
C:\Users\Chris\Pictures\4311 W Lawther 550\JPEG>

December 21, 2010

Executable Prolog CLP Program for the Following Job Shop Scheduling Problem

The job shop scheduling problem has a wide range of applications in industry. The problem we will explore is a simple job shop scheduling for a print shop. The print shop has 6 machines: [printer, stapler, sorter, binder, packager, copier], and schedules a number of jobs over a two day (48 hour) period. Each job is a sequence of tasks which have a name, duration (in hours) and machine that they must be performed on. A schedule assigns a start time for each task, so that no task starts before the previous task in the job has finished, and no machine is busy with two tasks at the same time. The main user defined predicate defined to solve the scheduling problem is data(TaskList, Jobs, Machines, Vars) where

  • TaskList is a list of tasks. Each task is represented as a term task(Name, Duration, Machine, StartTime) where Name, Duration, StartTime are the name, start time, and duration of the task, Machine is the machine the task needs.
  • Jobs is a list of jobs which in turn by definition is a list of tasks. Each job in this list consists of the tasks that make up this job in the order that they should be completed,
  • Machines is the list of all machines in the shop, and
  • Vars is the list of all start time variables (of the tasks).

As an example, data/4 below describes a pair of small advertising print jobs.

data(
   %%% First argument is a list of tasks with name, duration
   %%% and machine and start time (unconstrained)
   [
     task(ad1_copy, 4, copier, AC1),
     task(ad1_sort, 4, sorter, AS1),
     task(ad1_pack, 3, packager, AD1),
     task(ad2_copy, 5, copier, AC2),
     task(ad2_sort, 4, sorter, AS2),
     task(ad2_pack, 4, packager, AD2)
   ],
   %%% second argument is a list of lists of task names to be
   %%% performed in order
   [[ad1_copy,ad1_sort,ad1_pack],
    [ad2_copy,ad2_sort,ad2_pack]
   ],
   %%% third argument is the list of different machines
   [copier,sorter,packager],
   %%% fourth argument is the list of all start time variables
   [AC1,AS1,AD1,AC2,AS2,AD2]
).

The file ’job.pl’ above, containing the data/4, should be saved under the same directory as your program. When your program is tested, it should be able to handle more jobs and each job may have more tasks. This program uses the template schedule-template.pl, below.

%% This is a program stub for the job shop scheduling problem
%% given in the project.
 
% Load in finite domain module
:- use_module(library(clpfd)).
% Other modules you may use are loaded here
 
% You must use the following to load in the data
:-['job.pl'].
 
% Your definition of the userdefined constraint jobshop(L) should be here.
 
member(X,[X|_]).
member(X,[_|T]):-
	member(X,T).
 
jobshop(L) :-
	data(W,X,_,Z),
	init(W),
	precLL(X,W),
	capacity(W),
	labeling([],Z),
	L = Z.
 
init([]).
init(TASKLIST):-
	TASKLIST=[task(_,D,_,ST)|T],
	ST in 0..48,
	ST+D #=< 48,
	init(T).
 
precLL([], _).
precLL(JOBS,TASKLIST) :-
	JOBS = [H|T],
	precL(H, [2], TASKLIST),
	precLL(T,TASKLIST).
 
precL(_, [], _).
precL([], _, _).
precL(JOBS, _, TASKLIST) :-
	JOBS=[H|T], T=[HH|TT],
	member(task(H,D1,_,T1), TASKLIST),
	member(task(HH,_,_,T2), TASKLIST),
	T1 + D1 #< T2,
	%write(H), write('-'), write(HH),write('\n'),
	precL(T, TT,TASKLIST).
 
exlude(T1, D1, T2, _) :-
	T1 + D1 #< T2.
exlude(T1, _, T2, D2) :-
	T2 + D2 #< T1.
 
capacity([]).
capacity(TASKLIST) :-
	TASKLIST = [task(J,D,M,_)|T],
	%write(J), write('-'), write(D), write('-'), write(M), write('-'), write(ST), write('\n'),
	nonoverlaps(J,D,M,T,TASKLIST),
	capacity(T).
 
nonoverlaps(_,_,_,[],_).
nonoverlaps(J,D,M,L,TASKLIST) :-
	L = [task(_, _, M2, _) | T],
	M \= M2,
	nonoverlaps(J,D,M,T,TASKLIST).
nonoverlaps(J,D,M,L,TASKLIST) :-
	L=[task(_,D2,M2,T2)|T],
	M = M2,
	member(task(J,D,M,T1),TASKLIST),
	exlude(T1,D,T2,D2),
	nonoverlaps(J,D,M,T,TASKLIST).
 
% Your rules should not go below this line
 
% Don't delete or comment away the following
 
%% Output the solution
myoutput :- jobshop(L),
 	    write('The starting time of the tasks are: \n'),
            myprint(L, 1).
 
%% this is to output the sarting time
myprint([], _).
myprint([X|L], I) :- write('task '), write(I), write(' starts at '),
                   write(X), write('\n'), Y #= I+1, myprint(L, Y).
 
%% initiat the output.
:- myoutput.

Sample query and output under Sicstus Prolog

banana$ sicstus
SICStus 3.11.2 (sparc-solaris-5.7): Wed Jun  2 11:43:16 MET DST 2004
Licensed to ttu.edu
| ?- ['schedule-template.pl'].
% consulting /home/undergrad3/ebaldelo/schedule-template.pl...
%  loading /usr/local/lib/sicstus-3.11.2/library/clpfd.po...
%  module clpfd imported into user
%   loading /usr/local/lib/sicstus-3.11.2/library/atts.po...
%   module attributes imported into clpfd
%    loading /usr/local/lib/sicstus-3.11.2/library/lists.po...
%    module lists imported into attributes
%    loaded /usr/local/lib/sicstus-3.11.2/library/lists.po in module lists, 10 msec 18528 bytes
%   loaded /usr/local/lib/sicstus-3.11.2/library/atts.po in module attributes, 10 msec 46400 bytes
%   loading /usr/local/lib/sicstus-3.11.2/library/assoc.po...
%   module assoc imported into clpfd
%    module lists imported into assoc
%   loaded /usr/local/lib/sicstus-3.11.2/library/assoc.po in module assoc, 20 msec 17988 bytes
%   module lists imported into clpfd
%   loading /usr/local/lib/sicstus-3.11.2/library/ordsets.po...
%   module ordsets imported into clpfd
%   loaded /usr/local/lib/sicstus-3.11.2/library/ordsets.po in module ordsets, 0 msec 21496 bytes
%   loading /usr/local/lib/sicstus-3.11.2/library/ugraphs.po...
%   module ugraphs imported into clpfd
%    module ordsets imported into ugraphs
%    module lists imported into ugraphs
%    module assoc imported into ugraphs
%    loading /usr/local/lib/sicstus-3.11.2/library/random.po...
%    module random imported into ugraphs
%     module assoc imported into random
%     loading foreign resource /usr/local/lib/sicstus-3.11.2/library/sparc-solaris-5.7/random.so in module random
%    loaded /usr/local/lib/sicstus-3.11.2/library/random.po in module random, 20 msec 7776 bytes
%   loaded /usr/local/lib/sicstus-3.11.2/library/ugraphs.po in module ugraphs, 70 msec 84872 bytes
%   loading foreign resource /usr/local/lib/sicstus-3.11.2/library/sparc-solaris-5.7/clpfd.so in module clpfd
%  loaded /usr/local/lib/sicstus-3.11.2/library/clpfd.po in module clpfd, 170 msec 829440 bytes
%  consulting /home/undergrad3/ebaldelo/job.pl...
%  consulted /home/undergrad3/ebaldelo/job.pl in module user, 0 msec 912 bytes
The starting time of the tasks are:
task 1 starts at 0
task 2 starts at 5
task 3 starts at 10
task 4 starts at 5
task 5 starts at 11
task 6 starts at 16
% consulted /home/undergrad3/ebaldelo/schedule-template.pl in module user, 200 msec 836040 bytes
yes
| ?-

September 24, 2010

Adding Color, Drawing a Tetrahedron, Cube with WebGL

Our second assignment asked us to use color when drawing a tetrahedron and cube using WebGL. Here is a screen shot of my work.

If you have a WebGl capable browser, then follow the link and you can test it yourself. Make sure you view source on the page.

Here are the three files you need to run this lesson.
lesson2.html
sylvester.js
glUtils.js

September 18, 2010

How to get the Symbol Browser Plugin to work in Gedit

Ok, so twice I had to research and figure out how I got the symbol browser working in gedit. I started out trying to install the Class Browser. But the ubuntu community suggested that this plugin was no good and to instead use the symbol browser. If you quickly rush and start downloading the symbol browser plugin, you will find that you just downloaded a whole bunch files that need to be compiled. Lucky for us though, you can instead download the binary files for the symbol browser. Go to SourceForge and instead of clicking on “Download Files”, look below under “Browse Files for Gedit Symbol Browser Plugin” and you should see

gedit-symbol-browser-plugin-bin-ubuntu-i386-0.1.tar.gz

If you are using 64 bit, make sure download the 64 bit binary version.

Extract your files and move it over to ~/.gnome2/gedit. You should have the following files…
~/.gnome2/gedit/symbols
~/.gnome2/gedit/plugins/libsymbolbrowser.so
~/.gnome2/gedit/plugins/symbolbrowser.gedit-plugin

A lot of us will now try and open Gedit and enable the plugin. As you try, it will automatically get grayed out. This is because you need the following package.

libgnomeprintui

Once you restart Gedit and enable the plugin, you might realize that it’s still not displaying any class, functions, or variables after you open a file. This is because you need to install exuberant-ctags. After you do this, you should be ready to go.

Let me know if you have any problems.

September 15, 2010

Drawing Simple Shapes – Triangle, Square in WebGL

Our first assignment asked us to draw simple shapes using WebGL. For this particular project I drew a simple square and triangle. Here is a screen shot of my work.

If you have a WebGl capable browser, then follow the link and you can test it yourself. Make sure you view source on the page. I heavily commented the code.

Here are the three files you need to run this lesson.
lesson1.html
sylvester.js
glUtils.js

September 8, 2010

Introduction to WebGL

I’m currently taking a computer graphics class and I’ll be spending this semester delving into WebGL. So, I’ll be giving some tutorials as I get new projects to work on.

Setting Up Your Browser To Support WebGL

First do a Google search for “google chrome developer build”, and it should be the first result. Here is the link it took me to.

http://www.google.com/chrome/intl/en/eula_dev.html

Once you have chrome’s developer build, click on [Start->All Programs->Google Chrome] and then right-click on ‘Google Chrome’. Select ‘properties’ and append this to the end of the [Target] string.

--enable-webgl

Here is how my target string looked like.

C:\Users\Chris\AppData\Local\Google\Chrome\Application\chrome.exe --enable-webgl

Now open up Chrome by going through [Start->All Programs->Google Chrome] and you should be ready to view WebGL webpages. Click here to test for your self.

Getting Started With WebGL

Here are the three files you need to set up your frist WebGL script.
webgl.html
sylvester.js
glUtils.js

September 7, 2010

Cache Problem in CakePHP

I recently had a problem on our website with caching in our CakePHP framework. We initially had caching turned on. And then we started noticing when we submitted a form, our changes wound not be updated until we manually refreshed the page.

So let’s say I have a row of users. I choose to delete one of the users. I click on delete, hit submit and cake removes that user from my table. Cake then redirects me back to same page, but the deleted user is still listed on our page. Once we manually hit the refresh button on our browser, then our deleted user disappears from our form page.

We scratched our heads and tried figuring out why this was happening. We turned off all caching and even added the <cake:nocache> tag. No matter what we did, we could not get rid of the problem.

After much research, we realized that the browser itself was actually caching the previous form page. So we added this snippet of code to our app controller.

$this->disableCache();

This is used to tell the user’s browser not to cache the results of the current request. The headers sent to this effect are:

Expires: Mon, 26 Jul 1997 05:00:00 GMT
Last-Modified: [current datetime] GMT
Cache-Control: no-store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0
Pragma: no-cache

I hope this saves you some time. If you find a better way fixing this problem, please leave a comment.