KidsCase iPhone & iPad development

Hello everyone,

In last month I was working for Intermarum on a iPhone and iPad game called Kids Case . The game is made especially for children aged 2-5 to familiarise them with new technologies. Kids Case is a game which connect fun with learning. The legendary Memory Game or Puzzles can also be found in Kids Case. The entertaining is made up with beautiful graphics, which are to my liking.

So, after a short introduction, let’s talk about technical side of Kids Case. My task was to implement seven different small games which all together makes Kids Case. The path I chose was to first write all classes and keep images and xib files proper for iPod Touch, iPhone 2G-3GS and iPhone 4 which has twice  a resolution then his predecessor. So in this way I get proper scaling for all iPhones and iPod devices. When the app was ready for iPhones, the reasonable time for iPad came. What I wanted was one universal app. So I’ve marked my target and upgraded it for iPad. It have made a small changes in info.plist and a new iPad-ready .xib file of MainWindow where the app begins. And here I decided to make a new group specially for iPad with all classes rewritten. I don’t really know whether it was a right move or not. One thing I know, that it for sure keeps my project well organised.  Perhaps, I will change my mind one day but for now I somehow dislike condition statements all over the code.

This is my first iPhone app I’ve ever made. I’ve enjoyed the developing process. Apple delivered high-quality kit for developers. Documentation is well written and easy to navigate. For beginner iPhone developer as me, I found stackoverflow.com most helpful site on the internet. I highly recommend typing “site:stackoverflow.com” in google while looking for leads. I would like to post some code with gruelling algorithms, but unfortunately  I haven’t written any code to boast. The project was rather easy to implement, I have just dived in iPhone programming. Now when I know the rules, the Cocoa Touch  API, the Interface Builder, all the environment I’m going to made a game for my own. I can’t tell you exactly what it will be about. I will be just successively adding some new algorithms to the blog. Stay tuned, here I come appstore ;)

Python script for sharing Dropbox files on webpages !

Hi there !
I always wanted to have a download list on my wordpress sidebar but I don’t really like box.net. I’m using dropbox on ubuntu and I found it really handy so I wrote a python script which is generating public urls of files which are in my Dropbox/Public/downloads. I find out that I can have a rss widget on sidebar so I decided to use it to show my downloads. I choose www.delicious.com to generate the rss. My script is simply adding a puburl and the filename (from my dropbox directory) to my delicious bookmarks, than wordpress get’s rss on sidebar widget ;)

What you need to use this script:
- Linux with dropbox
- delicious account
- Python (almost on every linux)

Scripts works like this:
Checking if there are any new files in predetermined directory ->; if true: gets filenames and puburls -> send it to delicious.com with “download” tag (to keep bookmarks in harmony:p) -> (here I’m using it by rss but you can do what you want with it:p)

Here is my code, enjoy ( of course you can download it from sidebar – droplist.py )
Please post issues in comments or talk to me on gtalk.

#!/usr/bin/python
# -*- coding: utf-8 -*-
# From author: Stop for a sec on every comment I've posted here, and do what it says  -Tetek
# P.S Add alias to .bashrc to make it faster to run

import urllib2, urllib, commands, dircache, os, struct, time
from stat import *

theurl = "https://api.del.icio.us/v1/posts/add?"
#Enter your username and password ( url is constant for everybody)
username = 'tetek'
password = 'xxx'
try:
	passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
	passman.add_password(None, theurl, username, password)
	authhandler = urllib2.HTTPBasicAuthHandler(passman)
	opener = urllib2.build_opener(authhandler)
	urllib2.install_opener(opener)
	
	
except:
	print "Incorrect username or password (or just connection fucked up)"

home = os.getenv("HOME")
# Please enter path to folder that you want to upload
path = home + '/Dropbox/Public/downloads/'
files = dircache.listdir(path)

#I'm using tag: download, just simply to get stuff in right order
#'replace' is optional..
def Upload_File_List(i):
	out = commands.getoutput('dropbox puburl ' + path + i)
	paired = { "url": out, "description": i, "tags":"download" ,"replace":"no" }
	data = urllib.urlencode(paired)
	full_url = str(theurl + data)
	upload_it = urllib2.urlopen(full_url)
	print " - " + i + " added!"

try:
#datekeeper keeps the date when this script was last runned
	date_keeper = open("datekeeper.txt", "rb")	
	handler = date_keeper.read()
	date_keeper.close()
	last_update = struct.unpack('i', handler)
#It checks if there are some new files to update
	for x in files:
		check_stat = os.stat(path + x) 
		if int(check_stat[ST_ATIME]) >= int(last_update[0]):
			Upload_File_List(x)
		
	print "Synchronised"
except:
		
	for y in files:
		Upload_File_List(y)
	print "Success"
	

	
	
	
try:
#Saves the current time to the datakeeper.txt I used struct lib to keep int binary
	time_saver = open("datekeeper.txt", "wb")
	current = struct.pack('i', time.time())
	time_saver.write(current) 
	time_saver.close()
except:
	print  "Can't save current time do datekeeper.txt"

From JesusFreke to CM- recovery..

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

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

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.
You can find downloads files in sidebar;)

Algorithm No. 1 INSERTION SORT

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

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

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 znajdziecie na sidebarze)

Ć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)

Follow

Get every new post delivered to your Inbox.