<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-641775512404432043</id><updated>2012-02-03T01:23:05.680-08:00</updated><category term='samba password problem ubuntu'/><category term='introduction'/><category term='newbie'/><title type='text'>Psylarium</title><subtitle type='html'>Random ramblings, science tutorials, python programming, my music tastes, this blog is a bag of mixed nuts.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://psylarium.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/641775512404432043/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://psylarium.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Psylarium</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://4.bp.blogspot.com/__EdzLGBTPjY/S0L1RaoGewI/AAAAAAAAAAM/nRz68Gseru8/S220/psylarium.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>10</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-641775512404432043.post-4158810610679622496</id><published>2011-06-14T18:06:00.000-07:00</published><updated>2011-06-14T18:06:18.752-07:00</updated><title type='text'>The maze of finding a good VPS hosting for Drupal and other CMS</title><content type='html'>I went through the maze of finding a good VPS hosting for a relatively database heavy website (typically any CMS will be in that category, Drupal, Joomla, Plone, Ruby on rails, etc...). So I thought I would write up how the experience, the traps and the final solution I found.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Shared hosting, VPS or dedicated ?&lt;/b&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;b&gt;Shared hosting&lt;/b&gt;&amp;nbsp;is typically the cheapest alternative, advertised with those super cheap prices (like less than $5 a month). However in practice, unless you just host a few raw HTML pages, your site is going to crawl if you use a MySQL database. If it crawls, most often hosting companies while claiming unlimited this and that will just turn off your website, I've experienced it, many others did.&lt;/li&gt;&lt;li&gt;&lt;b&gt;VPS hosting &lt;/b&gt;was recommended to me by my initial hosting company (InMotionHosting) after they unilaterally turned off my website without even notifying me (not to mention I was mad). Their argument was I was using too much resources, time to move to Virtual Private Hosting, which basically is a shared hosting with a fixed amount of resources allocated to you. Now the price varies between $20 to $40 a month for the entry plans between companies.&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Watch out: there are two types of VPS hosting: &lt;b&gt;managed&lt;/b&gt; and &lt;b&gt;unmanaged&lt;/b&gt;, I'll explain more about them later.&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;&lt;b&gt;Dedicated hosting&lt;/b&gt; is when you have a full server at your disposal, it will often cost you more than $100 for a entry plan.&lt;/li&gt;&lt;/ol&gt;So in my situation, I decided that VPS was probably right for me, I don't have a 100.000 connexions a day but at the same time the website is growing and I need a MySQL that responds relatively fast.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;What hosting company ?&lt;/b&gt;&lt;br /&gt;Now, if you're like me you type "Best VPS hosting" in Google, and you get tons of results that look faked. And they are (faked), many hosting companies pay people in India to post positive reviews about them, that's called backlinking. So they all can claims they are the best. Now in practice, it's far from the truth. Actually a funny event happend, someone posted in my phpBB forums a spam back link for my own hosting company (InMotionHosting), how stupid is that ?&lt;br /&gt;&lt;br /&gt;But at first, I fell for the trick and initially signed up for a hosting based on those faked review, the speed was abysmal but I thought naively that it was normal.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.inmotionhosting.com/"&gt;&lt;b&gt;InMotionHosting&lt;/b&gt;&lt;/a&gt;:&amp;nbsp; Then I moved on to another "best hosting", InMotionHosting which basically may be good for shared with basic HTML pages but with Drupal pretty much forced me to go to a VPS. Once on a VPS the performance improved but remained poor, the loading time for the front page on average took 2 seconds and sometimes it would take as much as 60 seconds to load. The customer support could never reproduce the issue (forget about user support for anything that doesn't happend all the time, like an intermittent huge loading time) and they didn't even try. They could have written a script in 5 minutes to load the front page every 10 minutes to measure the load time, they didn't.&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.hostgator.com/"&gt;&lt;b&gt;HostGator&lt;/b&gt;&lt;/a&gt;: So I decided to finally give a try to the next big name, hostgator. They may be good at shared hosting but while their VPS was faster than InMotionHosting, it still remained slow. Page loading, would take 2 to 8 seconds for my front page. Their VPS comes with CentOs 5.6 and all packages feel obsolete (python 2.4.3, etc... they offer python 2.7 but only for shared hosting...). Their live customer support would deserve an entire blog post to tell the horror stories that have happened to me. Their SQL response time was slow as hell (same config as at my home, the queries took 3 time longer to execute).&lt;/li&gt;&lt;/ul&gt;These companies are reputed as shared hosters but the VPS value remains low. Their VPS are managed (or semi-managed) which basically means that you get an often incompetent user support to spend hours chatting online. But it's reassuring, someone is helping you even if it's of no help, they provide a chat log so you can show your boss it's not your fault that nothing is working. Yes reassuring.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;The world of unmanaged VPS&lt;/b&gt;&lt;br /&gt;Here basically you're on your own, you get the server, and you need to install everything without a user support holding your hand. And that's what I finally tried with &lt;a href="http://www.linode.com/"&gt;&lt;b&gt;Linode&lt;/b&gt;&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;I chose to use the Ubuntu 10.04 Linux VPS (it's a cloud server, but VPS and cloud are pretty much the same thing, just that clouds allows cloning). Installation is simple, you get a SSH shell, you install Apache and whatever you need, it's as simple as apt-get. The packages are up-to-date (being Ubuntu) so you don't really have to compile anything.&lt;br /&gt;&lt;br /&gt;In 1 hour, I had the whole site setup and working. The performance is excellent, loading the frontpage takes 250ms. The cost is &lt;b&gt;half &lt;/b&gt;of what I was paying with InMotionHosting and HostGator.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Final word&lt;/b&gt;&lt;br /&gt;My point here is not to make a commercial for Linode but to relate my experience through years of hosting quest. There are probably others who are offering a good VPS hosting, however I didn't use them so I'm not going to comment on them.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;The lesson that I learned:&lt;/u&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Stay away from big shared hosting companies if you want VPS hosting&lt;/li&gt;&lt;li&gt;Go for an unmanaged VPS hosting company, the performance is incomparable, they offer a lot of documents to help you configure your server and you can always find help by going to IRC and chat.&lt;/li&gt;&lt;/ul&gt;&lt;b&gt;Performance comparison of my page load times&lt;/b&gt;&lt;br /&gt;Those times where measured using Firefox:FireBug-&amp;gt;Net load time analyzer.&lt;br /&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt; &lt;th&gt;Company&lt;/th&gt; &lt;th&gt;Average load time&lt;/th&gt; &lt;th&gt;Worst load time&lt;/th&gt; &lt;/tr&gt;&lt;tr&gt; &lt;td&gt;&lt;a href="http://www.inmotionhosting.com/"&gt;InMotionHosting&lt;/a&gt;&lt;/td&gt; &lt;td&gt;1-2s&lt;/td&gt; &lt;td&gt;60s&lt;/td&gt; &lt;/tr&gt;&lt;tr&gt; &lt;td&gt;&lt;a href="http://www.hostgator.com/"&gt;HostGator&lt;/a&gt;&lt;/td&gt; &lt;td&gt;1-2s&lt;/td&gt; &lt;td&gt;8s&lt;/td&gt; &lt;/tr&gt;&lt;tr&gt; &lt;td&gt;&lt;a href="http://www.linode.com/"&gt;Linode&lt;/a&gt;&lt;/td&gt; &lt;td&gt;0.25s&lt;/td&gt; &lt;td&gt;0.5s&lt;/td&gt; &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/641775512404432043-4158810610679622496?l=psylarium.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://psylarium.blogspot.com/feeds/4158810610679622496/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://psylarium.blogspot.com/2011/06/maze-of-finding-good-vps-hosting-for.html#comment-form' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/641775512404432043/posts/default/4158810610679622496'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/641775512404432043/posts/default/4158810610679622496'/><link rel='alternate' type='text/html' href='http://psylarium.blogspot.com/2011/06/maze-of-finding-good-vps-hosting-for.html' title='The maze of finding a good VPS hosting for Drupal and other CMS'/><author><name>Psylarium</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://4.bp.blogspot.com/__EdzLGBTPjY/S0L1RaoGewI/AAAAAAAAAAM/nRz68Gseru8/S220/psylarium.jpg'/></author><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-641775512404432043.post-4683886923455666905</id><published>2011-04-21T08:15:00.000-07:00</published><updated>2011-04-21T08:19:33.429-07:00</updated><title type='text'>Portal 2, an honest review</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-kVZXb3hoiWI/TbBK2Yk6l_I/AAAAAAAAABU/ObneuWBlHZE/s1600/portal_2_logo_square-1.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/-kVZXb3hoiWI/TbBK2Yk6l_I/AAAAAAAAABU/ObneuWBlHZE/s1600/portal_2_logo_square-1.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;I don't generally write about games but this time I felt I had to. Because most articles one finds on internet are totally biased and sound more like sponsored infomercials than real objective reviews, and since I don't work for Valve, here's an example of such BS: &lt;a href="http://www.rockpapershotgun.com/2011/04/19/review-portal-2/"&gt;http://www.rockpapershotgun.com/2011/04/19/review-portal-2/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;The good&lt;/b&gt;&lt;br /&gt;Technically the game looks good and is fun to play, you really get a sense of achievement when solving some of the harder problems, however none are really that hard. I guess if you played Portal 1, you will find it easier because you're already used to the portal way of thinking.&lt;br /&gt;&lt;br /&gt;They have added some new type of technological stuff, like some light bridges, fields and gels which give you more possibilities, however these are not really big game changers. They add variety and it's cool but they never really get used in combination to make you think out of the box. Typically, you just get to deal with 1 or 2 elements at a time, so it's a bit of a let down, they could have pushed the difficulty a bit more.&lt;br /&gt;&lt;br /&gt;There are some really nice sound tracks in game, like in other Valve games the music artist(s) deliver super&amp;nbsp; catchy tunes. With one exception the end-track, read below.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;The bad&lt;/b&gt;&lt;br /&gt;Slightly disappointing, even though I didn't rush, it only took me 6 hours to complete the single player game. For a $50 game, that felt like being shortchanged, I would have hoped for two to three times that playtime for that price. But that's a general trend in gaming industry, you get less for your money every year.&lt;br /&gt;&lt;br /&gt;The story feels weak and predictable compared to Portal 1, but well there's a simple story at least. But I wish it would be a bit more surprising.&lt;br /&gt;&lt;br /&gt;The humor felt forced and bitter, to me it felt like the team who did this tried too hard to be funny and ended up failing. In other words, it felt like a job, a mechanical forced way to pack jokes assembled by a group self-centered story-specialist sipping coffee for hours in meetings (anyone who ever worked in a software company will get the picture). In contrast, the humor in portal 1 came progressively and was extremely funny (may be it was the work of smaller team).&lt;br /&gt;&lt;br /&gt;&lt;b&gt;The ugly&lt;/b&gt;&lt;br /&gt;Ok, the first part with the hyper active "ADSD (Attention Deficit Syndrome)" computer core (that round thingy that keeps on talking stupidly with an english accent) is verging on being obnoxious. This part is so lame and feels so forced, it almost made me close the game or at least to play it without sound. Fortunately this only last for 30% of the game, after that things settle down. To put an image it feels like those Walt Disney 3D animations where the characters are over-scenarized and keep talking.&lt;br /&gt;&lt;br /&gt;The ending song, I realize they tried to do a superb song like for Portal 1 (which was so catchy and addictive and fitted the story so well) but let's be honest, they failed miserably. To their defense, it's hard to do a hit song on-demand, even rock stars can't do that. So I don't want to be overly harsh on them, just honest.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/641775512404432043-4683886923455666905?l=psylarium.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://psylarium.blogspot.com/feeds/4683886923455666905/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://psylarium.blogspot.com/2011/04/portal-2-honest-review.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/641775512404432043/posts/default/4683886923455666905'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/641775512404432043/posts/default/4683886923455666905'/><link rel='alternate' type='text/html' href='http://psylarium.blogspot.com/2011/04/portal-2-honest-review.html' title='Portal 2, an honest review'/><author><name>Psylarium</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://4.bp.blogspot.com/__EdzLGBTPjY/S0L1RaoGewI/AAAAAAAAAAM/nRz68Gseru8/S220/psylarium.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-kVZXb3hoiWI/TbBK2Yk6l_I/AAAAAAAAABU/ObneuWBlHZE/s72-c/portal_2_logo_square-1.jpg' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-641775512404432043.post-3940523405056848999</id><published>2010-12-18T00:03:00.000-08:00</published><updated>2010-12-18T00:14:18.135-08:00</updated><title type='text'>Combining views and path aliases in Drupal 6</title><content type='html'>Ok after a long time off, I finally have something worth to say. First I must thank &lt;b&gt;styol &lt;/b&gt;from #drupal IRC channel for pointing me to the solution and to &lt;b&gt;phrancescot &lt;/b&gt;for his persistent help. I decided to write it up for other people struggling like me.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;What I was trying to achieve&lt;/b&gt;&lt;br /&gt;Basically I wanted to add a Tab for a content type song that pointed to a view to report all the reviews for that song, all that using nice auto-aliased urls.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;The context&lt;/b&gt;&lt;br /&gt;&lt;u&gt;The song content type&lt;/u&gt;&lt;br /&gt;I have a song content type, it has the usual Title and Body fields plus a field called duration.&lt;br /&gt;Each song content type is auto aliased using the pathauto module. The automatic alias is &lt;b&gt;song/[title-raw]&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;u&gt;The review content type&lt;/u&gt;&lt;br /&gt;I have a content type review which basically has the usual Title and Body fields plus a nodereference field called song.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;The view to list the reviews for a song&lt;/u&gt;&lt;br /&gt;Here I won't go into the SQL query details, it's just standard view work. The important thing here is that in Views-&amp;gt;Page there's a &lt;i&gt;Page settings&lt;/i&gt; entry. In it, you have to field to fill: &lt;i&gt;Path &lt;/i&gt;and &lt;i&gt;Menu&lt;/i&gt;.&lt;br /&gt;The path I was using was &lt;b&gt;song/%/reviews&lt;/b&gt;. That was my first mistake, while it works perfectly for the SQL request, the tab was not appearing in the tab menu because of that.&lt;br /&gt;Instead the right solution is to use &lt;b&gt;node/%/reviews&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Well at this point the path is not the beautiful aliased path. However fear not, since that's where the subpath_alias module comes into play. It will rename automatically the node/% to the autopath matching it. There's nothing to do other than installing that module (talk about drupal magic !).&lt;br /&gt;&lt;br /&gt;Now for the menu, simply select Menu Tab and fill the title and description.&amp;nbsp; And voila, the tab will have a new entry, pointing to your aliased URL.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Modules used&lt;/b&gt;&lt;br /&gt;&lt;a href="http://drupal.org/project/cck"&gt;CCK&lt;/a&gt;&lt;br /&gt;&lt;a href="http://drupal.org/project/views"&gt;views&lt;/a&gt;&lt;br /&gt;&lt;a href="http://drupal.org/project/pathauto"&gt;pathauto&lt;/a&gt;&lt;br /&gt;&lt;a href="http://drupal.org/project/subpath_alias"&gt;subpath_alias&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Special thanks&lt;/b&gt;&lt;br /&gt;From the #drupal IRC channel: styol, &lt;span class="hyperlink-whois"&gt;phrancescot for the persistent help !&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/641775512404432043-3940523405056848999?l=psylarium.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://psylarium.blogspot.com/feeds/3940523405056848999/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://psylarium.blogspot.com/2010/12/combining-views-and-path-aliases-in.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/641775512404432043/posts/default/3940523405056848999'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/641775512404432043/posts/default/3940523405056848999'/><link rel='alternate' type='text/html' href='http://psylarium.blogspot.com/2010/12/combining-views-and-path-aliases-in.html' title='Combining views and path aliases in Drupal 6'/><author><name>Psylarium</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://4.bp.blogspot.com/__EdzLGBTPjY/S0L1RaoGewI/AAAAAAAAAAM/nRz68Gseru8/S220/psylarium.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-641775512404432043.post-8319925308979642122</id><published>2010-02-28T00:34:00.000-08:00</published><updated>2010-02-28T00:34:12.720-08:00</updated><title type='text'>Quote of the day</title><content type='html'>I was browsing the excellent blog of &lt;a href="http://segfaultlabs.com/"&gt;SegFaultLabs &lt;/a&gt;and I've found the following quote over there, that's my quote of the day !&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning... (by Rick Cook)&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/641775512404432043-8319925308979642122?l=psylarium.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://psylarium.blogspot.com/feeds/8319925308979642122/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://psylarium.blogspot.com/2010/02/quote-of-day.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/641775512404432043/posts/default/8319925308979642122'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/641775512404432043/posts/default/8319925308979642122'/><link rel='alternate' type='text/html' href='http://psylarium.blogspot.com/2010/02/quote-of-day.html' title='Quote of the day'/><author><name>Psylarium</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://4.bp.blogspot.com/__EdzLGBTPjY/S0L1RaoGewI/AAAAAAAAAAM/nRz68Gseru8/S220/psylarium.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-641775512404432043.post-3684789597997491968</id><published>2010-01-31T10:38:00.000-08:00</published><updated>2010-01-31T10:42:44.302-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='samba password problem ubuntu'/><title type='text'>My samba server was losing/changing passwords !</title><content type='html'>I finally resolved a nagging problem with Samba. I recently installed Ubuntu 9.10 (Karmic Koala), and I was using pretty much the same config file for Samba that I was using with Ubuntu 8.04.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Passwords getting modified automatically ?&lt;/b&gt;&lt;br /&gt;However, there was a problem. After a few hours, it seemed like the Samba passwords were replaced by the UNIX passwords. So I had to reissue a &lt;span style="background-color: #d0e0e3; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;sudo smbpasswd &amp;lt;user&amp;gt;&lt;/span&gt; to set back my password. In my system, I don't use the same password for Samba and Unix. But somehow, the password was getting changed automatically after a few hours.&lt;br /&gt;&lt;br /&gt;Obviously, I already had that option:&lt;br /&gt;&lt;span style="background-color: #d0e0e3; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;unix password sync = no&lt;/span&gt;&lt;br /&gt;But that didn't do anything ! The password was still getting changed to UNIX.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Google is of no help&lt;/b&gt;&lt;br /&gt;I tried Google/Bing searches but there are thousands of questions involving passwords and Samba, and after reading countless search results, nothing really matched by problem. I mean Google is a good search engine if you're looking for something popular since its core algorithm is a kind of popularity contest. But when you're looking for something rare that can only be expressed with common vocabulary, this search engine really shows its limits.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Read The Fucking Manual (RTFM)&lt;/b&gt;&lt;br /&gt;So my last option was to start reading the Samba documentation, which is like reading an encyclopedia. I mean who really reads that enormous document ? What a pain !&lt;br /&gt;But anyway, after a few days of browsing through it I finally figured the issue.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;There's something about &lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;pam_smbpass&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;It was a Samba module named &lt;a href="http://freshmeat.net/projects/pam_smbpass/"&gt;pam_smbpass&lt;/a&gt; that was installed automatically by Ubuntu. This module, every now and then would replace the Samba passwords with the UNIX passwords.&lt;br /&gt;&lt;br /&gt;So I went to synaptic package manager and uninstalled that module. Problem solved.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/641775512404432043-3684789597997491968?l=psylarium.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://psylarium.blogspot.com/feeds/3684789597997491968/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://psylarium.blogspot.com/2010/01/my-samba-server-was-losingchanging.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/641775512404432043/posts/default/3684789597997491968'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/641775512404432043/posts/default/3684789597997491968'/><link rel='alternate' type='text/html' href='http://psylarium.blogspot.com/2010/01/my-samba-server-was-losingchanging.html' title='My samba server was losing/changing passwords !'/><author><name>Psylarium</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://4.bp.blogspot.com/__EdzLGBTPjY/S0L1RaoGewI/AAAAAAAAAAM/nRz68Gseru8/S220/psylarium.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-641775512404432043.post-6487077008850715567</id><published>2010-01-29T01:22:00.000-08:00</published><updated>2010-01-29T01:26:11.387-08:00</updated><title type='text'>External RAID 5 with Ubuntu 9.04 and Gnome notifications</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/__EdzLGBTPjY/S2Kij6nktNI/AAAAAAAAAA8/Mapx7sh_tHw/s1600-h/tr4u.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" height="200" src="http://4.bp.blogspot.com/__EdzLGBTPjY/S2Kij6nktNI/AAAAAAAAAA8/Mapx7sh_tHw/s200/tr4u.jpg" width="129" /&gt;&lt;/a&gt;&lt;/div&gt;Recently I lost a drive after 6 months, and all my data disappeared. That was a &lt;a href="http://www.google.com/products/catalog?q=maxtor+1+touch+2+tb&amp;amp;cid=11938721847775788936&amp;amp;sa=title#p"&gt;Maxtor 1 Touch 1.5 TB&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;So after that disappointment, I decided to get a safer solution. So I wanted to have an external RAID 5 and I found those very nice little towers that go for around $150: &lt;a href="http://www.sansdigital.com/towerraid/index.php"&gt;TowerRaid from Sans Digital&lt;/a&gt;. See the picture on the right to see what it looks like. Basically the front panel opens and you just slide your drives in. Fix them with the side screws and you're done.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;This box also came with an PCIe card that provides 2 eSATA ports, of which only needs to be used to connect to that box.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Preparting the drives for RAID&lt;/b&gt;&lt;br /&gt;I decided not to use the functionality of the card which offers RAID 5 amongst other RAID flavors and simply use Linux software RAID which is a lot more widespread and documented that the chipset on the card. By default, the card was reporting the drives as JBOD (Just a Bunch Of Disks). So I simply started &lt;a href="http://gparted.sourceforge.net/"&gt;gparted&lt;/a&gt; to find the names of the devices (e.g. the drives inserted in the box).&lt;br /&gt;&lt;br /&gt;In my case, I found they were&lt;br /&gt;&lt;div style="background-color: #d0e0e3; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;/dev/sde&lt;/div&gt;&lt;div style="background-color: #d0e0e3; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;/dev/sdf&lt;/div&gt;&lt;div style="background-color: #d0e0e3; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;/dev/sdg&lt;/div&gt;&lt;div style="background-color: #d0e0e3; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;/dev/sdh&lt;/div&gt;&lt;br /&gt;Ok, the next step was to create partitions on them since they didn't even have a partition table. For each drive,&lt;b&gt; I used fdisk to create a primary partition of type Linux (83)&lt;/b&gt;.&lt;br /&gt;Now I had 4 partitions, one for each drive. They were named /dev/sde1, /dev/sdf1, etc...&lt;br /&gt;&lt;br /&gt;&lt;b&gt;The actual RAID setup&lt;/b&gt;&lt;br /&gt;The RAID configuration couldn't be easier. I simply did.&lt;br /&gt;&lt;div style="background-color: #d0e0e3; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;sudo mdadm --create /dev/md0 -n 4 -l 5 /dev/sde1 /dev/sdf1 /dev/sdg1 /dev/sdh1&lt;/div&gt;&lt;br /&gt;The options are quite simple:&lt;br /&gt;/dev/md0 is the name of device (since it was my only raid array, I set it to md0)&lt;br /&gt;-n 4 because there are 4 drives in the box&lt;br /&gt;-l 5 is for RAID 5&lt;br /&gt;and then you pass the list of partitions.&lt;br /&gt;&lt;br /&gt;And that's all. Isn't it amazingly simple ?&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Creating a file system on the RAID array&lt;/b&gt;&lt;br /&gt;From this point on, you can simply treat /dev/md0 just like any partition. So I decided to create an ext4 file system on it.&lt;br /&gt;&lt;div style="background-color: #d0e0e3; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;sudo mkfs.ext4 /dev/md0&lt;/div&gt;&lt;br /&gt;And that will create the file system.&lt;br /&gt;&lt;br /&gt;Next I mounted it.&lt;br /&gt;&lt;div style="background-color: #d0e0e3; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;sudo mkdir /myraiddisk&lt;/div&gt;&lt;div style="background-color: #d0e0e3; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;sudo mount /dev/md0 /myraiddisk&lt;/div&gt;&lt;br /&gt;And now, I could just save files on my new RAID disk.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Checking everything works !&lt;/b&gt;&lt;br /&gt;It's always safe to check that everything works as expected. There's a simple command to do that.&lt;br /&gt;&lt;div style="background-color: #d0e0e3; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;sudo mdadm -D /dev/md0&lt;/div&gt;&lt;br /&gt;That will report the status of your RAID array. Now for me, at the beginning the RAID array was showing as degraded, rebuilding. I assumed it was organizing the data. After 1 day of work, the status became Active, Clean.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Get a desktop notification on Gnome if a drive fails&lt;/b&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_LSnbJ1KE9uA/SSjhwe3DM3I/AAAAAAAAAF8/st8DDZ3jfRU/s1600/alert.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" height="105" src="http://3.bp.blogspot.com/_LSnbJ1KE9uA/SSjhwe3DM3I/AAAAAAAAAF8/st8DDZ3jfRU/s320/alert.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;The advantage of RAID 5 is that if a drive fails, then you can replace it and the array rebuilds/auto-corrects itself. But, first you need to be aware that a drive failed. For that purpose, there's a &lt;a href="http://tomthegeek.blogspot.com/2008/11/pop-up-notification-of-software-raid.html"&gt;great blog post from TomTheGeek&lt;/a&gt; that explains just how to do that. &lt;br /&gt;The only difference I found in Ubuntu 9.04 was that the notify-send command &lt;u&gt;was not in&lt;/u&gt; notification-deamon package, it was in libnotify-bin.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/641775512404432043-6487077008850715567?l=psylarium.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://psylarium.blogspot.com/feeds/6487077008850715567/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://psylarium.blogspot.com/2010/01/external-raid-5-with-ubuntu-904-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/641775512404432043/posts/default/6487077008850715567'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/641775512404432043/posts/default/6487077008850715567'/><link rel='alternate' type='text/html' href='http://psylarium.blogspot.com/2010/01/external-raid-5-with-ubuntu-904-and.html' title='External RAID 5 with Ubuntu 9.04 and Gnome notifications'/><author><name>Psylarium</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://4.bp.blogspot.com/__EdzLGBTPjY/S0L1RaoGewI/AAAAAAAAAAM/nRz68Gseru8/S220/psylarium.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/__EdzLGBTPjY/S2Kij6nktNI/AAAAAAAAAA8/Mapx7sh_tHw/s72-c/tr4u.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-641775512404432043.post-2901085744224253232</id><published>2010-01-09T10:45:00.000-08:00</published><updated>2010-01-12T13:00:16.097-08:00</updated><title type='text'>Fast computation of prime numbers in Python</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Prime Numbers&lt;/span&gt;&lt;br /&gt;Before I present the Python code, let's quickly introduce &lt;a href="http://en.wikipedia.org/wiki/Prime_number"&gt;prime numbers&lt;/a&gt;. A prime number is a number than can only be divided by itself and 1. For example:&lt;a style="" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://upload.wikimedia.org/wikipedia/commons/a/a2/Portrait_of_Eratosthenes.png"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer; width: 185px; height: 184px;" src="http://upload.wikimedia.org/wikipedia/commons/a/a2/Portrait_of_Eratosthenes.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;ul&gt;&lt;li&gt;7 is a prime number since it can only by divided by either 1 and 7&lt;/li&gt;&lt;li&gt;6 is not a prime number since it can divided by 1,2,3,6&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;The Greeks&lt;/span&gt;&lt;br /&gt;Now, let's pay tribute to the Greeks, and for this occasion, one in particular: &lt;a href="http://en.wikipedia.org/wiki/Eratosthenes"&gt;Eratosthenes (276 BC – c. 195 BC)&lt;/a&gt;. Eratosthenes is famous for &lt;a href="http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes"&gt;its sieve&lt;/a&gt;, which is basically an algorithm to find prime numbers. The idea is very simple for our times but  one has to marvel at the genius of having it more than 2000 years ago. His idea was for each number &lt;span style="font-style: italic;"&gt;n&lt;/span&gt;, mark each number greater than &lt;span style="font-style: italic;"&gt;n&lt;/span&gt; and dividable by &lt;span style="font-style: italic;"&gt;n&lt;/span&gt; to be non-prime. So technically what the algorithm does, is for each number &lt;span style="font-style: italic;"&gt;p&lt;/span&gt; &gt; &lt;span style="font-style: italic;"&gt;n&lt;/span&gt;, find the remainder of &lt;span style="font-style: italic;"&gt;p&lt;/span&gt;/&lt;span style="font-style: italic;"&gt;n&lt;/span&gt;, if the remainder is 0, then &lt;span style="font-style: italic;"&gt;p&lt;/span&gt; is not a prime. Technically rather than testing every number, Eratosthenes sieve marks directly all the products of a given prime number as non-prime.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Python, what else ?&lt;/span&gt;&lt;br /&gt;Here's the code to compute the prime numbers contained in the first 100,000 first natural numbers, it doesn't even take a second to complete. I'm making use of the matrix package Numpy previously introduced in &lt;a href="http://psylarium.blogspot.com/2010/01/word-about-fractals-and-python.html"&gt;my blog entry about fractals&lt;/a&gt;.&lt;br /&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;numpy&lt;/span&gt; &lt;span class="kn"&gt;as&lt;/span&gt; &lt;span class="nn"&gt;N&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="n"&gt;pr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ones&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;100000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;bool&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c"&gt;# Interval to search for primes&lt;/span&gt;&lt;br /&gt;&lt;span class="n"&gt;pr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;&lt;br /&gt;&lt;span class="n"&gt;pr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;4&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="mf"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;&lt;br /&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;xrange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pr&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="mf"&gt;2&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;br /&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;pr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;           &lt;span class="c"&gt;# If x is a prime&lt;/span&gt;&lt;br /&gt;        &lt;span class="n"&gt;pr&lt;/span&gt;&lt;span class="p"&gt;[::&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt; &lt;span class="c"&gt;# Mark every x entry as 0 (non-prime)&lt;/span&gt;&lt;br /&gt;        &lt;span class="n"&gt;pr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;  &lt;span class="c"&gt;# Except the one for x&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="c"&gt;# Finally filter out zero entries&lt;/span&gt;&lt;br /&gt;&lt;span class="n"&gt;pr2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pr&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;nonzero&lt;/span&gt;&lt;span class="p"&gt;()[&lt;/span&gt;&lt;span class="mf"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;And that's all there is to it.&lt;br /&gt;&lt;br /&gt;Last but not least, here's a link for verifying big (and small) prime numbers: &lt;a href="http://www.numberempire.com/primenumbers.php"&gt;http://www.numberempire.com/primenumbers.php&lt;/a&gt;. This website can verify numbers up to $10^{128}$ which is much superior to any other website I visited.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/641775512404432043-2901085744224253232?l=psylarium.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://psylarium.blogspot.com/feeds/2901085744224253232/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://psylarium.blogspot.com/2010/01/fast-computation-of-prime-numbers-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/641775512404432043/posts/default/2901085744224253232'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/641775512404432043/posts/default/2901085744224253232'/><link rel='alternate' type='text/html' href='http://psylarium.blogspot.com/2010/01/fast-computation-of-prime-numbers-in.html' title='Fast computation of prime numbers in Python'/><author><name>Psylarium</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://4.bp.blogspot.com/__EdzLGBTPjY/S0L1RaoGewI/AAAAAAAAAAM/nRz68Gseru8/S220/psylarium.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-641775512404432043.post-5902336028881454665</id><published>2010-01-08T23:36:00.001-08:00</published><updated>2010-01-09T01:03:33.350-08:00</updated><title type='text'>A word about fractals and Python</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Introducing Python&lt;/span&gt;&lt;br /&gt;There's a nice language that I use pretty much for everything, it is &lt;a href="http://www.python.org/"&gt;Python&lt;/a&gt;. What's so special about Python ? Well it's simple, easy to learn and yet powerful. Its syntax is particularly clear and it can also be compiled into Java bytecode thanks to &lt;a href="http://www.jython.org/"&gt;Jython&lt;/a&gt;. I've been using it for years and pretty much anything else I looked at never convinced me as much.&lt;br /&gt;&lt;br /&gt;One limitation of Python though is the execution speed, and I'm talking about the pure Python not Jython which is much faster. Since in the next part of this little blog post I am going to do some pretty intensive computations, namely fractals, it's important to mention the speed aspect of things. But, fear not, python is expanded with tons of packages which are C++ fast (which is often as fast as you get, excepting pure machine code which can also be derived from Python but that's another story).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Introducing Numpy and Pylab&lt;/span&gt;&lt;br /&gt;&lt;a href="http://numpy.scipy.org/"&gt;Numpy&lt;/a&gt; is a mathematic package for python that binds to a huge library of mathematical primitives. Basics include matrices and operations to manipulate them. It also includes more advanced capabilities such as matrix inversion, least square computation, singular value decomposition and a lot more.&lt;br /&gt;&lt;a href="http://matplotlib.sourceforge.net/"&gt;Pylab or matplotlib&lt;/a&gt; is a superb package to display curves and images. This thing looks good, really good. So check the link if you're looking for some beautiful plotting in a very few lines of code.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Let's enter the fractal world&lt;/span&gt;&lt;br /&gt;First let's have a little teaser of a fractal image computed with the program I'm going to present later:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/__EdzLGBTPjY/S0g10YW3SgI/AAAAAAAAAAw/EBohvES7cO0/s1600-h/fractal.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 298px;" src="http://3.bp.blogspot.com/__EdzLGBTPjY/S0g10YW3SgI/AAAAAAAAAAw/EBohvES7cO0/s400/fractal.jpg" alt="" id="BLOGGER_PHOTO_ID_5424644925175581186" border="0" /&gt;&lt;/a&gt;Let's get acquainted with the Mandelbrot set. The Mandelbrot fractal is computed by looking at the divergence of the complex (see &lt;a href="http://en.wikipedia.org/wiki/Complex_number"&gt;this page&lt;/a&gt; for an explanation of complex numbers) function $z_{n}=z_{n-1}^{2}+c$ with the initial condition $z_{0}=c$. Mandelbrot's set is computed by computing a &lt;span style="font-style: italic;"&gt;z&lt;/span&gt; function at every position (&lt;span style="font-style: italic;"&gt;x&lt;/span&gt;,&lt;span style="font-style: italic;"&gt;y&lt;/span&gt;) of the 2D space, and the constant &lt;span style="font-style: italic;"&gt;c&lt;/span&gt; is defined as &lt;span style="font-style: italic;"&gt;c&lt;/span&gt;=&lt;span style="font-style: italic;"&gt;x&lt;/span&gt;+&lt;span style="font-weight: bold;"&gt;j&lt;/span&gt;.&lt;span style="font-style: italic;"&gt;y&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Next to determine the color of the pixel, we have to determine whether the function z has diverged. We know for sure that it will diverge if $\left|z_{n}\right|\geq4$. So the first &lt;span style="font-style: italic;"&gt;n&lt;/span&gt; for which the previous condition is true determines the color of the point.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Implementation in Python&lt;/span&gt;&lt;br /&gt;As mentioned earlier, for optimal computation speed, we're going to make use of matrices to compute all the points simultaneously.&lt;br /&gt;&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;numpy&lt;/span&gt; &lt;span class="kn"&gt;as&lt;/span&gt; &lt;span class="nn"&gt;N&lt;/span&gt;&lt;br /&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;pylab&lt;/span&gt; &lt;span class="kn"&gt;as&lt;/span&gt; &lt;span class="nn"&gt;P&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="n"&gt;dx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;663&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;007&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c"&gt;# X start position, X width&lt;/span&gt;&lt;br /&gt;&lt;span class="n"&gt;dy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-.&lt;/span&gt;&lt;span class="mf"&gt;191&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;007&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c"&gt;# Y start position, Y width&lt;/span&gt;&lt;br /&gt;&lt;span class="n"&gt;v&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;zeros&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="mf"&gt;1024&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mf"&gt;1024&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;uint8&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;    &lt;span class="c"&gt;# The color matrix&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="c"&gt;# Create the constant matrix and initialize it&lt;/span&gt;&lt;br /&gt;&lt;span class="n"&gt;c&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;zeros&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="mf"&gt;1024&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mf"&gt;1024&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;complex&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;[:]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;real&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;linspace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dy&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="n"&gt;dy&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;dy&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;br /&gt;                       &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])[:,&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;newaxis&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;br /&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;[:]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;imag&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;linspace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dx&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="n"&gt;dx&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;dx&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;br /&gt;                       &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])[&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;newaxis&lt;/span&gt;&lt;span class="p"&gt;,:]&lt;/span&gt;&lt;br /&gt;&lt;span class="n"&gt;z&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;           &lt;span class="c"&gt;# The z function is initialized from c&lt;/span&gt;&lt;br /&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;xrange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;256&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;  &lt;span class="c"&gt;# Use 256 colors&lt;/span&gt;&lt;br /&gt;    &lt;span class="n"&gt;z&lt;/span&gt; &lt;span class="o"&gt;*=&lt;/span&gt; &lt;span class="n"&gt;z&lt;/span&gt;              &lt;span class="c"&gt;# Compute z = z*z&lt;/span&gt;&lt;br /&gt;    &lt;span class="n"&gt;z&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;              &lt;span class="c"&gt;# Compute z = z + c&lt;/span&gt;&lt;br /&gt;    &lt;span class="c"&gt;# Set colors for which z has diverged&lt;/span&gt;&lt;br /&gt;    &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;abs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mf"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mf"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;it&lt;/span&gt;&lt;br /&gt;&lt;span class="n"&gt;P&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;imgshow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;      &lt;span class="c"&gt;# Display the image&lt;/span&gt;&lt;br /&gt;&lt;span class="n"&gt;P&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;show&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;And voila, this will generate a beautiful fractal picture like the one shown above. Note that you can experiment with different start positions and widths for dx and dy. The smaller the width, the more you zoom in, the larger the more you zoom out. Have fun !&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/641775512404432043-5902336028881454665?l=psylarium.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://psylarium.blogspot.com/feeds/5902336028881454665/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://psylarium.blogspot.com/2010/01/word-about-fractals-and-python.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/641775512404432043/posts/default/5902336028881454665'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/641775512404432043/posts/default/5902336028881454665'/><link rel='alternate' type='text/html' href='http://psylarium.blogspot.com/2010/01/word-about-fractals-and-python.html' title='A word about fractals and Python'/><author><name>Psylarium</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://4.bp.blogspot.com/__EdzLGBTPjY/S0L1RaoGewI/AAAAAAAAAAM/nRz68Gseru8/S220/psylarium.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/__EdzLGBTPjY/S0g10YW3SgI/AAAAAAAAAAw/EBohvES7cO0/s72-c/fractal.jpg' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-641775512404432043.post-303877581294342068</id><published>2010-01-04T23:40:00.000-08:00</published><updated>2010-01-05T00:04:06.980-08:00</updated><title type='text'>Let's start the new year on a positive note: Twitter sucks !</title><content type='html'>Now that may come as a pretty assertive statement, almost brutal. But let me explain.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;The context&lt;/span&gt;&lt;br /&gt;Well you have to put yourself in my position for 2 minutes. Here in the silicon valley, but it's probably the same across USA, when I watch the TV, I keep hearing Twitter this, Twitter that. From the cooking shows, to the news, to the UFC fighting organization, you hear about Twitter everywhere, all the time. It's a perpetual brainwashing machine. It's like the internet bubble that exploded in 1999 has re-inflated itself with Web 2.0 !&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;The initiation&lt;/span&gt;&lt;br /&gt;Eventually, be it due to the perpetual brainwashing or to simple curiosity, I finally opened myself a twitter account. First, when I logged in, the twitter website asked me: Tell what you are doing now. Ahem, isn't that a bit too personal a question ? Ok I get it, that's the concept, exhibitionism. Put your life out like you were a popstar, forget intimacy, just let it go. Well, that's where things got difficult for me, I wasn't doing anything special just typing on my computer and trying to find something smart to say about what I was doing which was "trying to find something smart to say about what I was doing", etc... &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Seeing the light&lt;/span&gt;&lt;br /&gt;So anyway, using Twitter, I really got to realize it's amazing power. It's like an email, but limited to 130 or so characters (I forgot the exact number anyway). Now I understand why everybody talks about it, what a revolution ! Limiting an email to 130 characters, who would have thought of that. It's incredible we had to wait for Web 2.0 to have such revolutionizing concept !&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Size doesn't matter&lt;/span&gt;&lt;br /&gt;Now it's time to realize, the best quotes from literature are less than 130 characters. Now, with a completely new open mind, I started to see what people were saying, which basically is: "I'm gardening today, it's sunny", "Let's stay in touch", "We announce a new product", etc... &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;A drop of water in the ocean&lt;/span&gt;&lt;br /&gt;All this Twitter experience finally convinced me that people, in the end, just want to feel that someone cares about them, that somehow in the multitude of the human population, someone is genuinely interested in them. However, thanks to Twitter, now I realize that most pretend to be interested in them simply to receive a reciprocal faked interest.&lt;br /&gt;&lt;br /&gt;Now join me on Twitter, come read my blog, visit my website. &lt;br /&gt;You won't be disappointed !&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/641775512404432043-303877581294342068?l=psylarium.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://psylarium.blogspot.com/feeds/303877581294342068/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://psylarium.blogspot.com/2010/01/lets-start-new-year-on-positive-note.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/641775512404432043/posts/default/303877581294342068'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/641775512404432043/posts/default/303877581294342068'/><link rel='alternate' type='text/html' href='http://psylarium.blogspot.com/2010/01/lets-start-new-year-on-positive-note.html' title='Let&apos;s start the new year on a positive note: Twitter sucks !'/><author><name>Psylarium</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://4.bp.blogspot.com/__EdzLGBTPjY/S0L1RaoGewI/AAAAAAAAAAM/nRz68Gseru8/S220/psylarium.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-641775512404432043.post-3213036684413821952</id><published>2010-01-04T23:31:00.001-08:00</published><updated>2010-01-04T23:34:24.291-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='introduction'/><category scheme='http://www.blogger.com/atom/ns#' term='newbie'/><title type='text'>And now for something completely different</title><content type='html'>That's it.&lt;br /&gt;I've done it.&lt;br /&gt;I'm now part of the big internet soup, ready to share my insignificant self !&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/641775512404432043-3213036684413821952?l=psylarium.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://psylarium.blogspot.com/feeds/3213036684413821952/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://psylarium.blogspot.com/2010/01/and-now-for-something-completely.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/641775512404432043/posts/default/3213036684413821952'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/641775512404432043/posts/default/3213036684413821952'/><link rel='alternate' type='text/html' href='http://psylarium.blogspot.com/2010/01/and-now-for-something-completely.html' title='And now for something completely different'/><author><name>Psylarium</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://4.bp.blogspot.com/__EdzLGBTPjY/S0L1RaoGewI/AAAAAAAAAAM/nRz68Gseru8/S220/psylarium.jpg'/></author><thr:total>1</thr:total></entry></feed>
