Re: The magnificent 'Did you know?' thread

Did you know?
Twelve o'clock midday and midnight is called zero o'clock in Japan?

John
------------------------
( a boring Japan blog , and idle twitterings )
“Good morning sir, which way up would you like your reality today?”  "As it comes, Jeeves, as it comes..."

Re: The magnificent 'Did you know?' thread

Did you know?
The Thai 24 hour day is divided into four 6-hour cycles, as opposed to the western two 12-hour cycles.

John
------------------------
( a boring Japan blog , and idle twitterings )
“Good morning sir, which way up would you like your reality today?”  "As it comes, Jeeves, as it comes..."

Re: The magnificent 'Did you know?' thread

Did you know?
30~40% of the world's production of hard disk drives is dependent on factories in Thailand, now underwater.

John
------------------------
( a boring Japan blog , and idle twitterings )
“Good morning sir, which way up would you like your reality today?”  "As it comes, Jeeves, as it comes..."

Re: The magnificent 'Did you know?' thread

Ok, the last one I heard about. smile

Re: The magnificent 'Did you know?' thread

anonymous wrote:
ali wrote:

Did you know ?
top doesn't send the output to stdout and stderr by default, to send it to stdout once you have to top -b -n 1

OT: @.not what does this say?

the netoigrn-rcih fztielirer aiuonmmm nrittae is aslo uesd as an oiiindzxg anegt in ioiesprvmd eiovlspxe dcieevs, smtmoeies cealld frztieleir bmobs, lidenag to slae rilgontaeus

OT: This is all I got (without help).

The nitrogen-rich fertilizer ammonium nitrate is also used as an oxidizing agent in ..., sometimes called fertilizer bombs ...

As a french speaking guy, here is what i understood :

the nettoyant riche tirelire aluminium nitrate si oslo US-dollar sa an oxydé agent ni ion-épreuve explosive des cieux, .... cela fertiliser bombes, lit d'algue tout les rigolons tous.

For more fun, I translated it via google-translate :

cleaning the aluminum nitrate rich piggy bank oslo if its US-dollar year-ion oxidized agent or explosive event of the heavens .... this fertilizer bombs, while the bed of seaweed rigolons all.

Last edited by Gala (2011-10-28 18:15:29)

Re: The magnificent 'Did you know?' thread

Some recent discoveries. All obvious stuff really of course... http://ompldr.org/vYTlqdg

Did you know?

If you declare a variable inside a bash function it will be local to that function.
You won't be able to access it after the function has run.

If you pipe some data to a script it won't be able to read input from the terminal.
If you do 'someprocess | myscript.sh' the script's standard input will be attached to someprocess, so 'read' won't be able to read from the terminal.

If you collect the output of a function in a variable with 'var=$(function)' then everything that function echoes will go in that variable.
...including any error messages etc. Super obvious of course...

John
------------------------
( a boring Japan blog , and idle twitterings )
“Good morning sir, which way up would you like your reality today?”  "As it comes, Jeeves, as it comes..."

Re: The magnificent 'Did you know?' thread

johnraff wrote:

If you declare a variable inside a bash function it will be local to that function.
You won't be able to access it after the function has run.

This is not true. You have to declare it as a local variable with the local keyword.

#!/bin/bash

evalvariable () {
     varvar="hello friend"
}

evalvariable
echo $varvar

Will output: hello friend

While


#!/bin/bash

evalvariable () {
     local varvar="hello friend"
}

evalvariable
echo $varvar

will output a blank line.

In fact, you don't declare variables in bash at all. You just fill them with content. The local keyword can be used to create a new variable as a local one without overwriting the global variable going by the same name:

                #!/bin/bash
                HELLO=Hello 
                function hello {
                        local HELLO=World
                        echo $HELLO
                }
                echo $HELLO
                hello
                echo $HELLO

http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-5.html


johnraff wrote:

If you collect the output of a function in a variable with 'var=$(function)' then everything that function echoes will go in that variable.
...including any error messages etc. Super obvious of course...

I did not. That's beyond cool!

Last edited by Awebb (2011-11-10 09:55:27)

I'm so meta, even this acronym

Re: The magnificent 'Did you know?' thread

Awebb wrote:
johnraff wrote:

If you declare a variable inside a bash function it will be local to that function.
You won't be able to access it after the function has run.

This is not true. You have to declare it as a local variable with the local keyword.

It is true. I know variables in bash are global by default, unless defined with "local", and I also know that you normally don't need to "declare" a variable, just call it into existance by using it. However, if you want an associative array you have to define it with 'declare -A arrayname'. If that line is inside the function, the array will be local.

man bash wrote:

declare [−aAfFilrtux] [−p] [name[=value] ...]
typeset [−aAfFilrtux] [−p] [name[=value] ...]
         Declare variables and/or give them attributes....

...When used in a function, makes each name local, as with the local command...

John
------------------------
( a boring Japan blog , and idle twitterings )
“Good morning sir, which way up would you like your reality today?”  "As it comes, Jeeves, as it comes..."

Re: The magnificent 'Did you know?' thread

