Tuesday, March 26, 2013

美国富人控制舆论

美国富人控制舆论,核心是压制平民的独立思维.有六种兵器.

1)让政治辩论变得丑陋.金钱+语言游戏=摧毁所有独立思维的平台.让你厌倦,绝望和怀疑自己 的思维.

2)提供注意力寄托.竞技体育,娱乐圈提供注意力的避难场所,也促进政治厌倦.

3)政治正确性的控制.如反犹太,社会主义和不爱国等帽子.

4)平 常积累媒体credibility,关键时候用来造假愚众。用"市场决定论"回应对媒体的质疑.

5)留余地.关键问题上放一点讨论空间,非关键问题上全面 放开,作为民主自由的证据.

6)大力宣传极少数平民变富翁的故事,让99%的人对American dream保持希望.

Saturday, March 16, 2013

Raspberry Pi + Ardunio

In a few weeks I will acquire a Raspberry Pi kit and Ardunio UNO kit for my own embedded system exploration. Will report back when I get them.

Here is a list of materials needed for this project:

1. Raspherry Pi model B: to serve as the master brain in the system. The Pi has an ARM microprocessor and standard IOs, much as a regular computer. It also comes with a Linux distribution (Raspbian), and support programming with Python (my favorite programming platform).

2. Ardunio UNO R3: to serve as a slave brain in the system. The Pi is a full fledge OS, but not perfect to perform real time work, such as, accurate timing. Ardunio has a microcontroller on it (ATmega328), which is capable of real time work. The on-the-chip ADC can be used to sense the physical world (through sensor add-ons).

3. Some basic electronics components such as: resistors, transistors, capacitors, jumper wires and so on.

4. Some interesting sensors will be great. I am thinking as least a temperature sensor, an accelerometer, a camera or a photo cell. 

5. I also need a way to control motors, if I decide to build some robotics or automation stuff. A motor controller and some stepper motors will be necessary.

6. For home automation application, I might also need a relay board with a bunch of 120VAC relays controllable with the digital IO from the Pi. The advantage of doing it with the Pi, instead of the ardunio is that one can control the Pi and hence the relays remotely on the web.

