astro trivia

May 31st, 2014

I was curious about a couple things and did a little surfing…

Diameter of our solar system 90 AU or 8 billion miles or .001 light years.

Milky Way ~ 100,000 light years in diameter, 200 – 400 billion stars.

Nearest star: Alpha Centauri ~ 4 light years away.

Nearest galaxy: Cannis Major Dwarf – Actually it’s sort of part of the Milky Way only 25k-40k light years away from Sun – apparently it collided with Milky Way long ago. Only has a billion stars.

A few other galaxies are similarly close <~ 100k light years away.

Andromeda Galaxy 2 million light years away nearest spiral galaxy, is bound to Milky Way, this plus Milky Way plus a few other galaxies make up the Local Group which are gravitationally bound together.

The Large and Small Magellanic Clouds are two irregular dwarf galaxies about 180,000 and 210,000 light-years away, respectively. They were thought to be orbiting the Milky Way, but that may not be the case..

All of these galaxies make up part of what is called the Local Group, which is a group of more than 30 galaxies that lie within 4 million light years of the Milky Way. Here’s a great article from the Spitzer Space Telescope’s website on the Milky Way’s family of close galaxies and a video by the same author on the subject. Read more: http://www.universetoday.com/21914/the-closest-galaxy-to-the-milky-way/#ixzz33Knq6qP9

All the stars we can see with the naked eye are within 1000 light years away, so they’re all in our Milky Way.

There are a few galaxies we can see with the naked eye;

The Andromeda Galaxy is 2.5 million light years away, but is visible in the night sky in the Andromeda constellation as a hazy patch of light about the size of the full moon. The Large Magellanic Cloud and the Small Magellanic Cloud are 2 smaller satellite galaxies of our own Milky Way, and are visible in the southern hemisphere.

Source: the net

C array subscript weirdness

September 20th, 2013

$ cat test.c
#include

int main() {
int a[2];
a[0]=0;a[1]=0;

1[a] = 1; // weirdness

printf("%d %d\n",a[0], a[1]);
}

$ gcc -o test test.c

$ ./test
0 1

The subscript operator is commutative for what ever reason.


*(a + 1) <=> a[1] <=> 1[a]

Generic makefile for easily building 1 file programs

September 18th, 2013

I’ve always found myself writing short little programs to test out an idea or learn how a language feature/bug works. Often they’re throw away programs, once finished they’re no longer needed. So often it ends up being test.c/test.cpp/test.java etc. But sometimes I like to keep it around so they’ll end up with a meaningful name i.e. I now have a lambda.cpp I used for trying out the new C++11 lambdas. So rather than always have to whip out a new makefile or copy/edit an old one I have this makefile which makes things a little easier. You just drop the makefile in place where you have file.cpp’s laying around and you can compile that single file.cpp with ‘make file’. As you can see I have it working on linux, osx, and windows.


$ cat - > hw.cpp
#include 
int main() {
std::cout << "Hello, world!\n";
}

arch:/home/mkm/src/test
$ make hw
g++ -std=c++11 -Wall  hw.cpp -o hw

arch:/home/mkm/src/test
$ ./hw
Hello, world!

Here's the makefile


# generic 1 file makefile
# 2013/09/18 Mike Makuch
# This makefile will compile any single file.cpp file without modification
# by simply typing 'make file' without the .cpp eg;
#	file name	myprog.cpp
#	type:		make myprog
# Initially works for linux, osx, win7/vs2012,
# Written assuming gnu make

UNAME := $(shell uname -s)

.SUFFIXES:
	MAKEFLAGS += --no-builtin-rules

ifeq ($(UNAME), Linux)
CFLAGS = -std=c++11 -Wall 
CC = g++
COMPILE = $(CC) $(CFLAGS) $< -o $@
BINS = $(subst .cpp,,$(SRCS))
endif

ifeq ($(UNAME), Darwin)
CC = /opt/local/bin/g++-mp-4.7
CFLAGS = -std=c++11  -L/opt/local/lib -I/opt/local/include
COMPILE = $(CC) $(CFLAGS) $< -o $@
BINS = $(subst .cpp,,$(SRCS))
endif

