Sunday, January 11, 2009

Opera mini and gmail

why can't I access my gmail accounts via opera mini but fine with the default browser ?
Been playing with the phone a little bit more over this weekend. I found 2 remote programs for S60, one being Salling Clicker and the other called Remote'Em All . Since remote is free ill be trying that and see how is it to set up VLC over wifi.

As for browsers, I tried the default browser, Opera Mini and Skyfire. Skyfire felt very laggy , slow and had some rendering issues. On the other hand opera mini is the superstar, fast rendering and havent come across a problem site yet. The default browser is also good, but if you are going to browse the web Opera Mini is the way to go

Tuesday, January 06, 2009

Remote For Nokia E71

Does any one know of some good software ( freeware :) ) that can act as a remote control for VLC or window media player over the lan ? Been hunting for something on the phone since I watch movies on my laptop connected to a big screen and it would be nice to control the playback over the air from the phone....any ideas ?

Friday, January 02, 2009

New Phone

So after a lot of research I finally went ahead and bought my first Nokia phone, the E71 . I bought it close to a month ago, and love it. Its packed with software and is amazingly good looking as well. Ill start posting more about the applications I have played it and my overall experience as a first time Symbian user after having used pretty much only Sont Ericsson phones in the past.

Wednesday, September 24, 2008

Nokia Tube



I cant wait for this phone to come out. Rumors state Oct 2nd and usually Nokia usually doesnt disappoint. If only the N96 was close to $1200

Wednesday, July 09, 2008

its been ages, but here goes another attempt

is anyone really surprised by the early iphone reviews ?? I mean when the phone was announced it was pretty clear that other than gps and 3g there wasnt a whole lot that you could call new in this phone. Still doesnt mean I wont go buy one, but the samsung and sony are really looking appealing :)

Thursday, May 15, 2008

I need to revive this thing again ..... need more ideas though

Saturday, January 05, 2008

Project Euler 40

One more :)

This one was really easy. Also learnt a thing or two about string concatenations in python when my original techinique of k += str(someInt) was taking way to long as the length of the string increased.

Apparently when wanting to a large number of concatenation, its fast to append to an array and then do a join.

Problem #4o states:-
An irrational decimal fraction is created by concatenating the positive integers:

0.123456789101112131415161718192021...

It can be seen that the 12th digit of the fractional part is 1.

If dn represents the nth digit of the fractional part, find the value of the following expression.

d1 × d10 × d100 × d1000 × d10000 × d100000 × d1000000

Solution:-

import time
w = time.time()
d = ''.join([`num` for num in xrange(1,190000)])
print int(d[0])*int(d[9])*int(d[99])*int(d[999])*int(d[9999])*int(d[99999])*int(d[999999])
print time.time() - w

Saturday, December 29, 2007

Project Euler 39

After a long time , but here is another project euler problem that I worked on.

This one was quite fun.

Problem:-
The number 3797 has an interesting property. Being prime itself, it is possible to continuously remove digits from left to right, and remain prime at each stage: 3797, 797, 97, and 7. Similarly we can work from right to left: 3797, 379, 37, and 3.

Find the sum of the only eleven primes that are both truncatable from left to right and right to left.

NOTE: 2, 3, 5, and 7 are not considered to be truncatable primes.

Solution:-

Again its a brute force ( takes a while to get the last prime) ,

I use a generator I found online to get the list of primes and then check if it left and right truncatable.


import time
from itertools import ifilter, count

def isPrime(n):
if n == 1:
return False

i = n - 1
while i > 1:
rem = n % i
if rem == 0:
return False
else:
i = i - 1
return True

def truncateLeft(num):

k = num

while k != 0:
k /= 10
if not isPrime(k):
return False
return True


def truncateRight(num):
k = num

while k != 0:
k %=(10**(len(str(k))-1))
if not isPrime(k):
return False
return True

def sieve():
g = count(2)
while True:
prime = g.next()
yield prime
g = ifilter(lambda x, prime=prime: x % prime,g)




candidates = []

t = time.time()

primes = sieve()
start = primes.next()

while len(candidates) != 11:
if truncateLeft(start) and truncateRight(start) and start > 7:
candidates.append(start)
print str(start) + " has been added"
start = primes.next()

print sum(candidates)
print time.time() - t

Thursday, September 20, 2007


Sony Ericsson has some of the best designs for phones, just have a look at this one:-

Saturday, September 01, 2007

I dont even know what to post about anymore, but I will post more often ...... in other news last week I was in New Orleans for company training and now I am a SCRUM Master :)

Friday, August 03, 2007

Project Euler #39

This is my solution for Project Euler #39

its definitely brute force and im sure there is a better way to get the answer, but here we go

Problem:-
f p is the perimeter of a right angle triangle with integral length sides, {a,b,c}, there are exactly three solutions for p = 120.

{20,48,52}, {24,45,51}, {30,40,50}

For which value of p 1000, is the number of solutions maximised?

My Solution:-


import math, time

t = time.time()

maximum = {}

for a in xrange(1,500):
for b in xrange(1,500):
c = math.sqrt(pow(a,2)+pow(b,2))
p = a+b+c
if p == int(p) and p < 1000:
if maximum.has_key(p):
maximum[p] += 1
else:
maximum[p] = 1

