Monday, April 4, 2016

Taxing mutual funds

Man, one more year where my mutual fund barely moves but I get a letter from the fund company telling me that I made $3k!?! So, pay tax for that... Anyhow, to understand how to account for this, read this good explanation.

Basically, when the fund manager sells a winning stock, you pay tax for that. As long as he/she doesn't sell the losing ones, you can see the fund lower with a bunch of unrealized losses (same as would happen if you held the basket of stocks).

So, sure, pay year by year, but keep track of that, so, that in the end, the earnings that you pay tax for become part of the investment capital (!). So, when you finally sell it and realize the losses, your investment is higher than it was, and your losses are higher than they look like if you just looking at the price you paid for the mutual fund at the very beginning.

Basically, avoid double taxation... The link above gives an example where you actually made money overall, but it is the same concept...

Cheers!

Wednesday, March 2, 2016

Installing Tenda W522U in Linux Mint

Installing this in Linux was not straightforward. FYI, if you haven't bought your Wifi adapter yet, check the internet and find something that folks recommend.

I'll go through all what I did. It may be random (really it was more a historical record for whatever clue it may give) than a reasoned one...

In my case, checking Networking in the System Settings or clicking on the connectivity icon in the status bar actually shows my access point SSID, which makes me think that it actually works. ifconfig was showing it too. Nevertheless, I can't connect. It tries but fails...

Although for a different chipset (RT3572 instead of RT3572), this is a good forum post. Or is it 5572? That is what I got compiling... Checking for that info, looks like 3572 and 5572 may be the same (or one a superset of the other).

Some useful commands:
  1. ifconfig
  2. lsusb list all what is connected to the USB ports.
    Bus 002 Device 002: ID 8087:8002 Intel Corp.
    Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 001 Device 002: ID 8087:800a Intel Corp.
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
    Bus 003 Device 011: ID 1c4f:0002 SiGma Micro Keyboard TRACER Gamma Ivory
    Bus 003 Device 010: ID 045e:0040 Microsoft Corp. Wheel Mouse Optical
    Bus 003 Device 009: ID 058f:6254 Alcor Micro Corp. USB Hub
    Bus 003 Device 002: ID 093a:2468 Pixart Imaging, Inc. SoC PC-Camera
    Bus 003 Device 013: ID 148f:3572 Ralink Technology, Corp. RT3572 Wireless Adapter
    Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
  3. modprobe -c | grep 3572 not sure for what it is. It will list something like this:
    alias usb:v148Fp3572d*dc*dsc*dp*ic*isc*ip*in* rt2800usb
    alias usb:v8516p3572d*dc*dsc*dp*ic*isc*ip*in* rt2800usb
    but if we do something similar (modprobe -c | grep 5372) for a different chipset we get:
    alias pci:v00001106d00005372sv*sd*bc*sc*i* sata_via
    alias spi:ad5372 ad5360
    alias usb:v148Fp5372d*dc*dsc*dp*ic*isc*ip*in* rt2800usb
    alias usb:v5372p2303d*dc*dsc*dp*ic*isc*ip*in* pl2303
    So, both show up...
  4. lsmod | grep rt2800usb
    rt2800usb 27034  0
    rt2x00usb 20742  1 rt2800usb
    rt2800lib 89076  1 rt2800usb
    rt2x00lib 55307  3 rt2x00usb,rt2800lib,rt2800usb
It seems like the rt2800 should work but it doesn't (properly) so:
$sudo pico /etc/modprobe.d/blacklist.conf

add the following lines:
blacklist rt2x00usb
blacklist rt2x00lib
blacklist rt2800usb
close and save.

$sudo rmmod rt2x00usb (just in case)
$sudo rmmod rt2x00lib (just in case)
$sudo rmmod rt2800usb (just in case)

Now lsmod won't show the rt2x... and my wireless stop working completely...
lsusb still shows it.