7. Neither the Pi or Arduino has built-in DAC. If I want to build a real-time function generator (probably better off with Arduino since it's a real-time system), a DAC is needed.

8. Of course, I definitely need a multi-meter on my bench to measure voltage and stuff.

Embedded System

An embedded system stands for a microprocessor embedded in a device to control its functions. It's very similar to a computer, in that input data can be processed and output. The major difference is, unlike a computer, an embedded system does not have a human sitting in front of a monitor and keyboard to tell it what to do. An embedded system is likely located inside a microwave, or a robotic machinery, to perform certain, but routine tasks. There are usually a few buttons to operate an embedded system, such as "start", "stop", for example. But other than that, it's mostly an autonomous machine running on its own schedule and going through a same set of instructions repeatedly.

One scheme of running an embedded system is to use service scheduling. Once the power button is on, an initialization routine will load a list of service to be executed based on a pre-determined schedule. Such list is something like this:

1. Clean the floor, every 1 hours, starting 5 mins from now
2. Clean the toilet, every 2 hours, starting 10 mins from now
3. Clean the window, every 3 hours, starting now
...

Basically, the schedule contains information of when to do what and how often.

Once the list is loaded, upon hitting the "start" button, the embedded system will start running this permanent loop:

while (1)
{
      if "someone presses 'stop'"
             goto end;
      run_the_list();
}

end:
      exit();

The permanent loop will make sure the machine will ignore everything else happening in the world, faithfully focuses on the tasks scheduled on the service list, until someone presses the "stop" button, or it runs out of power.




Saturday, March 9, 2013

Marijuana vs Tobacco

Written by Noam Chomsky

Ask ourselves a simple question: how come marijuana is illegal, but tobacco legal? It can't be because of the health impact, because that's exactly the other way around. There has never been a fatality from marijuana use among 60 million reported users in the United States, whereas tobacco kills hundreds of thousands of people every year. My strong suspicion, that I don't know how to prove it, is that marijuana is a weed, you can grow it in your backyard, so there's nobody who would make any money off it if it were legal. Tobacco requires extensive capital inputs and technology, and it can be monopolized, so there are people who can make a ton of money off it. I don't really see any other difference between the two of them, frankly-except that tobacco is far more lethal and far more addictive.

Friday, March 8, 2013

More update on ion column design

In the last week or so, I carried out some more systematic study on electrostatic lens design. The overall goal of designing a lens is to meet the following criteria:

- achieve minimum spherical and chromatic aberration coefficients
- have the ability to focus with practical high voltage power supplies
- minimize the probability of micro-discharging between neighboring elements
- has to be manufacturable
- accommodate other physical restrictions, as such field of view, delfection, and etc.

The first step is optimizing the lens geometry for minimal aberrations. Basic geometrical factors include the thickness and bore size of each element, and the gaps between elements. To study the effect of one geometrical factor, one needs to systematically vary that factor, then compute the axial potential field distribution from it. Aberration coefficients can then be evaluated from the axial field. Python is a very convenient tool here for "glueing" multiple smaller modelling programs together. For each geometrical factor, I wrote a .py script to automate the parameter variation, and the extraction of the aberration coefficients.

Once a french ion optics researcher gave a talk at Zeiss, on the FIB that he designed. He stressed that it is simply impossible to design a FIB that can do everything, meaning that achieving the best resolution, and at the same time being a material hogging machine. I was not quite sure what he meant at the time. With more hands-on experience on column design, it becomes more obvious to me that some lenses have to be optimized for low current probes, while others have to be tweaked for larger current probes. Often times the two types of optimizations contradict each other, pushing one to an extreme will inadvertently compromise the other. As a result, at the beginning of a column design, one have to set out and ask, what is the end application of the column? Is it for high resolution imaging which usually uses a small probe size and probe current? Or for high-throughput material modification that would require a higher probe current?

I charged to design a condenser lens, which will magnify a source into a cross-over, and an objective lens that demagnify the the cross-over into a probe. The initial assessment of the column built out of the combination of the two lenses is promising, in terms of resolution performance.

Wednesday, March 6, 2013

Essential Navigation in Vim

This article is written by SathiyaMoorthy.

This article is part of the ongoing Vi / Vim Tips and Tricks series. Navigation is a vital part of text editing. To be very productive, you should be aware of all possible navigation shortcuts in your editor. In this article, let us review the following 8 Vi / Vim navigation options.
  1. Line navigation
  2. Screen navigation
  3. Word navigation
  4. Special navigation
  5. Paragraph navigation
  6. Search navigation
  7. Code navigation
  8. Navigation from command line

1. Vim Line Navigation

Following are the four navigation that can be done line by line.
  • k – navigate upwards
  • j – navigate downwards
  • l – navigate right side
  • h – navigate left side

By using the repeat factor in VIM we can do this operation for N times. For example, when you want to
go down by 10 lines, then type “10j”.

Within a line if you want to navigate to different position, you have 4 other options.
  • 0 – go to the starting of the current line.
  • ^ – go to the first non blank character of the line.
  • $ – go to the end of the current line.
  • g_ – go to the last non blank character of the line.

2. Vim Screen Navigation

Following are the three navigation which can be done in relation to text shown in the screen.
  • H – Go to the first line of current screen.
  • M – Go to the middle line of current screen.
  • L – Go to the last line of current screen.
  • ctrl+f – Jump forward one full screen.
  • ctrl+b – Jump backwards one full screen
  • ctrl+d – Jump forward (down) a half screen
  • ctrl+u – Jump back (up) one half screen

3. Vim Special Navigation

You may want to do some special navigation inside a file, which are:
  • N% – Go to the Nth percentage line of the file.
  • NG – Go to the Nth line of the file.
  • G – Go to the end of the file.
  • `” – Go to the position where you were in NORMAL MODE while last closing the file.
  • `^ – Go to the position where you were in INSERT MODE while last closing the file.
  • g – Go to the beginning of the file.

4. Vim Word Navigation

You may want to do several navigation in relation to the words, such as:
  • e – go to the end of the current word.
  • E – go to the end of the current WORD.
  • b – go to the previous (before) word.
  • B – go to the previous (before) WORD.
  • w – go to the next word.
  • W – go to the next WORD.

WORD – WORD consists of a sequence of non-blank characters, separated with white space.
word – word consists of a sequence of letters, digits and underscores.

Example to show the difference between WORD and word
  • 192.168.1.1 – single WORD
  • 192.168.1.1 – seven words.

5. Vim Paragraph Navigation

  • { – Go to the beginning of the current paragraph. By pressing { again and again move to the previous paragraph beginnings.
  • } – Go to the end of the current paragraph. By pressing } again and again move to the next paragraph end, and again.

6. Vim Search Navigation

  • /i – Search for a pattern which will you take you to the next occurrence of it.
  • ?i – Search for a pattern which will you take you to the previous occurrence of it.
  • * - Go to the next occurrence of the current word under the cursor.
  • # - Go to the previous occurrence of the current word under the cursor.

7. Vim Code Navigation

% – Go to the matching braces, or parenthesis inside code.

8. Vim Navigation from Command Line

Vim +N filename: Go to the Nth line of the file after opening it.
vim +10 /etc/passwd

Vim +/pattern filename: Go to the particular pattern’s line inside the file, first occurrence from first. In the following example, it will open the README file and jump to the first occurrence of the word “install”.
vim +/install README

Vim +?patten filename: Go to the particular pattern’s line inside the file, first occurrence from last. In the following example, it will open the README file and jump to the last occurrence of the word “bug”.
vim +?bug README

Importing Python Modules

Importing Python Modules

January 07, 1999 | Updated February 02, 2001 | Fredrik Lundh

Introduction #

The import and from-import statements are a constant cause of serious confusion for newcomers to Python. Luckily, once you’ve figured out what they really do, you’ll never have problems with them again.
This note tries to sort out some of the more common issues related to import and from-import and everything.

There are Many Ways to Import a Module #

Python provides at least three different ways to import modules. You can use the import statement, the from statement, or the builtin __import__ function. (There are more contrived ways to do this too, but that’s outside the scope for this small note.)
Anyway, here’s how these statements and functions work:
  • import X imports the module X, and creates a reference to that module in the current namespace. Or in other words, after you’ve run this statement, you can use X.name to refer to things defined in module X.
  • from X import * imports the module X, and creates references in the current namespace to all public objects defined by that module (that is, everything that doesn’t have a name starting with “_”). Or in other words, after you’ve run this statement, you can simply use a plain name to refer to things defined in module X. But X itself is not defined, so X.name doesn’t work. And if name was already defined, it is replaced by the new version. And if name in X is changed to point to some other object, your module won’t notice.
  • from X import a, b, c imports the module X, and creates references in the current namespace to the given objects. Or in other words, you can now use a and b and c in your program.
  • Finally, X = __import__(‘X’) works like import X, with the difference that you 1) pass the module name as a string, and 2) explicitly assign it to a variable in your current namespace.