e = maximum.keys()
e.sort(cmp = lambda a,b: cmp(maximum[a],maximum[b]))
print e[-1]
print time.time()-t

Friday, July 13, 2007

Namespaces for PHP

I read this kinda late, but namespaces were definitely required in php and now they have been made official http://www.gravitonic.com/blog/archives/000418.html

Thursday, July 05, 2007

Project Euler

I am completely addicted to this site...its all about solving math problems using programming.

Here is the solution to one of the problems

How Many Lychrel Numbers are below 10,000 ? http://projecteuler.net/index.php?section=problems&id=55

my solution in python, which takes abt 39 seconds:-

def lychrel(x):
i = 0
while i < 50:
x += int(str(x)[::-1])
if str(x) == str(x)[::-1]:
return False
i += 1
return True

print len ([x for x in range(1,10000) if lychrel(x)])

Saturday, May 26, 2007

Microsoft Popfly

So today I got an invite for microsoft's popfly . Popfly seems to be msfts take on letting users create mashups, websites , communities etc without typing in a single line of code and is powered by silverlight. The key word here being "user" which means anyone can create a mashup without knowing how things work behind the scenes.

The site is in alpha, and there are definitely some issues that I have come across. But the UI is amazing, it works with firefox ( big plus ! ).

I will be messing around with this and see what mashups I can come up with. Please feel free to add me as a friend ( http://www.popfly.ms/users/Kashif ) and I will post invites for users as soon as I get them :)

Sunday, May 06, 2007

Vice Funds

I read about vice funds a while back on fark.com. From the site the fund invests in alcohol, tobacco, gaming, aerospace and defense stocks. It is an interesting concept because in many ways people are addicted to this stuff and they have had very nice yearly returns ( close to 14.3%/yr ) to back their idea.

Now for anyone who still reads this would you invest in it ? Abhi , I think I already know your answer :)
I need to start posting stuff here again ....

Saturday, February 24, 2007

Roman Numeral Converter

One more codegolf challenge:-

In this challenge, you will be given a number in roman numeral form and must print out its integer value.

( from codegolf)


My latest solution at 129 bytes:-

r,l,s={'M':1000,'D':500,'C':100,'L':50,'X':10,'V':5,'I':1},1000,0
for j in raw_input():s+=r[j]-(0,l*2)[r[j]>l];l=r[j]
print s

Any other ideas ?

Update:

After manzo's comment, I searched a little and came up with this. Right now its at 119 bytes

r,l,s=dict(M=1000,D=500,C=100,L=50,X=10,V=5,I=1),1000,0
for j in raw_input():s+=r[j]-(0,l*2)[r[j]>l];l=r[j]
print s

Saturday, January 06, 2007

Colors for Visual Studio

Having watched a lot of videos featuring textmate, I really liked the color scheme that was being used by a lot of the videos. After some searching I came across Scott Hanselmans blog where he suggests some colors that bring it quite close.

This is what my current setting looks like:-

Any ideas for the colors of the html tag names other than white ?


Friday, December 08, 2006

Codegolf

Ive been working on this codegolf challenge recently which I found quite fun to do (codegolf == accomplish a challenge in code using least amt of lines )

The challenge in question:-

The game of REVERSE requires you to arrange a list of numbers in numerical order from left to right. To move, you tell the computer how many numbers (counting from the left) to reverse. For example, if the current list is 2 3 4 5 1 6 7 8 9 and you reverse 4, the result will be 5 4 3 2 1 6 7 8 9. Now if you reverse 5, you win.

What we're asking you to do is, given a list of numbers in a random order, produce the moves required to arrange them so they end up in numerical order.

(from codegolf.com)



Now Ive been working on this for a couple of hours and the best I can come up with is this ( My language of choice, python):-


[UPDATE #1]: File Size - 181kb

1) Changed the while loop condition

2)A different way of printing, by adding a comma after the last object one can suppress the new line that is automatically added by print in python

3)Removing unnecessary indentation helped on the file size

4)Didnt need the strip function

import re,sys
n = map(int,re.split(" ",sys.stdin.readline()))
l = len(n)
while l:
m = n.index(max(n[0:l])) + 1
n[:m] = n[m-1::-1]
n[:l] = n[l-1::-1]
print m,l,
l -= 1


[ORIGINAL]


import re,sys
n = map(int,re.split(" ",str(sys.stdin.readline()).strip()))
l = len(n)
while n != sorted(n):
m = n.index(max(n[0:l])) + 1
n[:m] = n[m-1::-1]
n[:l] = n[l-1::-1]
print m,"\n",l
l -= 1


the algorithm works in the following way:-

given a list, get its length

find the index of the maximum value within it, do a reverse from 0 to the index, so now the max is in front (and the move being the index + 1)

then do a reverse again on the length of the list , bringing the max to the end of the list (now the move after that being the length of the list)

decrease the length, so you iterate over a smaller list and repeat the same steps on the smaller section of the list


Anyone have anymore ideas to make this shorter ( either the program itself or the algorithm ) ?