ifneq (,$(findstring CYGWIN_NT,$(UNAME)))
CC=cl
CFLAGS=/O2 /nologo 
#LIBS=gdi32.lib user32.lib kernel32.lib shell32.lib winmm.lib opengl32.lib glu32.lib
LIBS=user32.lib kernel32.lib shell32.lib
COMPILE = cl /EHsc $?  /Fe$(subst .cpp,.exe,$?)  ;  rm $(OBJ)
OBJ = $(addsuffix .obj,$@)
BINS = $(subst .cpp,.exe,$(SRCS))
endif

SRCS = $(shell ls *.cpp)

% :	%.cpp
	$(COMPILE)

clean:
	rm -rf $(BINS) *.dSYM *.obj *.exe

author unkown

June 28th, 2013

Great minds discuss ideas, average minds discuss events, and little minds discuss people. Widely credited to Eleanor Roosevelt but if you keep digging that’s not clear.

Advanced Certification

March 18th, 2012

Advanced Scuba Certification

Got it done this weekend. Also took the Nitrox test this week.

4 dives in Travis, 2 Sat 2 Sun. 3/17 & 3/18, 2012

Water temp about 57. Outside low 70s. Had complete thick (6 mil?) suit on actually it was a wader type bottom which covered ankles to chest then a top half that covered head to knees so it was doubled up. Then had booties/fins and a hoodie. Only thing not covered was hands and they were fine. I was almost toasty warm the whole time.

Visibility: almost nothing at times, almost total brown out at other times. Great experience.

Made it to about 60′ or just below that each days 1st dive. Was trying to get down to 80 or 90 or what ever, but silt avalanche followed us down (rookies) and instructor aborted descent.

Dove Shaker Plant site both days. Old construction area when damn was built. Just a bunch of old pillars, concrete blocks, timbers, big crap laying around you have to watch out for. They’ve got a bunch of lines tied to follow around.

My first dive was a helluv an experience. Definitely pushed out of my “Cozymel” comfort zone ha ha :-)

Because of numerous rookies they/we quickly stirred up tons of silt on the bottom and what would have been maybe 10 feet of vis quickly degrades to almost nothing at times. Most of the time it was several feet and you could definitely see the other flash lights for the most part as long as we were together. Or I’d be able to see the fins kicking in front of me but couldn’t see the upper body connected to them. Several times one of the group would get “lost” not really lost but gone out of site and the instructor would go chase ‘em and get ‘em going back in right direction. One time I pointed out to him that we’d lost one of the group and he went and got her.

It’s very interesting how being nearly blind so dramatically changes the experience. I visualize the dive site of the areas we were diving and imagine it was only an area of say 100 feet square, or maybe 200 feet, I’m not sure but not that big an area. This would be nothing in blue water as you’d be able to see the whole area from one spot and thing nothing of it. But remove vision and it’s an amazing experience. Like being in a maze of twisty little passages. You don’t know what you’re swimming up to until you’re right there. Kinda spooky at first but 2nd day I was all over it.

I dove in groups of 3. Instructor and 2 advanced students each dive. We dove off of Giant Stride pontoon dive boat.

We’d drop down, follow lines around down to around 50 or 60 feet to see if we could attempt a deep dive to 90 or so. Plan was if viz was ok we’d descend down but each time we tried the rookies kicked up too much silt and viz got poor so we couldn’t go down further. So, we’d just swim around practicing staying together, following the lines and staying close and practicing communicating – which were all a real challenge given the very short visibility.

It was a real challenge is several ways. You really can’t see where you are, the bottom or anything much of the time. So, you have to rely on your gauges for your depth and controlling your buoyancy. This was very new to me. I did much better 2nd say than 1st. It was good to have a day between – I thought about it a lot and figured out what I needed to do.

Also did a navigation exercise where I was to swim a square by following compass N-E-S-W 3 mins each leg. 1st day tried it and it was quite difficult as I hadn’t ever tried anything like this before. You have to constantly watch your gauges, clock, compass, depth and adjust and control all 3 concurrently – all without being able to see any bottom or features for reference – imagine being in a white out blizzard except this was more like a mud out.

First attempt I didn’t do well. I was having trouble controlling my neutral buoyancy, then I’d get neutral and find I was 90 or 120 degrees in wrong direction, etc. 2nd day (today) I nailed it. Had total control of my buoyancy and direction. I felt like I really swam in correct direction and depth each of the 4 legs and I believe that’s the case. What I didn’t factor though was my timing was off on 1 or 2 of the legs and so I didn’t end up exactly right back at the boat. Idea was to pop up when done with the square and I’d be right behind the boat where I started. Great drill. Would love to do it again.

