gnome-panel is dead, long live gnome-panel! -
TL;DR: You can reorganize your gnome panel by using Alt when right-clicking. Whew.
SQL joins can be really powerful once you got the hold of them. Especially interesting could be self-joins, i.e. joining the table onto itself.
Let’s say you have a table of daily temperatures:
create table temperatures (
id serial,
date date,
temp numeric(4,2)
);
insert into temperatures (date, temp) values ('2011-09-01', 30);
insert into temperatures (date, temp) values ('2011-09-02', 28);
insert into temperatures (date, temp) values ('2011-09-03', 27);
insert into temperatures (date, temp) values ('2011-09-04', 32);
insert into temperatures (date, temp) values ('2011-09-06', 26);
select * from temperatures;
id | date | temp
----+------------+-------
1 | 2011-09-01 | 30.00
2 | 2011-09-02 | 28.00
3 | 2011-09-03 | 27.00
4 | 2011-09-04 | 32.00
5 | 2011-09-06 | 26.00
(5 rows)
Say that we want a query which would, for each day, calculate the difference between that and the previous measurement.
We will start with a simple query to get all date’s temperatures:
select date, temp from temperatures order by date;
date | temp
------------+-------
2011-09-01 | 30.00
2011-09-02 | 28.00
2011-09-03 | 27.00
2011-09-04 | 32.00
2011-09-06 | 26.00
(5 rows)
Ok, that’s easy. Now we will expand this table with other dates, but we can narrow our query to only get dates prior to the current one:
select t1.date, t1.temp, t2.date
from temperatures t1
left join temperatures t2 on t1.date > t2.date
order by t1.date, t2.date;
date | temp | date
------------+-------+------------
2011-09-01 | 30.00 |
2011-09-02 | 28.00 | 2011-09-01
2011-09-03 | 27.00 | 2011-09-01
2011-09-03 | 27.00 | 2011-09-02
2011-09-04 | 32.00 | 2011-09-01
2011-09-04 | 32.00 | 2011-09-02
2011-09-04 | 32.00 | 2011-09-03
2011-09-06 | 26.00 | 2011-09-01
2011-09-06 | 26.00 | 2011-09-02
2011-09-06 | 26.00 | 2011-09-03
2011-09-06 | 26.00 | 2011-09-04
(11 rows)
Now we have matched every date with all previous dates. (An important thing to note is that 2011-09-01 doesn’t have matched record. That’s because there is no date prior to 2011-09-01 in the table). So, for example, for 2011-09-04 we have all three, 01, 02, and 03. matched. We need just the most recent one, i.e. 03.
We will now use a trick to achieve this. We will add another join to eliminate all the dates but the most recent one:
select t1.date, t1.temp, t2.date, t3.date
from temperatures t1
left join temperatures t2 on t1.date > t2.date
left join temperatures t3 on t3 < t1 and t2 < t3
order by t1.date, t2.date, t3.date;
date | temp | date | date
------------+-------+------------+------------
2011-09-01 | 30.00 | |
2011-09-02 | 28.00 | 2011-09-01 |
2011-09-03 | 27.00 | 2011-09-01 | 2011-09-02
2011-09-03 | 27.00 | 2011-09-02 |
2011-09-04 | 32.00 | 2011-09-01 | 2011-09-02
2011-09-04 | 32.00 | 2011-09-01 | 2011-09-03
2011-09-04 | 32.00 | 2011-09-02 | 2011-09-03
2011-09-04 | 32.00 | 2011-09-03 |
2011-09-06 | 26.00 | 2011-09-01 | 2011-09-02
2011-09-06 | 26.00 | 2011-09-01 | 2011-09-03
2011-09-06 | 26.00 | 2011-09-01 | 2011-09-04
2011-09-06 | 26.00 | 2011-09-02 | 2011-09-03
2011-09-06 | 26.00 | 2011-09-02 | 2011-09-04
2011-09-06 | 26.00 | 2011-09-03 | 2011-09-04
2011-09-06 | 26.00 | 2011-09-04 |
(15 rows)
What’s this? Even more records! We join with t3, but in such way that the date from t3 must be between dates from t1 and t2. But if you note the “missing” bits in t3.date column, you will see that for some date pairs from t1 and t2, there is no t3.date. That’s the records where t2.date is right before t1.date. We need only that records. So, we’ll just add WHERE clause to discard all the records where t3.date exists:
select t1.date, t1.temp, t2.date, t3.date
from temperatures t1
left join temperatures t2 on t1.date > t2.date
left join temperatures t3 on t3 < t1 and t2 < t3
where t3.date is null
order by t1.date, t2.date, t3.date;
date | temp | date | date
------------+-------+------------+------
2011-09-01 | 30.00 | |
2011-09-02 | 28.00 | 2011-09-01 |
2011-09-03 | 27.00 | 2011-09-02 |
2011-09-04 | 32.00 | 2011-09-03 |
2011-09-06 | 26.00 | 2011-09-04 |
(5 rows)
Right! Back to 5 rows, with just right values in t2.date column. Now all we have to do is add the temperature difference, and we’re done:
select t1.date, t1.temp, t2.date, t1.temp - t2.temp as diff
from temperatures t1
left join temperatures t2 on t1.date > t2.date
left join temperatures t3 on t3 < t1 and t2 < t3
where t3.date is null
order by t1.date, t2.date, t3.date;
date | temp | date | diff
------------+-------+------------+-------
2011-09-01 | 30.00 | |
2011-09-02 | 28.00 | 2011-09-01 | -2.00
2011-09-03 | 27.00 | 2011-09-02 | -1.00
2011-09-04 | 32.00 | 2011-09-03 | 5.00
2011-09-06 | 26.00 | 2011-09-04 | -6.00
(5 rows)
That’s it. :)
You have received a bunch of photos to you GMail account, and you want to publish them to your Picasa web album, but you hate having them downloaded to your machine, and then again uploaded to web, especially knowing that both Gmail and Picasa are Google’s applications. Wouldn’t it be nice if Gmail had an option to, besides download, upload the photos directly? Unfortunately, no such option.
There’s a workaround though. Go to your Picasa web account, go to photo settings page, there you will see an option to enable “email to Picasa”, by setting a special email account at @picasaweb.com. Just enable it, go to your Gmail, and simply forward your email with attached photos to newly created email address. You will get your photos imported to Picasa almost instantly.
Nakon reakcija iz branše na po ko zna koji preplaćen državni sajt, palo mi je na pamet da sistematizujem i klasifikujem sve vrste griža savesti koje se javljaju, kao i načine za njihovo suzbijanje.
Da počnemo od najbanalnijih, ali i najtežih za suzbijanje…
Ovo je lagano. Ne sečete granu na kojoj sedite. Daleko bilo da podignete svoj glas i otvoreno kažete šefu da to ne košta toliko i da nije u redu što je nabacio posao svom kumašinu nego da je trebalo da se raspiše tender. Ne samo da biste ostali vi bez posla, nego i vaša žena i pašenog, koje ste ugurali na državne jasle preko poznanstva.
Jasno - ne grizeš ruku koja te hrani. Konkurencija je gadna, vi ste naprimali kadar, ima tu i nešto slabijih programera, treba vremena (i para) dok se uhodaju, iznajmili ste fensi kancelarije, treba to pokrpiti. Pa nećete valjda u starkama raditi posao za Vlast?!
Pratite tendere, ortačite se sa perspektivnim partijskim kadrovima, pravite “socijalnu infrastrukturu” za buduće poslove. Ovaj posao su maznuli drugi, ali sledeći je vaš, kad ministarstvo gde radi vaš budući kum dođe na red. Ne želite da se sutradan postavi pitanje da li ste naplatili previše. I ako se postavi, pokazaćete prstom na svoju računicu od prošle godine gde ste matematički precizno dokazali da ni prethodnih N sajtova nikako nije preplaćeno.
Kada ste prethodni put stranom partneru lupili cifru triput veću nego što mislite da vaš rad zaista vredi, jako ste se iznenadili kad je pristao. Ali, kontate, tamo stručnjaci skupi, vi kvalitetni i pouzdani, nema razloga da vas grize savest. Lako ste se navikli na “zapadnu platu” u Srbiji. Ali pomalo vam je glupo kad vidite da se ovde ljudi prodaju za sitne pare, samo obaraju cenu u branši. Ko vam garantuje da sutra vaš strani partner neće uzeti baš nekog od njih za duplo manje nego što mu vi fakturišete. Zato neka, 50k€ i nije neka cifra za švajsovani Džumla templejt, kad malo bolje razmislite.
Nikako vam nije jasno kako vaš ortak sastavi sajt za nedelju dana. Vi malo natucate Fotošop, nešto uspete u Drimviveru da nakrpite, PHP razumete kad je lepo napisan. Ej, nije to laka stvar napraviti sajt. Ljudi uče to programiranje po 10 godina, te fakulteti, te sertifikati… Treba imati rispekt za taj uložen rad (i novac). Te uložene pare i to uloženo vreme moraju se u jednom trenutku isplatiti… Džaba se vi danas mučite da učite, jedno po jedno, ako sutra to neko neće znati da ceni i plati.
Stalo vam je da ortacima iz srednje koji su vas stalno zajebavali pokažete da ste postali neko i nešto. Hoćete da vas cene, da vas cice gledaju sa poštovanjem, da možete da smuvate i neku “pravu ribu” a ne samo bubuljičave wannabe sponzoruše i debele metalke. Da skinete najzad te starke, godine prolaze, nema više zezanja, dosta furanja nerd-imidža, treba se skinuti matorima s gajbe, kupiti neki pristojan auto. A šta je 50k€, potroši se začas. A cilj opravdava sredstvo.
Većina sa Tvitera tako misli a vi ne želite da se konfrontirate. :)
Redovno koristim Limundo i, iako je u pitanju sasvim funkcionalan sajt sa sada već vrlo velikim komjunitijem, ima par stvari koje čine da Limundo i dalje odaje utisak nedovršenog i poluamaterskog proizvoda. U pitanju su sitnice koje bi bilo lako ispraviti, a znače puno:
Ne želim da moram da se logujem uvek kad pristupam sajtu. Ni GMail ne zahteva logovanje pri svakom pristupu. Umesto toga, treba omogućiti dva nivoa pristupa: prvi nivo sa trajnom sesijom za “soft” pristup sajtu - posmatranje svojih i tuđih aukcija, čitanje pošte, i drugi nivo, sa dodatnim logovanjem i kratkotrajnom sesijom - za postavljanje aukcija, bidovanje itd. Ovaj sistem koriste i GMail i Amazon, recimo.
Ako mi Limundo pošalje email (npr, kada primim novu poruku), želim da se klikom na link u mejlu automatski prijavim u prvi security nivo na Limundu, bez potrebe da kucam svoj username i password ponovo. Sama činjenica da imam pristup svom mejlu znači da imam pristup i svom Limundo nalogu.
Popularni “fazon” na Limundu je bidovanje u poslednjim sekundama aukcije. Na ovaj način kupci se dovode u neravnopravnu situaciju (od aukcije pravi se igra na sreću), a predmet prodaje ne uspe da dostigne punu vrednost, tako da je i prodavac, a posredno i Limundo s obzirom da radi na procenat, oštećen.
Aukcija treba da se automatski produži za par minuta, ako je ponuda postavljena u poslednjim minutima (tako npr. funkcionišu neki onlajn sportski menadžeri tipa hattrick.org). Na taj način predmet će prirodno dostići svoju tržišnu cenu a niko od kupaca neće se osećati frustrirano ako je bio spreman da ponudi višu cenu od ostalih.
Trenutno bilo ko ko zna moju email adresu može da promeni moju šifru. To nije ok. Umesto ovog, u mejlu koji dobijem kad kliknem “zaboravio sam šifru”, treba da stoji jedinstveni link kojim potvrđujem izmenu šifre, tj. šifra treba da se promeni tek kad ja, vlasnik email naloga, odradim svesnu akciju. U suprotnom, šifra treba da ostane ista kao ranije.
I was curious about the new UI included in latest Ubuntu release called Unity so I decided to give it a shot. I haven’t reinstalled my main working machine (10.10 still working there), but I took 10-20 GB off MacbookPro’s hard drive to install it there.
Installation went smoothly, Ubuntu even recognized the MacOS on the other partition and offered whether it should replace it (boy that was tempting!) or install alongside with it. Upon installation, everything went well, I got Unity right off, it is in fact written as a Compiz plugin, so, you got Compiz, you can have Unity and vice versa, no Compiz (say, no adequate graphic card or adequate driver), no Unity.
I had some problems installing Broadcom Wifi drivers, had to experiment and google a bit, but eventually it started working.
After the install, I just removed couple of applications I don’t use (everything using Mono, for example, Gwibber, Empathy, Shotwell etd), and installed couple I use (Kupfer, Pidgin, gThumb, Exaile). Natty occupies some 280 MB in memory upon boot. Seems rather modest to me.
Now about Unity, as it’s the biggest change new Ubuntu brings.
It may look intimidating to the users used to traditional Gnome interface. Top panel, although similar, is not your old Gnome panel. Right-clicking doesn’t work. Icons on the right are not panel applets, but indicators (not the same). So you might feel frustrated by expecting for it to behave the way you used to.
On the left, you’ll see the launcher. If you used Mac OS or Windows 7, you’ll know what you have, same icons reused both for favourite applications you would like to be able to launch easily, and for currently running applications. I always liked that on Mac, I like it here as well. The only thing that annoyed me on Mac seems to be solved here: if you have more than one window opened for an application, you don’t see it on Mac, and if you want to pick one from them, you need to press and hold the icon until a (text) menu appears. In Unity you 1) have one small arrow on the left of the icon per every window opened, and 2) another click on the icon shows the thumbnails of the opened windows in that app, and you can pick one easily. The launcher hides automatically if some of your windows covers it, or if you maximize any window.
There’s a nice feature in the launcher: each icon is assigned a keyboard shortcut - Super+1 for the first icon on the top, Super-2 for the second etc. If you have couple of icons fixed there (say, for a file manager, terminal, browser and a chat application, you can switch between them really quickly, lot faster and more accurate than using Alt-Tab (which, of course, still works). There is also Super-W, which displays thumbnails of all open windows, and couple of other shortcuts.
Application menus are moved away from application windows, to the top panel. Again, MacOS users will feel at home here. Very sane decision, to save space by not displaying menubars of inactive windows.
Maximized windows are really maximized. All you will see is the top panel. No window bar - close, minimize and maximize buttons and window title are, again, moved to the top bar.
Dash is something like Gnome menu replacement - you get it when you either click top left ubuntu button, or tap Super key once. It’s convenient for searching and launching applications and documents. You might find it useful if you are a power user, but I guess some inexperienced users would expect to see all installed applications which they would browse at a single place. I, personally, prefer Unity’s type-and-search approach, but it’s inferior to existing applications dedicated to it, and here I must praise Kupfer again, a brilliant application for power users (I believe Quicksilver is the original application for Mac). I would really like to see integration of Kupfer and Unity as it could easily serve as the “engine” which powers dash search.
The biggest problem I see with Unity is the fact that it relies and requires video acceleration. Combine that with the fact that often you can’t rely on graphic drivers to exist or work on your specific hardware, you can’t guarantee that Unity will work on any hardware around.
Also, there are some aesthetic annoyances, unaligned buttons and images here and there, it just feels a little unpolished.
There is no centralized place for customizing look and feel. You can’t add, remove and rearrange app indicators as you could gnome’s panel applets. Right click is often unused.
After couple of days of active Unity usage I really don’t feel restrained in any way by it, and I believe I will continue using it on my primary machine. Also, I believe it will improve in time, both in terms of aesthetics, features and customization. But generally, as a power user, I find it more friendly than the old Gnome.
ccsm (CompizConfig Settings Manager), you’ll be able to tweak some Unity’s features there.
MTS prepaid brojevi (Zvezda/Partizan) imaju problem sa primanjem SMS poruka. Danas sam bio u korisničkom servisu i ni službenik nije uspeo da primi SMS poruku na novi prepaid broj (kartica je ispravno aktivirana i prima i šalje glasovne pozive).
Vidim po internetu da nisam jedini sa istim problemom.
Just recently, a fellow coder wrote the following tweet:
you know what function #php is missing? preg_file_get_contents - get only the content part which matches the pattern
I’m not usually reacting to such appeals, but I felt this is very suitable to try to explain what’s so deeply wrong about PHP, and not as much with PHP but with the whole attitude in communities around certain platforms. I said that that statement is wrong on so many levels, so here I’ll try to address some of them.
language == functionThis is so symptomatic in PHP - identifying the language with the function set provided with it. That tells helluva lot about the language (or, rather, the lack of one). Hey, I thought languages are there to allow you, the programmer, to actually create the functions you need.
Instead of having few very poweful functions which you can combine to achieve your goal, you rely on myriad of tiny, ultra-specialized functions crafted to perform a single specific task. You need function to get lines from a file that match a pattern? All you really need is:
select items from an iterator based on a given criteriaSomething like this (Ruby, but any decent modern language has something similar):
File.foreach('pi.c').select{|line| line =~ /print/}
# ^ ^ ^ ...which match the given regex
# | | ...select only those lines...
# | iterating through every line of a file...
See? Not even worth putting in a separate method.
Waiting for the language creators (or, in extreme cases, a comitee) to accept something which would make your life easier is frustrating, time-wasting and plainly insulting. Such gods should be overthrown, caught and imprisoned. Good gods just should give us the basic tools, a hammer and a chisel, and we’ll make the rest ourselves.
Here’s a regular expression you can use if you want to parse a user’s search query, along with some Ruby to put the result into neat Hash. The query supports prefixing with plus or minus, adding string prefix (a la Google’s site:www.site.com) and quoting whole phrase for exact matching:
def parse_query s
s.scan(/((\S+)\:\s?)?([+-])?(("(.+?)")|(\S+))/).map{|match|
Hash[
[nil, :prefix, :plusminus, nil, nil, :phrase, :word].zip(match).select(&:all?)
]
}
end
so that:
parse_query 'foo +bar -baz "dev pro talk" site:devprotalk.com category:cat1'
returns:
[
{:word=>"foo"},
{:plusminus=>"+", :word=>"bar"},
{:plusminus=>"-", :word=>"baz"},
{:phrase=>"dev pro talk"},
{:prefix=>"site", :word=>"devprotalk.com"},
{:prefix=>"category", :word=>"cat1"}
]