This is O.R.Senthil Kumaran's blogspot on programming and technical things. The title is a line from "Zen of Python".
Posting via Jabber
Posting this via Jabber, that is LJ talk. Noticed today that Live journal user page has a forceful ad serving. You got to wait and press on the top right x to close it and then access your account page.
Video Chat on Ubuntu
If you would like to do a Video Chat on Ubuntu, then
1. Install Skype 2.0 on Ubuntu.
2. Follow the instructions mentioned here to make the Video option work fine.
1. Install Skype 2.0 on Ubuntu.
2. Follow the instructions mentioned here to make the Video option work fine.
How to Use Math Symbols in gnome-terminal
HOLD CTRL+SHIFT + U + CODEPOINT. That's it.
For e.g. CTRL + SHIFT + U + 2200 will output ∀ After typing CTRL + SHIFT + U,
when the terminal identifies that what follows is unicode, you might leave the
keypresses and just type the codepoint.
∀ U2200
∁ U2201
∂ U2202
∃ U2203
∄ U2204
∅ U2205
∆ U2206
U2207
U2208
∉ U2209
∊ U220A
For e.g. CTRL + SHIFT + U + 2200 will output ∀ After typing CTRL + SHIFT + U,
when the terminal identifies that what follows is unicode, you might leave the
keypresses and just type the codepoint.
∀ U2200
∁ U2201
∂ U2202
∃ U2203
∄ U2204
∅ U2205
∆ U2206
U2207
U2208
∉ U2209
∊ U220A
C++0x support in gcc
http://gcc.gnu.org/projects/cxx0x.html
Some of the features are already available in gcc.
Some of the features are already available in gcc.
Python Strings as Comments
The question was:
In Python we can emulate multiline comments using triple-quoted
strings, but conceptually strings and comments are very different.
I.e. strings are objects, comments are auxillary text discarded at
compile time. Strings are objects created at runtime, comments are
not.
The answer from Steven D'Aprano:
Guido's time-machine strikes again.
String literals -- not just triple-quoted strings, but any string
literal -- that don't go anywhere are discarded by the Python compiler,
precisely so they can be used as comments.
In Python we can emulate multiline comments using triple-quoted
strings, but conceptually strings and comments are very different.
I.e. strings are objects, comments are auxillary text discarded at
compile time. Strings are objects created at runtime, comments are
not.
The answer from Steven D'Aprano:
Guido's time-machine strikes again.
>>> import dis
>>> def test():
... x = 1
... """
... This is a triple-quote comment.
... """
... return x
...
>>> dis.dis(test)
2 0 LOAD_CONST 1 (1)
3 STORE_FAST 0 (x)
6 6 LOAD_FAST 0 (x)
9 RETURN_VALUE
String literals -- not just triple-quoted strings, but any string
literal -- that don't go anywhere are discarded by the Python compiler,
precisely so they can be used as comments.
ln explained best
At this article titled Demystifying the Natural Logarithm
His entire series of get an intuition articles on Maths is very good.
His entire series of get an intuition articles on Maths is very good.
Pell's Equation
x^2 - n y^2 = 1
(Pell's equation) which is named after the English mathematician John Pell. It was studied by Brahmagupta in the 7th century, as well as by Fermat in the 17th century.
http://en.wikipedia.org/wiki/Pell%27s_equation
(Pell's equation) which is named after the English mathematician John Pell. It was studied by Brahmagupta in the 7th century, as well as by Fermat in the 17th century.
http://en.wikipedia.org/wiki/Pell%27s_equation
8 Bit Byte
Factors behind the ubiquity of the eight bit byte include the popularity of the IBM System/360 architecture, introduced in the 1960s, and the 8-bit microprocessors, introduced in the 1970s. The term octet unambiguously specifies an eight-bit byte (such as in protocol definitions, for example)
http://en.wikipedia.org/wiki/Byte
Otherwise, people have tried with 12 bit byte. Varying byte length in PDP 10. 6, 7 and 9 bits in Univac computers.
http://en.wikipedia.org/wiki/Byte
Otherwise, people have tried with 12 bit byte. Varying byte length in PDP 10. 6, 7 and 9 bits in Univac computers.
Brainfuck
+++ +++ +++ +[>
+++ +++ +
>
+++ +++ +++ +
<++ .
>+++ ++ .
Brainfuck is easy and interesting.
We work on cells, like if you know c, cell is like ptr = unsigned char *
+ stands for increment like ++*ptr
- stands for decrement like --*ptr
> goes one cell right like ++ptr
< goes one cell left like --ptr
. spits out output like putchar(*ptr)
, expects input. like *ptr = getchar(stdin)
[ is the start of while block test condition (for non-zero) which is like while(*ptr) {
] is the end of the block }
And everything else is comment, like the these sentences.
The above program is designed to output "Hi" and if you include these
sentenses too, it will print "Hii" and wait for some input and enter
presses till the cell becomes zero.
Isn't it cool? :)
BTW, you can run this program using an interpretor called (bf) just an apt-get away.
+++ +++ +
>
+++ +++ +++ +
<++ .
>+++ ++ .
Brainfuck is easy and interesting.
We work on cells, like if you know c, cell is like ptr = unsigned char *
+ stands for increment like ++*ptr
- stands for decrement like --*ptr
> goes one cell right like ++ptr
< goes one cell left like --ptr
. spits out output like putchar(*ptr)
, expects input. like *ptr = getchar(stdin)
[ is the start of while block test condition (for non-zero) which is like while(*ptr) {
] is the end of the block }
And everything else is comment, like the these sentences.
The above program is designed to output "Hi" and if you include these
sentenses too, it will print "Hii" and wait for some input and enter
presses till the cell becomes zero.
Isn't it cool? :)
BTW, you can run this program using an interpretor called (bf) just an apt-get away.
Kavka's toxin puzzle
In its original form, it is:
An eccentric billionaire places before you a vial of toxin that, if you drink it, will make you painfully ill for a day, but will not threaten your life or have any lasting effects. The billionaire will pay you one million dollars tomorrow morning if, at midnight tonight, you intend to drink the toxin tomorrow afternoon. He emphasizes that you need not drink the toxin to receive the money; in fact, the money will already be in your bank account hours before the time for drinking it arrives, if you succeed. All you have to do is. . . intend at midnight tonight to drink the stuff tomorrow afternoon. You are perfectly free to change your mind after receiving the money and not drink the toxin.
Kavka's theory is that, one cannot intend to do something which one won't do.
There is an analysis of payoffs from different scenarios and the real-world example of this puzzle is:
...the Political Manifesto. Before an election, a political party will release a written document outlining their policies and plans should they win office. Many of these promises may be difficult or impossible to implement in practice. Having won, the party is not obligated to follow the manifesto even if they would have lost without it.
An eccentric billionaire places before you a vial of toxin that, if you drink it, will make you painfully ill for a day, but will not threaten your life or have any lasting effects. The billionaire will pay you one million dollars tomorrow morning if, at midnight tonight, you intend to drink the toxin tomorrow afternoon. He emphasizes that you need not drink the toxin to receive the money; in fact, the money will already be in your bank account hours before the time for drinking it arrives, if you succeed. All you have to do is. . . intend at midnight tonight to drink the stuff tomorrow afternoon. You are perfectly free to change your mind after receiving the money and not drink the toxin.
Kavka's theory is that, one cannot intend to do something which one won't do.
There is an analysis of payoffs from different scenarios and the real-world example of this puzzle is:
...the Political Manifesto. Before an election, a political party will release a written document outlining their policies and plans should they win office. Many of these promises may be difficult or impossible to implement in practice. Having won, the party is not obligated to follow the manifesto even if they would have lost without it.
Subscribe to:
Posts (Atom)