Puppy Programming School

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

Puppy Programming School

#1 Post by Lobster »

Puppy Hacker School
starts its first program of studies
http://puppylinux.org/wikka/PuppySchoolProgramming

Because Puppys are the friskiest breed of mongrels in this dimension
you can expect the students to be setting the pace . . .

Help :shock:

What have I started?

1. This year Puppy will be ARM'd and dangerous as we become Raspberry Pi enabled
2. The first language used on http://puppylinux.org/wikka/PARM
PARM will probably be bash script, leading to Bacon when we get a compiler with the Devx
3. Your ability to write tutorials with the language of your choice, is a good way of developing for the new generation

. . . must be time for a little rant . . . I remember the day I created a BASIC tutorial in Pascal for my students. Most adult students were only interested in using Word (A DOS program in ye olde days) and other applications but one guy got it. Programming is not for everyone but everyone can do a few basics . . .

Please share your knowledge 8)
Last edited by Lobster on Fri 09 Mar 2012, 13:19, edited 1 time in total.
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

User avatar
antiloquax
Posts: 405
Joined: Fri 27 Jan 2012, 09:17

#2 Post by antiloquax »

Hi Lobster!
Your Hackers' School is great. I notice that you have put a link to my Python blog - thanks for that!

I am interested in learning a bit more BASH scripting. I have been dipping into "The Shellcoders Handbook" and "Hacking: The Art of Exploitation". I got rather out of my depth with the second of these! Very interesting though!
mark
My System:Arch-Arm on RPi!
"[url=http://murga-linux.com/puppy/viewtopic.php?t=76049l]RacyPy[/url]" puplet on Toshiba Tecra 8200. PIII, 256 MB RAM.
[url=http://raspberrypy.tumblr.com/]RaspberryPy[/url]: Lobster and I blog about the RPi.

User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

#3 Post by Lobster »

This GUI front end should be both useful and easy to understand and modify:

http://www.murga-linux.com/puppy/viewto ... 850#185153
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

#4 Post by Lobster »

Gosh have not programmed in python for a couple of years
Something simple to start with . . .

A python example of two arrays and the random function
to create fruity insults - kids should instantly find this very useful

Must be supervised
Marks given for gentler insults which are more hilarious and disarming 8)

Code: Select all

## Random fruit response
# Lobster March 3 2012

import random

verb = ['erratic', 'unbelievable', 'unfortunate', 'inconsequential']
fruit = ['raspberry', 'pomegranite', 'banana', 'grape', 'loganberry']
print "You are an" , random.choice (verb) , random.choice (fruit)
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

User avatar
antiloquax
Posts: 405
Joined: Fri 27 Jan 2012, 09:17

#5 Post by antiloquax »

Nice one!

I led a class of Y9 (about 13-14 year olds) through a simple "You suck and I rule" infinite loop program last week!

My latest blog post is a "hack your homework" offering. I've been learning about math.pow() and "repr().rjust()"!

Grid Multiplication

I think I did this the hard way - if anyone can think of a more elegant solution, please let me know!
You can see the RPi logo just peeping around my screen-shot!


