A Potpourri of Technology, Science, Math, Politics, Economics, and anything else I might be interested in. Don't trust me as a definitive source of information.
Saturday, March 3, 2012
HTML By Hand
So, here is the HTML I wrote by hand for the Webcraft school. I have worked with html before, so It only took me one try.
Friday, March 2, 2012
Badges and Webcraft
So, Mozilla (and probably others) are making this new "Badges" system, where you can demonstrate your skills by earning online badges. The idea is that a college degree doesn't give employer's an accurate specific idea of what you do and do not know. The same degree from different universities may include entirely different sets of skills, and knowledge sets. Badges provide way to demonstrate more granular knowledge.
This badges system is very exciting to me, because over the years I have taught myself a lot informally. However demonstrating these skills to employers and/or universities/grad schools, is a challenge.
And so, while these badges are new and in development I am going to try and earn some, both to show off the skills I have already acquired, maybe pick up some new skills, and hopefully help progress this new method of education.
This post is actually part of Web 101 on the P2PU Webcraft school. I am already fairly proficient with HTML, but I have no formal training, and this give me an opportunity to get some form of exterior validation, and possibly pick up something new.
This badges system is very exciting to me, because over the years I have taught myself a lot informally. However demonstrating these skills to employers and/or universities/grad schools, is a challenge.
And so, while these badges are new and in development I am going to try and earn some, both to show off the skills I have already acquired, maybe pick up some new skills, and hopefully help progress this new method of education.
This post is actually part of Web 101 on the P2PU Webcraft school. I am already fairly proficient with HTML, but I have no formal training, and this give me an opportunity to get some form of exterior validation, and possibly pick up something new.
Tuesday, December 13, 2011
A simple FFT
So, following my PDE's class, I decided to try my hand at writing an FFT algorithm. I ended up doing it in both c and Fortran. Surprisingly, I found it easier to write in Fortran (accounting for the fact that I am more familiar with c, and had to look up the syntax for just about everything in fortran). So, without further ado, here is my code:
FORTRAN:
module FFT
implicit none
save
public
REAL, parameter :: PI = 4*atan(1.0)
contains
recursive function fft1(f) result(r)
!assumes that f is of length n where n is a power of 2
!output is zero indexed
COMPLEX, intent(in) :: f(:)
integer :: N, first, last, k
COMPLEX :: r(0:size(f)-1)
COMPLEX, dimension(0:size(f)/2-1) :: even, odd
N = size(f)
first = lbound(f,1)
last=ubound(f,1)
if( N == 1) then
r = f
return
end if
even = fft1(f(first:last-1:2))
odd = fft1(f(first+1:last:2))
do k=0,N/2-1
odd(k) = exp((0,-2)*PI*k/N)*odd(k)
end do
r(0:N/2-1) = even+odd
r(N/2:N-1) = even-odd
end function
recursive function ifft1(f) result(r)
!assumes that f is of length n where n is a power of 2
!output is zero indexed
COMPLEX, intent(in) :: f(:)
integer :: N, first, last, k
COMPLEX :: r(0:size(f)-1)
COMPLEX, dimension(0:size(f)/2-1) :: even, odd
N = size(f)
first = lbound(f,1)
last=ubound(f,1)
if( N == 1) then
r = f
return
end if
even = ifft1(f(first:last-1:2))
odd = ifft1(f(first+1:last:2))
do k=0,N/2-1
odd(k) = exp((0,2)*PI*k/N)*odd(k)
end do
r(0:N/2-1) = even+odd
r(N/2:N-1) = even-odd
r=r/2
end function
end module
C:
#include <complex.h>
#include <math.h>
#include <stdlib.h>
#include "fft.h"
double complex* _fft1( double complex*, size_t, unsigned int);
double complex* _ifft1(double complex*, size_t, unsigned int);
/** use the Cooley-Tukey method to take the fast fourier transform of an
* Array of lenth 2^n
*
* input and output are both complex arrays of length N, which must be a
* power of 2. Returns 0 if succusfull, nonzero if failed.
**/
double complex* fft1( double complex *input, size_t N) {
return _fft1(input,N,1);
}
double complex* _fft1( double complex *data, size_t N, unsigned int step) {
double complex *result;
double complex *even;
double complex *odd;
size_t k;
if ( (N > 2) && ( N % 2 != 0 )) return NULL;
result = (double complex*) malloc( sizeof(double complex) * N);
if ( N ==1 ) {
result[0]=data[0];
return result;
}
even = _fft1(data, N/2, 2*step);
odd = _fft1(data+step, N/2, 2*step);
//multiply the odds by the twiddle factor e^(-i*2*pi*k/N)
for( k=0; k < N/2; k++) {
odd[k] = cexp(-2.0*I*M_PI*k/N)*odd[k];
}
//generate result
for( k =0; k < N/2; k++) {
result[k] = even[k] + odd[k]; //first N/2 results
result[k+N/2] = even[k]-odd[k]; // last N/2 results
}
free(even);
free(odd);
return result;
}
double complex* ifft1( double complex* data, size_t N) {
return _ifft1(data, N, 1);
}
double complex* _ifft1( double complex *data, size_t N, unsigned int step) {
double complex *result;
double complex *even;
double complex *odd;
size_t k;
if ( N % 2 != 0 ) return NULL;
result = (double complex*) malloc( sizeof(double complex) * N);
if ( N ==1 ) {
result[0]==data[0];
return result;
}
even = _ifft1(data, N/2, 2*step);
odd = _ifft1(data+1, N/2, 2*step);
//multiply the odds by the twiddle factor e^(i*2*pi*k/N)
for( k=0; k < N/2; k++) {
odd[k] = cexp(I*2*M_PI*k/N)*odd[k];
}
//generate result
for( k =0; k < N/2; k++) {
result[k] = (even[k] + odd[k])/2; //first N/2 results
result[k+N/2] = (even[k]-odd[k])/2; // last N/2 results
}
free(even);
free(odd);
return result;
}
Sunday, November 13, 2011
What is a miracle
The first definition of miracle on Dictionary.com is "an effect or extraordinary event in the physical world that surpasses all known human or natural powers and is ascribed to a supernatural cause." I don't really like this definition, and this post will explain why.
First of all, what does it mean for something to be caused by a supernatural cause? It would be something that does not obey the laws of the universe, correct? But the universe, and its laws were created by God. And why would God ever have need to break his own laws? God certainly influences things in the universe, and performs miracles on scales from affecting the entire universe to a single individual. But I have no reason to believe that he does so outside of the laws of the universe that he established at his creation. As an Example look at Moses parting the Red Sea. It is entirely conceivable that some natural phenomenon caused the water to stop flowing at some point, and then start again. But why should that preclude the involvement of God. It would be a remarkable coincidence for the phenomenon to occur at precisely the right time for the Israelites to cross on dry land. If it is the case, as I speculate that it is, that God performed the miracle by utilizing natural forces, then Moses' miracle was the result of a natural cause, but it was also a miracle of God.
Now let me talk about my own life. There have been a vast many occurances in my life that are entirerly explainable by human and/or natural forces, which nonetheless I would consider miracles. Often they take the form of something like me, or someone else, being in the right place at the right time, or someone saying something I really needed to hear, or a pathway opening to me that had previously been shut. I believe that these sorts of things happen to everyone. Some may say that they are just coincidences or random occurances. But the frequency with which they have occured in my life is too statistically significant to reasonably accept that as an explanation. I see the work of God in my life, and the lives of others, even when they do not see it. That is what I call a miracle.
You can do incredible things with science and technology. Today's technology would look like magic to the ancients. And our current understanding of the laws of the universe is limited at best. Just look at quantum mechanics. We can make remarkable predictions in that realm, but we have only half-baked philosophical musings about what is really going on. There are many things in this world that cannot be explained by the science we currently have, but they are not considered miracles by most, because eventually when our knowledge progresses we can explain them as natural phenomina. And there is nothing wrong with that. But just because something is natural doesn't mean it doesn't come from God.
One of God's greatest miracles is the miracle of creation. It is a miracle that we can see just by looking around us, and on deeper study the miracle only becomes more profound. If the physical constants that show up in our laws of physics differed by even a small amount, the universe would be the way it is, there might have been no stars, no matter, and certaiinly no life as we know it. And there is a beuaty and symmetry in the way the world works, down from the most complex organisms on Earth (i.e. humans) to the most basic laws of physics.
In order to miss the works of God in the Universe you must actively be trying not to see them.
First of all, what does it mean for something to be caused by a supernatural cause? It would be something that does not obey the laws of the universe, correct? But the universe, and its laws were created by God. And why would God ever have need to break his own laws? God certainly influences things in the universe, and performs miracles on scales from affecting the entire universe to a single individual. But I have no reason to believe that he does so outside of the laws of the universe that he established at his creation. As an Example look at Moses parting the Red Sea. It is entirely conceivable that some natural phenomenon caused the water to stop flowing at some point, and then start again. But why should that preclude the involvement of God. It would be a remarkable coincidence for the phenomenon to occur at precisely the right time for the Israelites to cross on dry land. If it is the case, as I speculate that it is, that God performed the miracle by utilizing natural forces, then Moses' miracle was the result of a natural cause, but it was also a miracle of God.
Now let me talk about my own life. There have been a vast many occurances in my life that are entirerly explainable by human and/or natural forces, which nonetheless I would consider miracles. Often they take the form of something like me, or someone else, being in the right place at the right time, or someone saying something I really needed to hear, or a pathway opening to me that had previously been shut. I believe that these sorts of things happen to everyone. Some may say that they are just coincidences or random occurances. But the frequency with which they have occured in my life is too statistically significant to reasonably accept that as an explanation. I see the work of God in my life, and the lives of others, even when they do not see it. That is what I call a miracle.
You can do incredible things with science and technology. Today's technology would look like magic to the ancients. And our current understanding of the laws of the universe is limited at best. Just look at quantum mechanics. We can make remarkable predictions in that realm, but we have only half-baked philosophical musings about what is really going on. There are many things in this world that cannot be explained by the science we currently have, but they are not considered miracles by most, because eventually when our knowledge progresses we can explain them as natural phenomina. And there is nothing wrong with that. But just because something is natural doesn't mean it doesn't come from God.
One of God's greatest miracles is the miracle of creation. It is a miracle that we can see just by looking around us, and on deeper study the miracle only becomes more profound. If the physical constants that show up in our laws of physics differed by even a small amount, the universe would be the way it is, there might have been no stars, no matter, and certaiinly no life as we know it. And there is a beuaty and symmetry in the way the world works, down from the most complex organisms on Earth (i.e. humans) to the most basic laws of physics.
In order to miss the works of God in the Universe you must actively be trying not to see them.
Wednesday, August 17, 2011
Thoughts on Unity
This is just a short post. I have finally had a chance to try out Ubuntu's Unity Desktop. In short, it appears to be an attempt to mimac macs. There is a dock along the side which functions pretty well with basic drag and drop functionality. Although I would like a little bit more customizability, such as controlling when it is visible and maybe put special applets on it. Also, the if a program is maximized its menu bar combines with the task-bar. Which is kind of cool, but is inconstant with non-maximized windows, and isn't obvious since the menus are hidden unless the mouse is hovering over them.
As for the Ubuntu symbol in the left top corner, clickin on it gives you something akin to Kickoff in KDE4, where you have an entry box where you can type the name of an application or folder and it will show results which you can select to run. It also lists favorites, and shortcuts to menus for other apps. The downside is that if browsing through you applications is a bit tedious with the mouse, however it gives you hints about uninstalled programs you might like, which I think is pretty cool.
Overall, I am pretty impresssed by Unity, but I still like KDE 4 better. And Enlightenment for when I want something a little simpler.
Apple, iTunes, and DRM
First of all, as a Linux user, I am rather annoyed by the fact that you need to use iTunes in order to purchase anything from the iTunes store. Then again, it doesn't matter all that much, since DRM makes it impossible to play anyways.
DRM for those of you that don't know is "Digital Rights Management," or as some more correctly call it "Digitla Restrictions Management." It is the use of technology to restrict the ways that users can use copyrighted material, and is supposedly intended to combat Piracy, though in reality I think the restrictions it places on users, only makes piracy more popular and illegally downloaded materials more attractive than legal downloads. http://www.slate.com/id/2298871/pagenum/all/gives a very good discussion of the issue.
Anyway, my family recently purchased the Third Season of Merlin (from BBC) in my absense via iTunes without fully understanding the limitations of DRM. Then we discovered just how crippling DRM is. First of all, we can't burn the videos onto a DVD that is playable by our DVD player, which would make it impossible for most people to watch the movies on their TVs. Fortunately we have a (older) computer hooked up to our TV, but that only partly solved the problem. The videos are in the .m4v format, and are encrypted which means that the only program that can play it is iTunes. This would be a little annoying in and of itself (I would prefer to play it with VLC), but it is even worse becuas playing movies (at least these TV episodes) is very glitchy on iTunes, with frames constantly freezing, the audio misaligning with the video, and worst of all, about once every 10 minutes iTunes crashes, and it takes about 5 minutes to stop the not responding iTunes program and start it again. To be fair, I was playing off of a data DVD which might possibly be damagged, and iTunes was unable to copy the files to the hard drive, (another failing for iTunes).
Ok, so I looked around and tried to figure out if there was a way to remove the DRM from the files so I could actually watch the content we purchased. And there was, unfortunately it involved playing the content, and recording it. Well, if iTunes crashes whenever I try to play it I can't really record it again, can I?
So, Apple is not going to get any business from me anytime soon, and never if they don't start offering products that are more interoperable with products provided by companies other than Apple. And I am going to avoid DRM as much as possible, which might mean that I will be sticking to DVDs and hard copies until the Movie Industry realizes that DRM is restricting their profits and making consumers unhappy. The music industry figured that out eventually, I just hope that the movie industyr figures it out faster. And I would really like Congress to repeal the Digital Millenium Copyright Act, which is in contradiction with the Fair Use Act anyway.
By the way, if anyone knows of a way to legally obtain movies that are playable on Linux besides ripping DVDs, or to remove the DRM of iTunes movies, please let me know.
Wednesday, July 13, 2011
Installing Peppermint OS without a CD
In this post, I will describe how I installed Peppermint Linux onto my harddrive without burning a CD and the issues I ran into. First I should warn you that this method is not for the light-hearted. It involves manually editing GRUB configurations, chrooting, loop mounting, etc.
The first step is to prepare the partition. In my case I formated an existing partition as ext4 using the mkfs command. I won't go into the details of how to do this, because I assume that you either already know how to do it, or are intelligent enough to find a howto somewhere else.
The next step is to get the installation ISO of the desired distro and make the filesystem accessible. In my case I just downloaded the 64-bit ISO from the Peppermint OS website. Then I mounted the ISO image using a command of the form "mount -o loop path/to/isofile.iso /mnt/mountpoint" which needs to be run as root. While you are at it you also need to make sure that the partition you want to install to is mounted (from now on I will refer to that mount point as /mnt/new). Finally, you will also need to find the squashfs filesystem on the ISO, I believe for PeppermintOS it was in the Casper folder, but it could vary from distro to distro. You will either need to extract it or mount it. I mounted it because I didn't have the squashfs tools installed, but you could probably extract it directly into the desired partition. In my case I mounted the squashfs with the command "mount -o loop -t squashfs filesystem.squashfs /mnt/squash." Then once I had it mounted I copied the entire contents into the new partitions with "cp -R ./* /mnt/new".
I had a slight problem in that the squashfs only appeared to have a broken symlink instead of a kernel, so make sure that you have a kernel (vmlinuz26) and an initram disk (prabably initrd.img or something like that). It may be in the root directory or in the boot directory depending on the distro.
Now you need to modify grub so you can actually log into your new OS. In my case (I am using grub 2) I added a new menu item with the following lines:
So, installing Linux this way is a lot of effort, but if, like me, you like to do things the hard way and are too cheap to buy a CD :), or if you don't have a CD drive on the computer you want to put it on, this is definetely an option.
The first step is to prepare the partition. In my case I formated an existing partition as ext4 using the mkfs command. I won't go into the details of how to do this, because I assume that you either already know how to do it, or are intelligent enough to find a howto somewhere else.
The next step is to get the installation ISO of the desired distro and make the filesystem accessible. In my case I just downloaded the 64-bit ISO from the Peppermint OS website. Then I mounted the ISO image using a command of the form "mount -o loop path/to/isofile.iso /mnt/mountpoint" which needs to be run as root. While you are at it you also need to make sure that the partition you want to install to is mounted (from now on I will refer to that mount point as /mnt/new). Finally, you will also need to find the squashfs filesystem on the ISO, I believe for PeppermintOS it was in the Casper folder, but it could vary from distro to distro. You will either need to extract it or mount it. I mounted it because I didn't have the squashfs tools installed, but you could probably extract it directly into the desired partition. In my case I mounted the squashfs with the command "mount -o loop -t squashfs filesystem.squashfs /mnt/squash." Then once I had it mounted I copied the entire contents into the new partitions with "cp -R ./* /mnt/new".
I had a slight problem in that the squashfs only appeared to have a broken symlink instead of a kernel, so make sure that you have a kernel (vmlinuz26) and an initram disk (prabably initrd.img or something like that). It may be in the root directory or in the boot directory depending on the distro.
Now you need to modify grub so you can actually log into your new OS. In my case (I am using grub 2) I added a new menu item with the following lines:
set root="(hd0,5)" linux /vmlinuz root=/dev/sda5 ro quiet splash initrd /initrd.imgThe last part is the trickiest, and most likely to change from OS to OS. I was unable to log in because there wasn't any account created, so I went back to my original OS and chrooted into the partitions (note you will need to mount with the exec option). Then I created a new user account, and granted it sudo priveledges. While in the chroot I also ran dpkg-reconfigure on several packages, such as the locale packages, and edited /etc/fstab and a couple other /etc files to behave properly, and for some reason I also needed to give the /tmp folder world writeable access (don't know why it didn't have it before). Unfortunately I am still having some kind of trouble with dbus, and I am not sure what is causing it. I've tried reinstalling it, recnfiguring it, etc. But since my Arch Linux works fine, and this was more of an experiment than anything else, I haven't worried too much about it.
So, installing Linux this way is a lot of effort, but if, like me, you like to do things the hard way and are too cheap to buy a CD :), or if you don't have a CD drive on the computer you want to put it on, this is definetely an option.
Subscribe to:
Posts (Atom)