PHP Git Utility Class
Posted by Travis Sharkey on May 3, 2009 at 3:41 pm
So after trying several web based options for git, I surrendered myself to writing my own PHP utility library. I'm far from finished with the library, but it is already being used to handle a few of my projects in the source section. Anyone wishing to pick it up, I'm releasing it under GPLv3 and it can be viewed or downloaded in the source section under a package I'm calling SlaintePHP. I haven't decided yet what other libraries I'll be including in the package nor do I have any available examples/tutorials on how to use the library. This is not a full application such as GitWeb.
Here's a quick example of some of the currently available features
...More in Full Version...
Image Magick Thumbnail
Posted by Travis Sharkey on April 12, 2009 at 3:30 pm
Friend asked about how I'm doing my thumbnails so...
| Bash |
1
2
3
| BASE=`basename $FILE`
convert $FILE -auto-orient -resize x100 -gravity center \
-crop 100x100+0+0 +repage thumb/${BASE/JPG/jpg} |
EDIT: Added my cover image code too.
| Bash |
1
2
| convert $FILE -resize 280x280 \
-crop 280x100+0+50 cover/${BASE/JPG/jpg} |
Probably obvious for some, but I was putting together some back-up packages for my projects and needed MySQL to be synced to my local machine. For simplicity I used the following
| Bash |
1
2
| ssh <servername> "mysqldump -u<mysqlUser> -p<mysqlPass> <mysqlDb>" \
| mysql -u<localMysqlUser> -p<localMysqlPass> -D<localMysqlDb> |
Keep in mind my ssh keys are setup to just log me in without explicitly specifying my credentials.
View
Transferring PS2 save (.PSV) from PC to PS3
Posted by Travis Sharkey on March 29, 2009 at 9:18 pm
Every time I have to do this, I end up wasting time searching online... Anyway, this is what worked for me.
In the root of the USB drive make the folder structure PS3/EXPORT/PSV and place the .psv files in there.
View
Finding Shortest Distance from Line to Point
Posted by Travis Sharkey on March 19, 2009 at 4:39 pm
OK, I was trying to work on my Phantom MRI simulator when my brain decided to give out on me for a simple geometry problem. Basically, I wanted to do a hit test for a cylinder by seeing if an arbitrary point's shortest distance to the center of the cylinder is less than or equal to the radius. I finally pulled out a piece of paper and drew it up and I'm putting it here for posterity's sake. The simulator is actually being done in C++, but I've illustrated the process in Octave/Matlab for the sake of simplicity.
| Matlab M |
1
2
3
4
56
7
8
9
1011
12
13
14
1516
17
18
19
2021
22
23
| % I'm choosing arbitrary values just as an example
O = [1 2 -1]; % Origin of Cylinder Line Segment
P = [2 -3 4]; % Point of Interest for Hit Test
u = [1 1 1]; % Directional Unit Vector for Cylinder
R = 2; % Radius of cylinder
% First calculate the projection of <P - O> onto u
d = dot(P - O, u);
% Then use that to find the origin of the new vector <V>vo = O + d*u;
% Calculate <V>'s directional vector
V = P - vo;
% We can now do whatever we want with the resultant vector
% for my purposes, simply check if it lies within the cylinder
% ie ||v|| leq R
if ( norm(V) <= R )
disp('Hit');else
disp('Miss');
end |
It is important to note that if you are not using an infinitely long cylinder, additional checks must be made to ensure the new vector origin is within the cylinder's center line segment.
View