30.March 2011 13:09Maybe the best answer on stackoverflow
Was doing some random browsing when I found this answer on stackoverflow. It could very well be the most thorough answer on stackoverflow!
Was doing some random browsing when I found this answer on stackoverflow. It could very well be the most thorough answer on stackoverflow!
I have finally decided on a subject for my first major written assignment at dtu. The title of my assignment is “Detection of human alertness using supervised learning”. I have to develop a program that given some 30 measurements of physiological and environmental factors can decide whether a driver is about to be inattentive. I am very excited and eager to get going.
I have been up late, finishing my first written assignment for the course Mathematics 3 at DTU. By coincidence I found a very neat proof of the countability of the set of all polynomials with integer coefficients. The idea is to map every polynomial to a unique integer. The easy way to do that is to define a positional base-13 numeral system where the digits for 10, 11 and 12 is represented by the symbols “x”, “+” and “-”. That way, every polynomial, represents a unique integer in the base-13 system. Eg. the polynomial
is the base-13 number
which (in base-10) equals
Every other polynomial maps to a unique integer in the same way. One small problem remains. The preimage of the mapping isn’t the whole set of integers, so what we know right now, is that the cardinality, of the set of polynomials, is less than or equal to the cardinality of the set of integers. No problem. The set of all zero-degree polynomials is a subset of all polynomials, and all zero-degree polynomials maps to a single integer and all integers is mapped by a single zero-degree polynomial. This implies that the cardinality of the set of all polynomials is greater than or equal to the cardinality of the set of integers.
The only possibility that remains is that the cardinality of the polynomials and the integers is exactly equal. Technically we need to show that the integers is countable, by mapping them 1-1 to the natural numbers, but that is trivial.
Sometimes I need to paste something from the clipboard to gvim. The content of the clipboard is saved in the register *, so the command
"*p
does the job.
I’ve just installed Ubuntu and wanted to remap a few keys system wise. The xmodmap command is useful for this task. First you need to find the keycode for the key you want to remap and the keysym that the key should be remapped to.
$ xmodmap -pk | less
When you have found the keycode and the keysym you just enter
$ xmodmap -e 'keycode <keycode> = <keysym>'
and then the key is remapped.
EDIT 08-04-2011:
Use the command xev to find the keycode for the key you want to remap. If I want to change the key that is the half fraction on my Lenovo I type in
$ xmodmap -e 'keycode 49=dollar'
Jeg ved ikke hvor mange gange jeg har brugt disse kommandoer, men jeg bliver alligevel ved med at glemme dem! Grr…
Opret arkiv med
tar cvzf archivename.tar.gz foldernametotar
Udpak arkiv med
tar xvzf archivename.tar.gz
Skulle lige sikre mig at python 2.5 returnerede floats ved division, men var lidt distræt og endte med at skrive
from __future__ import decision
det kunne være pænt sejt hvis det virkede…
Jeg kan stadig finde nye små godbidder blandt phps funktioner. Nogen gange kommer jeg ud for en situation hvor en funktion har en række parametrer som den så skal samle i et array og sende videre:
function menu($items, $id, $show_submenus) {
return render_partial('menu', array(
'items' => $items,
'id' => $id,
'show_submenus' => $show_submenus
));
}
Repetitionen er rimelig tydelig, men jeg vil gerne have funktionen “menu” så jeg i min template kan skrive
<div class="some_wrapper">
<?=menu($items, 'mainmenu', true)?>
</div>
istedet for
<div class="some_wrapper">
<?=render_partial('menu', array('items'=>$items, 'id'=>'mainmenu', 'show_submenus'=>true)?>
</div>
Løsningen er en php-funktion jeg har overset indtil i dag. Compact tager et vilkårligt antal strenge. For hver streng undersøger den om der er en variabel med samme navn defineret i samme scope, som compact bliver kaldt. Hvis der er, bliver variablens værdi tilføjet til det array compact i sidste ende returnerer. Arrayet compact returnerer har variablens navn som key og variablens værdi som value. Lige hvad der skal bruges til at gøre min menu-funktion pænere.
function menu($items, $id, $show_submenus) {
return render_partial('menu', compact('items','id','show_submenus'));
}
Sidder og skal have bikset en aflevering i operationsanalyse (nej det har ikke noget med hospitalsvæsenet at gøre) færdig. Jeg skal blandt andet skrive nogle matricer der skal have lodrette streger mellem nogle af kolonnerne. Fandt denne lille stump man bare skal smide i sin preamble
\makeatletter
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
\hskip -\arraycolsep
\let\@ifnextchar\new@ifnextchar
\array{#1}}
\makeatother
og vupti så kan man få lodrette streger ved at angive en ekstra parameter til matrix-environmentet.
\begin{bmatrix}[ccc|cc]
2 & 1 & 2 & 1 & 0 \\
1 & 2 & 3 & 0 & 1
\end{bmatrix}
Har lige installeret WP-Latex og skal lige tjekke at det virker:
Det virker det jo til det gør. Og her: