Tetek weblog

From JesusFreke to CM- recovery..

Posted by: Tetek on: January 27, 2010

Hi,

I’ve spent so much time on updating my android software, that I want to share a solution with you.

What we want to do:

- install cm-recovery-1.4.img ( or similar )

- install  cyanogen mod

What we have:

- Donut 1.6

- JesusFreke recovery

What we tried:
(Here can be differences, no matter)

D:\Android\AndroidMod> adb shell
$ su
# cd /system
# cat /data/local/recovery.img > recovery.img
# flash_image recovery recovery.img
#

What is the problem?:

 /sbin/sh: flash_image: not found

I had this error every time.. I found something like fastboot, but JF recovery don’t support it..
There is one simple solution..
Downgrade your phone to 1.5 Cupcake, and than try what I’ve written above ;)
P.S Cyanogen is slow, it takes 10s to back to home screen. (G1)

Asker v6 – learn words

Posted by: Tetek on: December 31, 2009

Hello everyone. I want to introduce my newest application “Asker“. The name is simply transformation of “Ask”, ‘cos this app is asking, examining you . For example, imagine that you want to learn Spanish. With all the grammar you are useless until you known words in Spanish. There is no method to know the words behind basically learn them. So I made a program in python which helps you to learn the new words. At first you must have the date base, you have 3 cases:

1. Make it by yourself in notepad

2. Make it by Asker builtin function

3. Download it from www.wordki.pl (for polish users)

And I really don’t want to post here all the Introduction because I have already did it in google code  project page.  http://code.google.com/p/asker/

If you have any issues, please report. Feel free to browse source code ;)

Regards, Tetek

TakeBus

Posted by: Tetek on: November 24, 2009

Hi.
It has been a long time since I ended TakeBus project but today I just want to share it here. It is my first python app ever. I see a lot of bugs there and it won’t probably works for you (prob you would never need this app). TakeBus is simple python app. I coded it because I could never remeber the bus table. As a student from highschool (Rybnik) which is not in my city(Rydułtowy)  I’m used to take bus to school and back. I’m android user so I have python interpreter in my pocket. This app contain 2 files: setup.py which connects to internet to get buses tables and than save it to the file. rozklad.py which ask me where am I and show me with which buses can I go to Rybnik or Rydułtowy.
Here are the files.
- rozklad.py
- setup.py

Algorithm No. 1 INSERTION SORT

Posted by: Tetek on: November 24, 2009

Hello everyone !
I had found a nice book in my TI classroom which is called “Introduction to Algorithms” Thomas. H Cormen. I had some time during lesson so I decided to rewrite some algorithms in python. Here you got one of these, it is called “insertion sort”. Insertion sort is a simple sorting algorithm, a comparison sort in which the sorted array (or list) is built one entry at a time.

A = [6,2,3,1,5,8,10,9,22,7]

for j in range(1,len(A)):
    key = A[j]
    i = j -1
    while i >= 0 and A[i] > key:
        A[i+1] = A[i]
        i = i-1
    A[i+1] = key

UTF-8 odpowiedniki polskich liter

Posted by: Tetek on: October 14, 2009

Witam
Dodaje tutaj prosty pythonowy skrypt który zamienia polskie znaki (ąćśżź itp) na ich angielskie odpowiedniki (acszz itp) znaki są zamieniane z utf-8 do standardowych. Według tablicy Kodowania polskich znaków. Z tego co wiem, to nie ma wbudowanej funkcji do takiej operacji. encode(‘ascii’,'ignore’) nie działa do końca tak jak powinno. Ja rozwiązałem to tak:

def odkoduj(tekst):
    polskie = {"\xc4\x84":"A","\xc4\x86":"C",
"\xc4\x98":"E","\xc5\x81":"L","\xc5\x83":"N","\xc3\x93":"O",
"\xc5\x9a":"S","\xc5\xb9":"Z","\xc5\xbb":"Z","\xc4\x85":"a",
"\xc4\x87":"c","\xc4\x99":"e","\xc5\x82":"l","\xc5\x84":"n",
"\xc3\xB3":"o","\xc5\x9b":"s","\xc5\xba":"z","\xc5\xbc":"z"}
    for x in polskie.keys():
        tekst = string.replace(tekst,x,polskie[x])
    return tekst

Kurs Pythona Swachy – Ćwiczenia

Posted by: Tetek on: August 13, 2009

Zaczynając moją przygodę z pythonem naktnałem się na bardzo ciekawy kurs. Kurs Jakuba Swachy który możecie znaleźć na stronie http://uoo.univ.szczecin.pl/~jakubs/ . Bardzo polecam ten kurs osobom chętnym do poznania pythona.  Pomyślałem,  że zamieszcze tutaj moje rozwiązania do niektórych ćwiczeń.  (Pliki .py możecie ściągnąć z widgetu box.net)

Ćwiczenie 11.
Napisz program “numer.py”, który zamieni wprowadzony przez użytkownika ciąg cyfr na formę tekstową:
a) znaki nie będące cyframi mają być ignorowane
b) konwertujemy cyfry, nie liczby, a zatem:
- 911 to “dziewięć jeden jeden”
- 1100 to “jeden jeden zero zero”