I believe we had to perform 3 out of a number of different tasks in order to get the advanced cert, though that wasn’t made clear to me. So I got deep water (anything beyond 60 is deep), low visibility, and the navigation component.

I totally appreciate lake diving now. It’s not about scenery. It’s about mastering your diving skills, at least this was. I loved it. I’d like to do more of this kind of stuff. I’ll have to look into the Master Diver program.

The Nitrox certifcation is just basically all about Nitrox, which is pretty straightforward with a few details. It’s getting more popular and available, extends your dive time and so need to be able to use it.

CS371P #14

December 2nd, 2011

Oops, one more blog. *this is the last one.

Today was the last day of the semester. Took the final test today. I found it to be shorter than exam 2, which helped. I was able to finish the test and go back over and check for mistakes. I’m sure I did well enough. I’ve always found written programming tests to be a pain, unrealistic and not something I am particularly great at. My strengths have always been in design and development. I scored well on the projects. As I should. I should do well on tests too. But that is my weakness. All of the extra credit raises the grade by 9% – almost a full letter grade. So for that reason I’ll get my grade.

I’m sure that having written test skills works in advantageous ways for those who have them. But it’s not the only way to succeed as a developer. I’m proof of that. It appears that our instructor is somewhat in tune with that as evidenced by the weighting of the projects and the ample extra credit. I don’t think all instructors are tuned in that way. I got lucky choosing this class.

Still I want to believe that test taking is a skill set that can be improved upon and I am challenged by it. I consider myself good at what I’m doing and so I ought to be able to do well on tests. So, I intend to look for information in this area, improving test taking skills that sort of thing. Especially as I’m considering grad school.

I enjoyed this course. Our instructor has obviously refined his teaching techniques over many years. He really maximizes the classroom experience by causing everyone to be 100% engaged every day in class. The short quiz every day. And the system he has of calling on people to answer questions really keeps everyone on their toes – lest they be humiliated in front of their peers. It works well sort of like a C++ boot camp. I didn’t like it at first but I came around.

I am pleased with my new C++, java & OOP knowledge. Most of the OOP was review for me and the programs were mostly trivial. But all the C++ ins and outs, corners and nuances I enjoyed learning. I will be putting it to practice soon.

Enjoyed meeting a few of you guys. See you around.

Calvin Coolidge

November 28th, 2011

Nothing in this world can take the place of persistence. Talent will not; nothing is more common than unsuccessful people with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination alone are omnipotent. The slogan “press on” has solved and always will solve the problems of the human race” – Calvin Coolidge

CS371P #13

November 28th, 2011

Last week of the semester and this is the last blog. I did manage to get quite a bit of studying done over the break though not as much as I had hoped.

This my first semester back to school has been an interesting and fun experience. I’ve learned quite a bit of C++ that I never knew. Which was a surprise, I thought this class was going to be mostly java. I plan to do more studying of C++ in the near future. And I hope to use java at some point for an extended period of time so I can become fluent with it.

I enjoyed this class and I’m glad this is the one I chose to take as my last CS course. I enjoyed working with the partners that I had. Chances are some of us will run into each other in the future. I look forward to that. Look me up on LinkedIn, Facebook or Google+.

Always do equality check with rvalue on the left

November 23rd, 2011

A common error in many languages is accidentally omitting an equals sign where a comparison was intended. Example;

void somefunc(int i) {
   if (i = 2) {     // was supposed to be "(i == 2)"
      // ...
   } else {
      // ...
   }
}

What makes it easily missed is that it compiles and executes just fine in many cases, albeit erroneously. Bugs like this can live in the code for long periods of time before being caught.

An easy habit to get into is to always put the rvalue on the left side when doing == comparisons. E.g.

void somefunc(int i) {
   if (2 == i) {
      // ...
   }
}

this way if (when!) you do accidentally omit an = then the compiler catches it for you.

Q: “Is Java the language you would have designed if you didn’t have to be compatible with C?”

November 22nd, 2011

Bjarne Stroustrup: “No. Java isn’t even close. ”

http://www2.research.att.com/~bs/bs_faq.html#Java