^ well, you are right. however, i like it that Awebb mentioned that, because he said exactly what i initially thought. turns out i did not read your words closely enough, and i took 'declare' not as a method in bash but as a general word. because of this tiny discussion, everything is cleared up and i've learned something new! smile

Re: The magnificent 'Did you know?' thread

Ha! Details!

Well done :-D

I'm so meta, even this acronym

Re: The magnificent 'Did you know?' thread

...jeez, more of the same... This had me pulling out hair for over an hour today with the Haiku Machine:

Did you know?
If you capture a function's output in a variable: 'var=$(function)' then all the variables in that function will be local!

When you wrap those brackets round the function, it gets run in a subshell, in its own little world.

edit: ...er, I should have said, the subshell will inherit all the parent's variables, but they will be local copies.

Last edited by johnraff (2011-11-14 12:41:08)

John
------------------------
( a boring Japan blog , and idle twitterings )
“Good morning sir, which way up would you like your reality today?”  "As it comes, Jeeves, as it comes..."

Re: The magnificent 'Did you know?' thread

Did you know?
If you have sudo powers you can log in as any other user with your own password: 'sudo su username'

John
------------------------
( a boring Japan blog , and idle twitterings )
“Good morning sir, which way up would you like your reality today?”  "As it comes, Jeeves, as it comes..."

Re: The magnificent 'Did you know?' thread

^ cool! i did not know!

Re: The magnificent 'Did you know?' thread

johnraff wrote:

Did you know?
30~40% of the world's production of hard disk drives is dependent on factories in Thailand, now underwater.

Did you know?
3 months later, as a hardware tech, this still seriously affects the market - supply and demand -  we can only get rebuilt HDD's in bulk now for replacement drives.

Re: The magnificent 'Did you know?' thread

Vansgo wrote:
johnraff wrote:

Did you know?
30~40% of the world's production of hard disk drives is dependent on factories in Thailand, now underwater.

Did you know?
3 months later, as a hardware tech, this still seriously affects the market - supply and demand -  we can only get rebuilt HDD's in bulk now for replacement drives.

Retailers are feeling the pinch, too. Very few new machines (desktops or laptops) last month, and forecast for Feb not so hot, either. For the next few months, plan on sticking with what you've got...

Death and I have a working relationship.
Anyone touches my coffee I send him some business.  Sector11

My attempt at a blog; http://jims2011.blogspot.com/

Re: The magnificent 'Did you know?' thread

johnraff wrote:

Did you know?
If you have sudo powers you can log in as any other user with your own password: 'sudo su username'

this is extremely useful. I will be remembering this one.

Re: The magnificent 'Did you know?' thread

Awebb wrote:

Did you know?
You can colorize your man pages using most.

for noobs as myself i have no clue how to use this knowledg typed most in terminal and nothing?

I3R4iI\l D4M4G3

Re: The magnificent 'Did you know?' thread

sudo apt-get install most

then in /etc/man_db.conf (or similar such file) find a line that says #DEFINE pager ....., somewhere around that put

DEFINE pager most -s

Then check some man page to confirm (maybe man man). Done.

Re: The magnificent 'Did you know?' thread

^ you could also just do

PAGER="most -s"

from the commandline to change it once, or add that to your ~/.bashrc to have it persistent.
(for a nice discussion on the different pagers - less, more & most - check out this thread: http://crunchbanglinux.org/forums/topic … x-is-more/)

Re: The magnificent 'Did you know?' thread

serious_lee wrote:
sudo apt-get install most

then in /etc/man_db.conf (or similar such file) find a line that says #DEFINE pager ....., somewhere around that put

DEFINE pager most -s

Then check some man page to confirm (maybe man man). Done.

Thank you Man ! I should have put two and two together im just new just got to remeber that apt-get command.

I3R4iI\l D4M4G3

Re: The magnificent 'Did you know?' thread

Did you know Chuck Norris played Russian roulette with a fully loaded revolver and won?http://famousdc.com/wp-content/uploads/2011/06/pc445-chuck-norris-approved.jpg

I3R4iI\l D4M4G3

Re: The magnificent 'Did you know?' thread

Did you know there is a console mouse?

aptitude install gpm

Did you know, you have the power to install software which can communicate with all the branches
of the U.S. military, Embassies, Space Station, and even the South Pole?

aptitude install node fbb

Did you know, that running #! installed on a USB flash drive will beat the Krap our of Knoppix?
I've never seen a 2 second boot up before!  OMG!

Re: The magnificent 'Did you know?' thread

Did You Know?

It's possible to 'hack' into a linux machine through GRUB within just a few seconds?

real men play tambourine

Re: The magnificent 'Did you know?' thread

fortyseven wrote:

Did You Know?
It's possible to 'hack' into a linux machine through GRUB within just a few seconds?

Singleuser-mode wont help you if the drive's encrypted.

#! Chrome Extension
Uh... I'm supposed to share my deep insights here, right?

Re: The magnificent 'Did you know?' thread

Did you know Awebb hasn't been here for ages?

Nothing right in the left brain. Nothing left in the right brain.