November 2011
1 post
4 tags
gnome-panel is dead, long live gnome-panel! →
TL;DR: You can reorganize your gnome panel by using Alt when right-clicking. Whew.
Nov 17th
2 notes
September 2011
3 posts
Solving delay when ssh-ing →
Sep 22nd
4 tags
Matching successive records using self-join
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...
Sep 12th
14 notes
4 tags
Publish photos from GMail to Picasa
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...
Sep 11th
4 notes
June 2011
2 posts
3 tags
7 krugova pakla
(ili “7 razloga za pravdanje krađe para od poreskih obveznika preplaćivanjem državnih sajtova”) 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… 7. Primate platu od...
Jun 23rd
2 notes
4 tags
Limundo, sitnice koje smetaju
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: Two-level security Ne želim da moram da se logujem uvek kad pristupam sajtu. Ni GMail ne zahteva logovanje pri svakom...
Jun 15th
9 notes
May 2011
1 post
5 tags
First Natty and Unity impressions
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...
May 4th
4 notes
April 2011
5 posts
4 tags
Upozorenje za Zvezda/Partizan mts prepaid pakete
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.
Apr 28th
7 notes
2 tags
Appeasing programming language gods
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...
Apr 27th
1 note
3 tags
Parsing search query in Ruby
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[ ...
Apr 27th
1 tag
Reverse a string using regexps
I know you have always wondered how would one reverse a string without using loops or any kind of iteration, using, say, regular expressions and recursion. So stop wondering you: class String def r_revert sub(/(.+)(.)/){$2 + $1.r_revert} end end 'jablan'.r_revert #=> 'nalbaj' or, if you prefer recursive lambdas instead of monkey-patching: l = ->(s){s.sub(/(.+)(.)/){$2 +...
Apr 23rd
tačka zvezda: Šta ćemo i kako ćemo →
omegawm: Preporučiću vam jednu izvanrednu knjigu o radu, stvaranju, zdravom razmišljanju i dobrim i lošim navikama. Napisana je narodski, jasno i koncizno, 1908. godine. Mislim da je dovoljno pročitati predgovor ovde. Pored opštih lekcija o vrednoći, štednji i urednom životu, autor recimo…
Apr 17th
9 notes
March 2011
3 posts
4 tags
Get first and last line from a file
I needed to get only first and last line from a file (actually, not a file, but rather output from another command). head -1 and tail -1 can be used to get either first or last, but how to combine the two at the same time? Here’s how. Enter tee: cat somefile | grep something | tee >(head -1) >(tail -1) > /dev/null Neat, huh?
Mar 29th
5 notes
5 tags
Random Mac/OSX PITA list
Ok, here’s my entirely private, subjective, random list of Pains In The Ass that I experienced while I was trying to get used to using OSX on a Macbook. While I spent years working in Windows as well, I mostly tend to compare experiences with Linux, allegedly notorious for its desktop (un)friendlyness. The list is unordered, some things bothering more, some less. No way of changing the...
Mar 23rd
2 notes
4 tags
Clojure's interpose and interleave in Ruby
These days I’m reading a great book titled “Seven Languages in Seven Weeks” by Bruce Tate, currently I’m on Clojure, and I am really surprised how easy it is to follow, knowing Ruby beforehand. In chapter on lazy evaluation, I noticed couple of methods that didn’t have their exact counterparts in Ruby, and I was curious how hard would it be to implement them. So,...
Mar 3rd
February 2011
1 post
Zašto je PHP bolji od Rubija
[Prevod članka Alija Nadžafa, britanskog programera. Original je ovde: Why PHP is better than Ruby] 21.2.2011. PHP je bolji od Rubija. Eto, rekao sam. U ovom članku ću vam objasniti zbog čega, i usput verovatno iznervirati neke hipi fanove od dvadeset i kusur sa japankama i Mekovima. U Rubiju sve je objekat… čak i literali! Ovo je prosto bolesno. Ne znam kako Rubi developeri mogu da...
Feb 24th
December 2010
4 posts
5 tags
Acer Aspire One D255 review
I needed a cheap netbook to replace my old 7-inch Asus eeePc, already semi-broken, part of its display permanently dead, some keys not working anymore, others pulled out. It is our kitchen computer, used by wife and kid, and main criteria was to be as cheap as possible, so I wouldn’t have to despair if it gets its keys extruded, or milk spilled over. Asus Aspire One D255 (single-core Atom)...
Dec 30th
3 tags
Imate novi pasoš, a treba vam nova lična
Pre mesec-dva sam postavio pitanje na ES-u u vezi vađenja nove lične: interesovalo me je šta treba od dokumenata, pod uslovom da sam već vadio novi (biometrijski, crveni) pasoš. Evo da odgovorim sam sebi: državljanstvo nije potrebno. Izvod iz matične knjige nije potreban, pod uslovom da ste prilikom vađenja pasoša prilagali novi, trajni izvod (roze boje). Ako ste pasoš vadili pomoću starog,...
Dec 29th
4 tags
StackOverflow-style syntax highlight on Tumblr
There are several articles on how to enable (client-based) syntax highlighting on Tumblr. None of these solutions worked for me, as each requires setting class on pre or code tags manually for coloring JS snippet to recognize areas to colorize. This is not simple in my case, as I am using Markdown as markup language, and generating HTML tags (and their attributes, such as class) is out of control...
Dec 11th
4 tags
"Each with previous" in Ruby
I often need a variant of Enumerable#each method, with a “twist”: sometimes I want to have previous element available along with the current one, most often for comparison between the two. Here’s a trivial example: array = [ {name: 'foo', value: 15}, {name: 'foo', value: 6}, {name: 'bar', value: 2}, {name: 'bar', value: 7}, {name: 'bar', value: 14}, {name: 'baz',...
Dec 11th
1 note
November 2010
39 posts
3 tags
Zašto se PHP smatra tamnom stranom programiranja
U pitanju nije moj tekst, već moj prevod, original možete naći ovde. Preveo sam ga jer dobro formuliše moj lični stav o PHP-u. PHP ima puno problema. Većina ima istorijske korene ali, u krajnjoj liniji, oni su razlog što ga dosta programera smatra užasnim jezikom. <?php i ?> “tagovi” i sva njihova rodbina Oni uglavnom potiču od rane prirode PHP-a kao templejt jezika. Iako...
Nov 29th
Swapping array elements using parallel assignment →
Intrigued by this question, I have played a bit with parallel assignment with arrays and method calls. So here’s an paradigmatic example, trying to swap two members in an array, by their value:
Nov 15th
Comment by Mladen Jablanović on Swapping array... →
Got it now, thanks!
Nov 15th
Comment by Mladen Jablanović on Swapping in Ruby →
Can you clarify this part: “In your code, however, the comma is part of the method call to deck.[]. The assignment comes after the method is executed, in a context where there are no commas.” Thx
Nov 15th
Comment by Mladen Jablanović on Ruby Hash... →
If you often do this kind of juggling, you might find easier to use Sqlite.
Nov 15th
Comment by Mladen Jablanović on Working with... →
What operations would you perform on the graph, i.e. what you would like Rails (or whichever plugin) to provide you with?
Nov 13th
Answer by Mladen Jablanović for In Ruby, 12.months... →
Yes and no: 12 months are the same as 1 year when you use them as relative intervals, because they are not converted to seconds then: t = Time.now #=> 2010-11-12 22:34:57 0100 t - 1.year == t -...
Nov 12th
Answer by Mladen Jablanović for Saving XML files... →
Perhaps something like: s = render_to_string :file => 'layouts/question.xml' File.open('fixed.xml','w'){|f| f.write s} render :text => s
Nov 12th
Answer by Mladen Jablanović for Ruby Hash... →
If you prefer inject, you can write it as h.inject({}){|a,(k,v)| v.inject(a){|a1,(k1,v1)| a1[k1] ||= {} a1[k1][k] = v1 a1 } a }
Nov 12th
Comment by Mladen Jablanović on How can I run a... →
Functions are not the same thing as methods. Ruby deals with methods, and methods always belong to some object. So I think you should rethink what you really want to invoke, and, most importantly, on…
Nov 11th
RT @vip_mobile: Smatramo da građani treba da dobiju priznanje za dobro delo!Zato našim korisnicima vraćamo 14 din uplaćenih na ime porez …
Nov 11th
Ako ste #linux korisnik, probajte #kupfer http://kaizer.se/wiki/kupfer/ Alt-Tab me oduvek nervira, sad ga možda najzad i ukinem.
Nov 10th
Answer by Mladen Jablanović for Preferred keyboard... →
I have, throughout time, learned both US and my native language (Serbian) layouts and use them alternately. I mapped CapsLock as a key to change the layout, and OS remembers which one is active in…
Nov 10th
Answer by Mladen Jablanović for How can I update... →
Your question is not clear enough. Which class are you talking about? What kind of YAML documents? You can’t have everything serialized to and from YAML. Let’s assume that your object just has a…
Nov 10th
Answer by Mladen Jablanović for In Ruby, is there... →
If you need something that would really prompt user during the execution of the script, you can wrap the methods you need to prompt about: module Confirmable def confirm_first *methods...
Nov 10th
Comment by Mladen Jablanović on How to elegantly... →
possible duplicate of How to change all the keys of a hash by a new set of given keys ? (Turns out I upvoted Jorg’s answer twice!) ;)
Nov 9th
Comment by Mladen Jablanović on How to elegantly... →
Just use mappings[k] || k instead of mappings[k] above and it will leave keys not in the mapping as is.
Nov 9th
Answer by Mladen Jablanović for How to generate a... →
If you need something more “precise” than distance_of_time_in_words, you can write something along these lines: def humanize secs [[60, :seconds], [60, :minutes], [24, :hours], [1000,...
Nov 9th
Answer by Mladen Jablanović for Handle... →
First you should separate the text column in at least two, so that the table looks like: (user_id, action, is_permitted) or, even, (user_id, action_id, is_permitted) Another possible…
Nov 9th
Answer by Mladen Jablanović for How to convert an... →
No, your solution seems completely ok. You can only omit the parentheses before join.
Nov 9th
Comment by Mladen Jablanović on How do I use this... →
Are you executing /lib/date_time.rb at all?
Nov 9th
Comment by Mladen Jablanović on web crawler in... →
Better in which way?
Nov 9th
Za 400€ mogu da pazarim novi laptop, instaliram Ubuntu, Netbeans i Rails i zaradim brdo para. #sinergija #fail
Nov 8th
Kako MS planira da privuče developere ako je kotizacija za #sinergija jbnh 400eur?!
Nov 8th
Comment by Mladen Jablanović on Timezone Select... →
I don’t think all_linked_zones is the right one to use, it gives just a small number of places. You should use one of the other methods. Note, however, that you will have LOTS of items, unless you…
Nov 7th
RT @newsycombinator: Polish Developers Are Joining U.S. Startups But Staying In Poland http://j.mp/9ble46
Nov 7th
Answer by Mladen Jablanović for When is File.join... →
There is another, subtle difference: File.join('foo','bar') #=> "foo/bar" ['foo','bar'].join('/') #=> "foo/bar" But, if you pass an argument already ending with / (which is quite often when…
Nov 6th
Jutros menjam kanale i vidim špansku seriju: tetka telefonira, zum na mobilni, ono Android. :)
Nov 5th
Comment by Mladen Jablanović on Theory of Object... →
Out of curiosity, what’s the motiv for your interest? Academic project or do you think it can have some commercial value? Thx.
Nov 4th
Comment by Mladen Jablanović on Classify a Ruby... →
You may find it easiest to get and use ActiveSupport.
Nov 3rd