Monday, October 29, 2012

isPrimeNumber() by Recursion in Python

In the pursuit to optimize some code In was writing I had to write this isPrime() by recursion.

Thursday, October 25, 2012

#shell scripting

So bash scripting in my opinion is cool but annoying
I want to access the file path and file name of a particular file but i don't know the file name. At least i know part of the file name. The files actual name is 'file_name_long.bin' and it is in the directory 'path/path/path/' from my current working directory.

So to get the file path I do something like

`ls path/path/path/file* | grep _name`

This will output : path/path/path/file_name_long.bin

And to get the file name

`ls path/path/path/ | grep _name`

This will output : file_name_long.bin

Hope this helps someone

Wednesday, October 17, 2012

just tried Chromium OS

Just took chromium OS chrome OS  for a whirl and its a pretty good os. Downside is that you have to be connected to the internet to do most of the stuff. I am trying it on a compaq presario c700. The boot is quite fast. My main motivation was the fact that I knew that Google had offered an offline version of docs and i wanted to try it out. Offline Google docs seems to be working well for only documents(text not spreadsheet). That's okay considering it is a beta product.
But my main disappointment is that the touch pad does not work well. Clicking via the buttons and tapping the touch pad works, but moving the mouse does not work. I have tried some of the suggestions on the forum but i still haven't been successful. But I think that the mouse would work with the 'lime' build as they call it.I will give it a try and see how it goes. All in all i am amazed at the power of html and java-script.
With more native looking apps coming up and more offline support Google chrome OS can build and integration of web and desktop that we have not experienced before.

Saturday, October 13, 2012

Hi my name is **** and am a stalker

Sometimes I find myself snooping around peoples profiles on facebook, there photos, there timeline on twitter. Yeah am a stalker. A facebook and twitter stalker. In this day and age, I guess being a stalker is inevitable  But If that is all we do then we are in a mess. Social media has bridged barriers of location and time. But for us to build strong friendships we have to spend time with people not there facebook timeline or tweet feed. So.... note to self by God's grace I will spend time with people and not just there tweets or feeds.

Tuesday, October 2, 2012

Apache Basic Auth through a Reverse Proxy

It took me like a whole day of googling to figure this out.Say you have a web service that doesn't have any form of authentication and you want to open it up to a public ip but still setup some security. If you are this guy then you may want to try basic auth.

Step 1 : Create password file
htpasswd -c /home/user/.passwdFile <username>

Step 2 : Setup the reverse proxy
Setup the reverse proxy

LoadModule proxy_module      modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule headers_module    modules/mod_headers.so
LoadModule ssl_module        modules/mod_ssl.so
LoadModule auth_digest_module modules/mod_auth_digest.so

ProxyRequests Off
ProxyVia Off

ProxyPass / http://127.0.0.1:1234/
ProxyPassReverse / http://127.0.0.1:1234/

127.0.0.1:1234 is the url:port that your webservice is running on. From the above commands your app will be open at 127.0.0.1:80
Remember to include the relevant modules as has been done above the proxy stuff

Step 3 : Setup basic authentication. My mistake was that I was using directory instead of location. Directory refers to to the filesystem while Location refers to webspace..url and stuff
so...

<Location />
    AllowOverride AuthConfig
    Options ExecCGI
    Order allow,deny
    Allow from all
    AuthType Basic
    AuthName "My awesome webservice"
    Require valid-user
    AuthUserFile /home/user/.passwdFile
</Location>


So put this in your httpd.conf file and restart apache.There you have it basic auth on a reverse proxy.
Bigups to http://stackoverflow.com/questions/5011102/apache-reverse-proxy-with-basic-authentication ,
http://httpd.apache.org/docs/2.2/howto/auth.html

Monday, October 1, 2012

Joy, Peace and Contentment

Happiness doesn't come from a well told joke. It is not sustained by money or the possession of a thing or gadget. A person can never make you happy or more peaceful. A peaceful environment doesn't make me anymore peaceful. Having more than enough doesn't make one content.So what do we really need in this life? If all this things and people do not meet our core internal needs.

All I know is that I need Jesus : my God and Saviour. All we think we need come as a result of a relationship with Jesus. Galatians 5:22 But the fruit of the Spirit is love, joy, peace, longsuffering, kindness....
Go to the source to get the product. Don't go to the product. It cannot reproduce itself.