sudo make me a sandwich

xkcd 149 – punch this in your terminal:

cat > Makefile << _EOF
SHELL=/bin/bash
all: sandwich
me:
`echo $'\t'`@touch me
a:
`echo $'\t'`@if [ -e me ]; then rm me; touch a; fi
sandwich:
`echo $'\t'`@bash -c 'if [ -e a ]; then rm a; if [ \`whoami\` == "root" ] ; then echo "Ok"; else echo "Make it yourself"; fi; else echo "...?"; fi'
_EOF

After that, try telling your command line to make you a sandwich, like this:

$ make me a sandwich
Make it yourself
$ sudo make me a sandwich
[sudo] password for ivucica:
Ok
$

corrected on August 11 2009, to adjust for differences in Ubuntu’s shell 🙂
corrected on September 24 2015, to explicitly specify use of /bin/bash and fix breakage on Debian Jessie

SSH server owners, beware

In case you haven’t noticed yet, your machine may be under attacks from botnets. Go check your /var/log/auth.log (at least under Debian) and see for yourself. Botnets are attempting to crack your passwords using brute-force.

Recommended strategies:
  • Change port. I’ve picked 2022.
  • Disable password logins. Use only authentication using secure keys. Too much of a hassle for me, especially on a server I share with others, since we’d have to carry our key files around.

Backspace on Firefox on Ubuntu and Iceweasel on Debian

A friend pointed this out to me:
http://kb.mozillazine.org/Browser.backspace_action

In short, if you’re a GNU/Linux user of Firefox (e.g. Firefox on Ubuntu and Iceweasel on Debian) you may want to get backspace to actually go back one page, like many browsers do (did?):

  1. In addressbar, type about:config
  2. If asked, confirm you want to change settings
  3. In search, type browser.backspace_action
  4. Set the value of browser.backspace_action to 0 (that is zero, not letter O) Zero is Windows default and makes pressing backspace go back in history; One is old Linux default and scrolls page up; Two is new Linux default and, like any other integer, simply unmaps the backspace key.

Now, enjoy pressing backspace to go back!

Image source

Microsoft SQL Server 2005 Express vs. MSXML6 SP2

I know very little of this, except I spent about 2 days trying to get MSSQL2005 to work on my machine. A lot of googling, a lot of reinstall, and a lot of thinking that it was perhaps caused by low disk space condition, then perhaps that it was caused by me not having IIS installed (because it was recommended by installer).

So here’s what I was doing:
  • MSSQL included with VS doesn’t want to install. I try freeing up disk space.
  • I try uninstalling VS2005. After reinstall doesn’t work.
  • I go get standalone MSSQL2005 Express. It doesn’t work either
  • I notice that standalone MSSQL recommends IIS to “get all features working”. Now IIS included with XP wants something off of SP3’s installation CD located in C:\Windows\ServicePackFiles … which is a folder I deleted to free up disk space!
  • I reinstall SP3 to restore above folder. IIS installation still doesn’t find the files. You can recognize this condition by file staxmem.dll or staxmem.dl_ being located in the folder you chose, but Windows not recognizing this.
  • I find out that I need to repair it with esentutl. KB894351
  • This works! I get IIS. Installation os MSSQL still fails with ~3 components passing ok, but the key one – service – failing, along with MSXML6.
  • I finally dig out something that relates MSXML6 SP2 and MSSQL 2005 Express not tolerating each other! I can’t find original site, but this will help even better.
  • Basically I can’t uninstall MSXML6 because of error without any helpful information in it… What now?!
  • I uninstall MSXML6SP2 using Windows Installer Cleanup Utility. I get the feeling that it’s not real uninstallation… but I don’t care as long as this junk gets to work.
  • Apparently it finally works!
Now, I’d try to avoid MSSQL after this kind of debacle … but I’ll need to use it for university work – a class that practically depends on .Net, C#, MSSQL, Windows Mobile and ASP. Annoying but I’ll have to make it through.

Decimal commas with scanf() / Decimalni zarezi sa scanf()

I wrote a Wavefront .obj format reader that uses fscanf(). Imagine my surprise when getting errors such as “Unknown wavefront command ‘.5438581’ in models/tube.obj”. This was first time I compiled the game under Windows with libintl code thrown in. Turns out that scanf() family of functions adapts to your locale.

That is, since Croatian locale uses comma in place of decimal point, when fscanf() encountered a decimal point it coughed and gave up.
A simple:
setlocale(LC_ALL, “C”);
restored things to normal.
Edited: 
setlocale(LC_NUMERIC, “C”);
Napisao sam čitač za Wavefront .obj format koji koristi fscanf(). Zamislite moje iznenađenje kad sam počeo dobivati greške tipa “Unknown wavefront command ‘.5438581’ in models/tube.obj”. Ovo je prvi put da kompajlirah igru pod Windowsima s ubačenim libintl kodom. Ispada da se scanf() funkcije prilagođavaju regionalnim opcijama.
Odnosno, budući da hrvatske regionalne postavke koriste decimalni zarez umjesto decimalne točke, kad je fscanf() naletio na točku, zakašljao se i odustao.
Jednostavan:
setlocale(LC_ALL, “C”);
vraća sve na normalno.
Uređeno:
setlocale(LC_NUMERIC, “C”);

Vip over IP – VoIP – ims.vip.hr – Ekiga on Linux, ZOIPER on Windows and Mac

Greetings, this post will be in Croatian since it’s aimed for Croatian (l)users.

7. ožujka 2010:
Javljeno mi je kako je Vip promijenio neke backend stvari za Vip VoIP, te stoga možda ove upute više ne funkcioniraju. Ukoliko netko isproba i/ili otkrije točne postavke, javite mi. Primijetite kako je ovo relativno stari post 🙂

Pozdrav, evo ukratko kako setupirati Ekigu da koristi “Vip over IP“. Prvo dakako morate imati Vip korisničko ime. Nakon što se registrirate, idemo dalje…

Vip over IP koristi SIP, Session Initiation Protocol. Njihov brandirani klijent je ustvari CounterPath Bria. Kako smo korisnici GNU/Linuxa, to nam ne pomaže. Pa krenimo.

Svakako će Vam trebati nova Ekiga. S verzijom 2.0.12 koja je u Debianu nisam uspio natjerati stvar da proradi. Također, nisam uspio s bilo kojim drugim non-CounterPathovim klijentom.

Prvo instalirati najnoviju Ekigu (meni radi sa paketom ekiga-snapshot, koji na današnji dan ima verziju 3.1.1). Detaljne upute za željne dječake (i djevojčice) su ovdje: http://snapshots.ekiga.net/

Sad ide zabavan dio, postavke.

Edit->Preferences->Protocols->SIP Settings->Outbound Proxy:

ims.vip.hr

Edit->Accounts, Accounts->Add a SIP account:

Name: [bilošto]
Registrar: vip.hr
User: korisnickoime
Authentication user: korisnickoime@vip.hr
Password: viponlinepassword
Timeout: 3600

Sretno svima koji se s ovime pate, javite jesam li nešto zbrljao pa da ispravim 🙂

Dodatno STUN server isključite. Vipov klijent koristi IP adresu od Vašeg interfacea, pa makar bila iz privatnog raspona. Mislim da je to uzrokovalo probleme, no nisam 100% siguran.

7. ožujka 2010: od 13. prosinca 2009 do danas ovdje su bile objavljene i postavke za ZOIPER FREE, no autor tog dijela javio mi je kako te postavke više ne funkcioniraju te zamolio za uklanjanje, što je i učinjeno.