Went to Tenda's website and dowloaded their linux driver. That is basically the pure source, so, once untar, followed the instructions in the readme. Basically:
  1. Add the 2 "y" instead of "n" to config.mk (all the other stuff was done already). 
  2. Also had to patch the rt_linux as described here and here (make wasn't working). To apply the patch all what we did was to copy it in the directory where the file we want to patch (rt_linux.h) is (/include/os) and apply patch < rt_linux.h.patch as described here
  3. Then did the make and worked. Generated rt5572sta.o
  4. Do make install
  5. modprobe rt5572sta . This will not work if the install wasn't done. Also, remember that some of these need su privileges.
  6. Notice that if we do modprobe -c | grep rt5 we can get a long list of alias with one line that says:
    alias usb:v148Fp3572d*dc*dsc*dp*ic*isc*ip*in* rt5572sta
    where the highlighted in red is the same we get with the lsusb. I.e., it seems that is saying that for that adapter the rt5572 is the right file.
  7. lsmod will list now the rt5572sta. By the way, if we want to remove it we can use rmmod rt5572sta (or modprobe -r rt5572sta)
  8. ifconfig now is very slow but eventually returns without showing the wireless interface.
  9. I rebooted as the whole thing was dying out... Now with lsusb we can't see the adapter. I guess that is related to the fact that we hide the rt2800usb and has not found the other. lsmod does not see the driver either but we do #5 and now is visible. Still not in lsusb. ifconfig returns also fast but without the adapter.
  10. I unplugged and plug the adapter and sure enough, it shows up in lsusb.
  11. Then it shows up with ifconfig -a
  12. So, now we can even see it in our wireless window (with SSID...) but still never manages to connect to router (like what was happening when using the rt2800...). We can see the LED light up, but nothing...
  13. Also doing lsmod shows cfg80211 which I am not sure was there before...
  14. iwlist scan does show my network with details on encryption type... 
  15. So, we started messing with the NetworkManager.conf file, making ifupdown managed, and somehow that made the service stop after reboot... Then we made managed "false", restart the service (service network-manager restart) and it came back, not only it, but also the wireless!!! Now is connected although I still can not surf the network through wireless ?!? I have no clue what I have done but at least got one step further... Note: eventually, this stopped working but it does work without security or just WEP. So, that points to the WPA... No time to debug now...
  16. Internal ping (192.168.0.1) works but not ping to Google (8.8.8.8)  
  17. Finally got it... I had my router blocking connections by MAC addresses. (0o)". I know... My doubt is at what point some of the errors above where coming from this. Still, I thought I would leave all as is, for anybody's reference...
Notes:
  1. Found this http://ubuntuforums.org/showthread.php?t=1285828
  2. How to see  your IP, change it and few more useful solutions at http://whatismyipaddress.com/
  3. A lot of info on the topic of setting and controlling the network adapter.  

Monday, January 18, 2016

Know your plastics

#1 BAD       polyethylene terephthalate, PET or PETE. Water bottles
#2 GOOD    HDPE - detergent/oil containers
#3 BAD       polyvinyl chloride/PVC - Pipes
#4 GOOD    low-density polyethylene, LDPE - Grocery bags
#5 GOOD    polypropylene, PP - Plastic cups/food containers
#6 BAD       polystyrene/PS (styrofoam)
#7 BAD       Lexan and others unclassified
 
Source 

For more properties on plastics see this...

Wednesday, November 25, 2015

Can you power for one day your house with the exercise from one hour bike ride?

A friend just posted this video in FB, from Billions in Change. I can't agree more with the philosophy of this group of inventors, but in the video/website, they claim to have developed a bike where pedaling for one hour would produce electricity for your home for the whole day. So, I had to check if this was close...
  1. Pedaling for one hour at a very good pace, say vigorous spin class, burns about 1000 calories (this is no average person). These are actually 1000Kcal, or ~1kWh. Let's assume that all that energy is stored in the battery, i.e., 100% efficiency.
  2. An average US household consumes about 30kWh/day. Of course, one can expect US to be a big consumer, so, checking around the world we find that the average would be 9.5kWh/day while a country like India you would still need about 2.5kWh per day.
  3. Just to run a energy efficient refrigerator, it would take 1kWh every day.  
So, we could qualify the wording as quite an an exaggeration. One probably would need a few strong family members to get there :)... But as I said, I do appreciate their intentions...

Nevertheless, taking this a step further, what if the cost of the bike went simply into solar power? Say that the fancy static bike was about $500. Just a number although we know you can get much cheaper... How much solar power you can buy with that? Based on this 2012 article (price is probably much cheaper now) the installed cost of solar panels was between $7-$9 per watt. So, $500 would give you about 80W of solar power. Considering that you don't need to have a family of athletes and that many of the poor countries are in areas of long sun hours, it seems plausible that the more traditional solar panels would do at the very least the same job for the same cost.

Actually, after I wrote this I found a more recent source of information. Claims that the solar system once installed (in Q3 2013) is about half the above price ($4.72/W) with most of that going to installation, permitting, etc... which traditionally would be much cheaper in lower income countries. In fact, the panels alone were $0.7/W!

Conclusion, it is very likely that dollar for dollar, solar would beat by now the above invention. Nevertheless, the bike is a reliable source (you get the electricity when you need it) and certainly healthy. :)

Comments welcome!! :)

Wednesday, November 18, 2015

Sunday, November 8, 2015

ODE brief tutorial

Very quick top level understanding of the key components in ODE...
An object in ODE is made of two entities:
  1. The body: holds the masses (one in the centre of gravity or distributed...). This is what gives the kinetic behaviour to the object.
  2. The geometries used to describe the physical boundaries of the object (detect collisions).
Bodies belong to the World, while geometries belong to the Space.

To create the objects, we create their bodies (which can actually be made of bodies). Each body is basically a mass, with a centre and an orientation (which later will be tight to the same centre and orientation of the geometry). Then we create geometries that we assign to that body so that it's all linked together. Setting a body on a geom automatically combines the position vector and rotation matrix of the body and geom, so that setting the position or orientation of one will set the value for both objects. This is important because even if we have created the geometry somewhere else, once we assign it to the body, the centre of the geometry will be shifted to match the centre of the body. To offset that, use dGeomSetOffsetPosition.

Program starts (in main C function) by creating the simulation environment with its objects and the fn function among others (see below). Then calls dsSimulationLoop (argc,argv,352,288,&fn); that starts the simulation. It will stay there, simulating, till exiting (usually ctrl+x).

fn, among other things, basically points to the 2 key functions on a simulation loop, Step (key ODE step sim) and Command which senses inputs from keyboard, for instance.

A simulation loop (Step) [1] runs dSpaceCollide in the space to detects collisions and position the objects according to that. [2] Then runs a step of physics simulation with dWorldStep which moves the object accordingly. [3] Finally draws the whole scene. Notice that you can draw whatever you want, even nothing, and may not match what/where the real geoms are. It is up to the user to keep what we see and what the sim uses to do collisions correct. For that, when drawing the objects, use their centers and orientations. Outside Step, after all that is done, [4] software checks for user inputs in Command.

Cheers!

PS.: Some of the tutorials included with ODE (I'll add as I go through them):
  1. Chain 2: uses ball and socket joints to connect a series of boxes to make it look like a chain. No user input. Simple and quite insightful.
  2. dBall: double ball and socket demonstration. Shows two objects tight by a rope under the wind.
  3. cylvssphere: just drops a sphere and a cylinder in screen. Pretty simple.
  4. feedback: that's a cool one... draws a bridge out of tiles and then drops a bunch of stuff on it that ends-up breaking it...
  5. gyro2: the boxes spinning in space, using dBodySetGyroscopicMode. Not sure what for...
  6. joints: that is a pretty spectacular/psychodelic one. Many different type of joints applied between two boxes... Sim seems to re-start between each type.

Monday, October 19, 2015

Alternatives to capitalism

The world moves a lot by inertia. The status quo stays like that for very long and changes to a new regime required in the past big revolutions. Today we got capitalism and democracy and many argue that one or the two have failed to deliver to the majority of people. I am not that negative on them and somehow, I believe that people have the system that they deserve. Somebody may argue that even this being truth, it doesn't make it right and with a social gap still growing it will eventually break the system.

Even if those were not big enough challenges, the world keeps evolving and I wonder if the current system will survive some of the big changes ahead. For instance, what happens in a society where machines can do any job better than humans? Or where people can live well beyond 100 years, becoming "de facto" immortals as science improves faster than they age? Those look like far fetched scenarios but I would argue quite the opposite. Many experts talk about the so call "singularities" happening in the next 50-100 years, worst case.

So, the question becomes if capitalism can gradually adapt to these or on the contrary, violent shifts will shake the system or even destroy it, and with it, maybe even civilization. That's of course, not even taking into account other background phenomena like climate change... Another concern is what I perceive as a bigger than ever polarization of the society, with less middle ground. Folks become cheerleaders and then fanatics of ideas, seldom questioning them.

Although this may sound like the typical negative post, I am actually quite positive. Never before so many people has been thinking on these topics and the information has been so easy to flow. The most recent crisis have acted a bit as a vaccination too. But we need new ideas and what is as important as that, we need ways to implement them hopefully encouraging a gradual transition... I got, for instance, a personal one... Say machines take more and more of humans jobs, who is going to consume the goods from those machines if no one can pay for them because they do not work? It seems that contrary to a doomsday scenario the system would regulate towards either the goods being cheaper and/or humans getting paid the same for less work hours, and sharing between them whatever tasks are left. None of the two may be good from a green perspective, but economically may work.

I have to expand on this in a different post... For the time being, with these issues in mind I did a small search. I'll update here what I find. Just typing "Alternatives to capitalism" I got:
  1. Workers self-directed enterprises (WSDEs). I agree with the intro of the article but I honestly feel it fails in the solution. WSDEs may work in some particular case but I doubt they can compete with the traditional company. If you feel that democracy has yielded so far mediocre states, why it would be any different for companies... And anyhow, I think they are far from addressing the problems above.
  2. There Are Good Alternatives to US Capitalism, But No Way to Get There 
Cheers!