import string
cyfry = ('zero', 'jeden', 'dwa', 'trzy', 'cztery', 'pięć', 'sześć', 'siedem', 'osiem', 'dziewięć')
ciag = raw_input('Podaj ciąg cyfr: ')
for x in ciag:
    if x not in string.digits: continue
    print cyfry[int(x)]

Ćwiczenie 12.
Woda zamarza przy 32 stopniach Fahrenheita, a wrze przy 212 stopniach Fahrenheita. Napisz program “stopnie.py”, który wyświetli tabelę przeliczeń stopni Celsjusza na stopnie Fahrenheita w zakresie od –20 do +40 stopni Celsjusza (co 5 stopni). Pamiętaj o wyświetlaniu znaku plus/minus przy temperaturze.

for x in range(-20,45,5):
    print '%+3i' % x, 'to sie równa %+4i' % ((x*9)/5 + 32), 'F'

Ćwiczenie 13.
Napisz program “oceny.py”, który wczytuje od użytkownika kolejne oceny i:
a) sprawdza czy wprowadzona ocena jest na liście dopuszczalnych na wydziale ocen (jeżeli ocena jest na liście dopuszczalnych na wydziale ocen, dodaje ją na listę otrzymanych ocen)
b) jeżeli wciśnięto sam Enter, oznacza to koniec listy otrzymanych ocen
c) wyświetla wyliczoną dla listy otrzymanych ocen średnią arytmetyczną.

wydzial = range(1,7)
dobre = []
oceny = input("podaj swoje oceny: ")
a = 0
for x in oceny:
    if x not in wydzial: continue
    dobre += [x]
for y in dobre:
    a += y
print "Twoja średnia ocen to", "%5.2f" % (float(a)/len(dobre))

Ćwiczenie 14.
Napisz program “tryg.py”, który wczyta od użytkownika wielkość kąta w stopniach i wyświetli wartość czterech podstawowych funkcji trygonometrycznych (sin, cos, tg, ctg) o ile dla danego kąta jest to możliwe.

from math import *
kat = input("Podaj wielkość kąta w stopniach: ")
print "%+5.3f" % sin(radians(kat))
print "%+5.3f" % cos(radians(kat))

if radians(kat)%(pi/2)== 0:
    print "nie ma takiego tangensa"
else:
    print "%+5.3f" % tan(radians(kat))

if radians(kat)%(pi)== 0:
    print "nie ma takiego cotangensa"
else:
    print "%+5.3f" % (1/tan(radians(kat)))

Ćwiczenie 15.
Napisz program “lotto.py”, który wyświetli 6 losowych i nie powtarzających się liczb z zakresu od 1 do 49.

from random import randint
lista = []

def lotto():
    a = randint(1,49)
    if a not in lista:
        lista.append(a)
    else:
        lotto()

for x in range(6):
    lotto()

print lista

Ćwiczenie 18.
Zdefiniuj funkcję “avg”, która dla dowolnej liczby parametrów zwróci ich średnią arytmetyczną (lub 0 dla 0 parametrów).

def avg(*a):
    y=0
    for x in a:
        y+=x
    return a and y/float(len(a))or 0

Ćwiczenie I.

Napisz program „liczby_slownie2.py”, który dla wprowadzonej liczby dziesiętnej (z zakresu 1-1999) wyświetli jej wartość zapisaną słownie.