Which Way Should I Use? #

Short answer: always use import.
As usual, there are a number of exceptions to this rule:
  • The Module Documentation Tells You To Use from-import. The most common example in this category is Tkinter, which is carefully designed to add only the widget classes and related constants to your current namespace. Using import Tkinter only makes your program harder to read; something that is generally a bad idea.
  • You’re Importing a Package Component. When you need a certain submodule from a package, it’s often much more convenient to write from io.drivers import zip than import io.drivers.zip, since the former lets you refer to the module simply as zip instead of its full name. In this case, the from-import statement acts pretty much like a plain import, and there’s not much risk for confusion.
  • You Don’t Know the Module Name Before Execution. In this case, use __import__(module) where module is a Python string. Also see the next item.
  • You Know Exactly What You’re Doing. If you think you do, just go ahead and use from-import. But think twice before you ask for help ;-)

What Does Python Do to Import a Module? #

When Python imports a module, it first checks the module registry (sys.modules) to see if the module is already imported. If that’s the case, Python uses the existing module object as is.
Otherwise, Python does something like this:
  1. Create a new, empty module object (this is essentially a dictionary)
  2. Insert that module object in the sys.modules dictionary
  3. Load the module code object (if necessary, compile the module first)
  4. Execute the module code object in the new module’s namespace. All variables assigned by the code will be available via the module object.
This means that it’s fairly cheap to import an already imported module; Python just has to look the module name up in a dictionary.