Image[/url]
My System:Arch-Arm on RPi!
"[url=http://murga-linux.com/puppy/viewtopic.php?t=76049l]RacyPy[/url]" puplet on Toshiba Tecra 8200. PIII, 256 MB RAM.
[url=http://raspberrypy.tumblr.com/]RaspberryPy[/url]: Lobster and I blog about the RPi.

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Re: Puppy Programming School

#6 Post by L18L »

Hi, could not resist the temptation to i18n
First Script
Save it as lob :wink:
------------------
edit
back from asking my translator whether lob is anything other than lobster´s first 3 letters: yes it is :D

User avatar
antiloquax
Posts: 405
Joined: Fri 27 Jan 2012, 09:17

#7 Post by antiloquax »

I'm reading (and trying to learn from) Schildt's "Java: The Complete Reference". I've got a bit lost in the section on bitwise operators.
Can anyone explain "two's complement" to me. I don't see how swapping all the bits and adding one would make the computer see it as a negative number. Also, what is the "high-order bit"?

I have a feeling I won't necessarily need to know all this, but still ...
:D :D
My System:Arch-Arm on RPi!
"[url=http://murga-linux.com/puppy/viewtopic.php?t=76049l]RacyPy[/url]" puplet on Toshiba Tecra 8200. PIII, 256 MB RAM.
[url=http://raspberrypy.tumblr.com/]RaspberryPy[/url]: Lobster and I blog about the RPi.

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#8 Post by SFR »

Hi antiloquax.

My English isn't so sophisticated, but examples should explain everything:

[BIN = DEC]

00000000 = 0
00000001 = 1
00000010 = 2
00000011 = 3
...
01111111 = 127

but:
10000000 = -128
10000001 = -127
10000010 = -126
10000011 = -125
...
11111111 = -1

Simply, the HOB (High Order Bit) or MSB (Most Significant Bit) may indicate if the number is positive or negative.

Two's complement example:
00101101 = 45
Now let's XOR all bits:
11010010 = -46
And add 1:
11010011 = -45

HTH
Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
antiloquax
Posts: 405
Joined: Fri 27 Jan 2012, 09:17

#9 Post by antiloquax »

Thanks for the reply SFR - what you wrote certainly fits in with what I have read about this - but I still don't see how
11111111 = -1
Isn't "11111111" 255?

I'm clearly missing something very obvious - I'll try to work it out later.

Let's say we have the binary number 7 - "00000111"
So we do "two's complement" and that gives us: "11111001".
So the left-most bit means -128, and then we add 64, 32, 16, 8 and 1 to get -7.
I get that. But how does the computer know that we don't mean 249?


antiloquax
My System:Arch-Arm on RPi!
"[url=http://murga-linux.com/puppy/viewtopic.php?t=76049l]RacyPy[/url]" puplet on Toshiba Tecra 8200. PIII, 256 MB RAM.
[url=http://raspberrypy.tumblr.com/]RaspberryPy[/url]: Lobster and I blog about the RPi.

User avatar
GustavoYz
Posts: 883
Joined: Wed 07 Jul 2010, 05:11
Location: .ar

#10 Post by GustavoYz »

"Signed magnitudes".
This has great information.

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#11 Post by SFR »

antiloquax wrote:I get that. But how does the computer know that we don't mean 249?
Computer doesn't know that :)
For CPU 11111001 may mean 249 as well as -7.
The beautiful thing is that when we add another 1, we'll get:
249 + 1 = 250
-7 + 1 = -6
11111010 = 250 = -6
so whatever you do, the result is always correct regardless if it's interpreted as positive or negative value.
The programmer decides how to interpret and display the result.

Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
antiloquax
Posts: 405
Joined: Fri 27 Jan 2012, 09:17

#12 Post by antiloquax »

Thanks for your help! It's becoming clearer!
My System:Arch-Arm on RPi!
"[url=http://murga-linux.com/puppy/viewtopic.php?t=76049l]RacyPy[/url]" puplet on Toshiba Tecra 8200. PIII, 256 MB RAM.
[url=http://raspberrypy.tumblr.com/]RaspberryPy[/url]: Lobster and I blog about the RPi.

User avatar
antiloquax
Posts: 405
Joined: Fri 27 Jan 2012, 09:17

#13 Post by antiloquax »

Image
My System:Arch-Arm on RPi!
"[url=http://murga-linux.com/puppy/viewtopic.php?t=76049l]RacyPy[/url]" puplet on Toshiba Tecra 8200. PIII, 256 MB RAM.
[url=http://raspberrypy.tumblr.com/]RaspberryPy[/url]: Lobster and I blog about the RPi.

User avatar
minesadorada
Posts: 68
Joined: Sun 11 Sep 2011, 19:10

Lazarus

#14 Post by minesadorada »

I'm having fun with Lazarus/FPC

I just wrote a general-purpose pascal object to handle calculating EGA handicap adjustments, EGA playing handicaps and new Exact EGA handicaps. It plugs into any simple Lazarus GUI app.

This is making my life a lot easier as the (temporary) handicap secretary of my local society.

I'm going to subclass it next to accept open-source golfML XML course definitions as an import. Then a golfML editor....

With Lazarus/FPC, I just recompile the same code for Linux 32, Windows 32 and Windows 64-bit versions, and it all works 100%

User avatar
antiloquax
Posts: 405
Joined: Fri 27 Jan 2012, 09:17

#15 Post by antiloquax »

I thought I'd post up links to a couple of .pets that might be of interest to programmers.

These are all available at ftp://raspberrypy.co/Pets/
User: a3804781
P'word: puppi1

Valgrind 3.7.0 - this is a memory checker that is recommended by Zed Shaw in his book "Learn C the Hard Way".

MIT Scheme 9.1.1 - An implementation of the dialect of LISP.
CLISP 2.49 - Common Lisp
MDK 1.2.6 - The MIXAL Development Kit
Lua 5.2.0
Ruby 1.9.3
My System:Arch-Arm on RPi!
"[url=http://murga-linux.com/puppy/viewtopic.php?t=76049l]RacyPy[/url]" puplet on Toshiba Tecra 8200. PIII, 256 MB RAM.
[url=http://raspberrypy.tumblr.com/]RaspberryPy[/url]: Lobster and I blog about the RPi.

User avatar
antiloquax
Posts: 405
Joined: Fri 27 Jan 2012, 09:17

#16 Post by antiloquax »

I've been doing a little reading up on different Scheme implementations. Some of the popular ones (eg Clojure) actually run in a Java VM. Personally, I find that slows down the whole thing (I divide my time between a reasonably fast desktop, a Raspberry Pi and a very old laptop!).

GNU Guile, on the other hand, seems to be written in C. I am putting together a .pet for this as we speak. It takes quite a long time to compile and needs libffi and libunistring.

mark
My System:Arch-Arm on RPi!
"[url=http://murga-linux.com/puppy/viewtopic.php?t=76049l]RacyPy[/url]" puplet on Toshiba Tecra 8200. PIII, 256 MB RAM.
[url=http://raspberrypy.tumblr.com/]RaspberryPy[/url]: Lobster and I blog about the RPi.

User avatar
antiloquax
Posts: 405
Joined: Fri 27 Jan 2012, 09:17

#17 Post by antiloquax »

If anyone fancies having a go, I have made some .pets for guile, libffi and libunistring.
They are at: raspberrypy.co.
User: a3804781
P'word: puppi1
mark
My System:Arch-Arm on RPi!
"[url=http://murga-linux.com/puppy/viewtopic.php?t=76049l]RacyPy[/url]" puplet on Toshiba Tecra 8200. PIII, 256 MB RAM.
[url=http://raspberrypy.tumblr.com/]RaspberryPy[/url]: Lobster and I blog about the RPi.

User avatar
antiloquax
Posts: 405
Joined: Fri 27 Jan 2012, 09:17

#18 Post by antiloquax »

There are now 5 tutorial videos on YouTube.
This link takes you to the most recent.
My System:Arch-Arm on RPi!
"[url=http://murga-linux.com/puppy/viewtopic.php?t=76049l]RacyPy[/url]" puplet on Toshiba Tecra 8200. PIII, 256 MB RAM.
[url=http://raspberrypy.tumblr.com/]RaspberryPy[/url]: Lobster and I blog about the RPi.

User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

#19 Post by RSH »

Cool!

I want to watch the video and learn something!

And then...

...the most recent video of the puppy programming school teaches you (teaches me)...

...NOTHING! :lol: :lol: :lol:

It is removed... :roll: :roll: :roll:

Image
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]

User avatar
antiloquax
Posts: 405
Joined: Fri 27 Jan 2012, 09:17

#20 Post by antiloquax »

RSH wrote:Cool!

I want to watch the video and learn something!

And then...
Sorry - I didn't know about the 15 minute limit.
It will be online later!

In the meantime my previous videos are available. here.
:oops:

EDIT
Tutorial Video Five is now available!
:D
My System:Arch-Arm on RPi!
"[url=http://murga-linux.com/puppy/viewtopic.php?t=76049l]RacyPy[/url]" puplet on Toshiba Tecra 8200. PIII, 256 MB RAM.
[url=http://raspberrypy.tumblr.com/]RaspberryPy[/url]: Lobster and I blog about the RPi.

Post Reply