liczby = {0:"zero",1: "jeden ",2:"dwa ",3:"trzy ",4:"cztery ",5:"pięć ",6:"sześć ",
          7:"siedem ",8:"osiem ",9:"dziewięć ",10:"dziesięć ",11:"jedenaście ",12:"dwanaście ",13:"trzynaście ",14:"czternaście ",
          15:"piętnaście ",16:"szesnaście ",17:"siedemnaście ",18:"osiemnaście",19:"dziewiętnaście",40:"czterdzieści",
          100:"sto ",200:"dwieście ",1000:"tysiąc ", 30: "trzydzieści ", 20: "dwadzieścia ",50: "pięćdziesiąt ",
          60: "sześćdziesiąt ",70: "siedemdziesiąt ",80: "osiemdziesiąt ",90: "dziewięćdziesiąt ",
          300: "trzysta ", 400: "czterysta ",500: "pięćset ",600: "sześćset ",700: "siedemset ",800: "osiemset ",900: "dziewięćset "}
r = liczby.keys()
r.sort()
r.reverse()
lr = ""
b = []
def fct(n):
    r = liczby.keys()
    r.sort()
    r.reverse()
    lr = ""
    for i in r:
        while i <= n:
            lr += liczby[i]
            n -= i
            break
    b = str(lr).rstrip('zero')
    return b

x = input("Podaj liczbę całkowitą:")
print  fct(x)

Nokia n91 HDD problem – Solved !

Posted by: Tetek on: November 5, 2007

As you know I’m nokia n91 user. This is the best phone which I’ve ever had. (n-gage,n-gage QD, 6600,w810i, 9300i communicator etc…). Everything was Ok, yesterday I was downloading podcast by wi-fi, (305mb skate video)… In this time I was instaling new programs.. I was so stupid and I was installing programs which i don’t know what they are for.. Installing more and more.. and phone got slowly.. And, It was about 19:00 when the podcast got downloaded. So when I want to connect n91 in USB STORAGE mode it says that HDD is used by some application. Also it don’t want to format HDD for the same reason. I was looking for internet a lot of time to get some tips for it.. I found some post where was wrote “I return my nokia n91 to the servis..” That’s break my down… but I could belive, becouse it looks like software problem, so I clicked a symbian s60 format code (*#7370#), and i stared to format my phone, but it doesn’t work as a result. “that HDD is used by some application” all the time… But I solved this problem.

As you know, or don’t know when remove the back cover the HDD is not working.. So what you must to do in points:
1. Removed back cover
2. Restart phone
3. After restarting put back cover
4. And very fast connect to the usb cable ( very fast because any other app. can’t start working on HDD)
5. Than backup your files
6. Format from Windows/Mac/Linux in FAT32 (WARNING!! DON’T FORMAT YOUR PHONE TO NTFS!! IT WOULDN’T WORK AGAIN!)
7. Now your phone must be working, do a format from a phone (Disk Manager), for sure that’s everything is OK.)
8. Now you can enjoy your nokia n91, and remember to install only useful software.

I decided to install only the best software, so I will write what I have installed on my phone!
And remember to install nokia soft updater and update your soft, it will be more compatible for sure!
I wish I helped you, If you have any problems, please write in comments ;-)
In the next update! Nokia headphones pilot HS-28 ! Amazing thing !

Snownews (RSS dla linuxa)

Posted by: Tetek on: August 30, 2007

Dzisiaj, rano szukając wiadomościm, stwierdziem żę wygodniej będzie mi czytać rss. Tylko gdzie? Na stronach? nie bardzo. W związku z tym zajrzałem do piruta. Najpierw chciałem zainstalować pierwszy z możliwych pakietów po wpisaniu rss, lecz wymagał firefoxa 2.0.0.3 .. a tak owego nie posiadam ( zaraz zakutalizuje). Ostatni na liście, “snownews”. można go także ściągnąć w konsoli.. su – , yum install snownews. SnowNews pokazuje newsy w konsoli. Porusza sie bardzo dynamicznie i płynnie, jest prosty w użyciu. Bardzo łatwo można dodać nowy kanał. Wystarczy kliknąć przycisk “a” i dodać url. Poniżej prezentuje screeny.
snownews5.pngsnownews2.pngsnownews3.pngsnownews

My delicious