Scratch Programming Playground by Al Sweigart

image

Summary: Great introduction to Scratch

So, you probably wonder where to start your adventure with Scratch. Don’t look any further. You have just found what you were looking for.

Let me be straight here. This book is perfect read after finishing Super Scratch Programming Adventure! (published by No Starch Press). Supper Scratch Programming Adventure will provide you with very basics of Scratch, while here, you can elevate your knowledge and become more experienced and more sophisticated Scratch coder. You don’t have to be a nerd to start your adventure with games. In fact, author tries to convince you that your math related issues – I know some people have them – are really not that important. And I fully agree here.

flow2
Click image to enlarge

What I like about the book is the way it delivers the knowledge – through building games. Number of them. It encourages people to learn by practice and experiments. It will push you towards code development instead of making you remember the stuff. That’s something I really appreciate. That’s quite in the line with my approach to learning:

For the things we have to learn
before we can do them,
we learn by doing them.
– Aristotle

You are supposed to build games by actually developing them. What I find quite useful for the readers are steps taken while building each project:

at first you take a look at sketch of your game. You can always do yours, all you need is sheet of paper and pencil
then, you learn how to code each of the elements used in the game
finally, you are encouraged to alter initial concept by introducing some changes into play (e.g. turn one player game into two player game, or to introduce some cheat codes)

This approach gives you the feeling of controlling everything. You are not thrown into deep water, instead, you make small steps to achieve the goal specified in each chapter.

But don’t be fooled by simple language and quite likable creatures hanging all over the place. They will teach you some good programming practices. You will be able to apply what you have learned, later during your engineering carer :) One of these principles is called DRY (Don’t Repeat Yourself, DRY at Wikipedia).


flow

Click image to enlarge

What’s also important is that you can get immediate access to content of the book, you can play sample projects (they are available via scratch.mit.edu – Projects). This way, you can compare your work to what can be treaded as reference. Really useful. Especially for people who just start their experience with coding. And to make this review more appealing to people whose motto is – “seeing is believing” – take a look below. That’s what you will learn to code! Cool, isn’t it?

snake

If you have used Scratch before, you will be able to find (inside the project) the good old Scratch code. It consists of blocks that make it super simple to code.

snake_code

If you haven’t used Scratch before, don’t be afraid. It’s really, really simple. Just take a look here:

So, just to make a quick conclusion. If you like games, if you want to write games, if you want to learn how to code, grab this one and make sure to read it cover to cover and build all the projects you find there! And don’t cheat! Try to code everything by yourself. This way, you will get most of it.

NoStarch (print): Scratch Programming Playground
NoStarch (e-book): Scratch Programming Playground
Safari Books Online: Scratch Programming Playground


Two line prompt with colors and gadgets

To get this

shell

use this

# bash

red="\[\033[1;31m\]"
green="\[\033[0;32m\]"
yellow="\[\033[1;33m\]"
blue="\[\033[1;34m\]"
magenta="\[\033[1;35m\]"
cyan="\[\033[1;36m\]"
white="\[\033[0;37m\]"
end="\[\033[0m\]"

export PS1="${white}┌[${green}\u${blue}@${green}\h${white}]\n└[\w]${end} "
# tcsh

set     red="%{\033[1;31m%}"
set   green="%{\033[0;32m%}"
set  yellow="%{\033[1;33m%}"
set    blue="%{\033[1;34m%}"
set magenta="%{\033[1;35m%}"
set    cyan="%{\033[1;36m%}"
set   white="%{\033[0;37m%}"
set     end="%{\033[0m%}"

set prompt="${white}┌[${green}%n${blue}@%m${white}]\n└[%~]${end} "

mwm confing for people who like minimalism during remote work

Here comes my supper ascetic ~/.mwmrc I use on regular basis.

Menu RootMenu
{
  "Root Menu"          f.title
  "Terminal - urxvt"   f.exec "/afs/eufus.eu/g2itmdev/user/g2michal/opt/usr/local/bin/rxvt &"
  "Terminal - Konsole" f.exec "/opt/trinity/bin/konsole &"
  "Shuffle Up"         f.circle_up
  "Shuffle Down"       f.circle_down
  "Refresh"            f.refresh
  no-label             f.separator
  "Restart..."         f.restart
  no-label             f.separator
  "Quit..."            f.quit_mwm
}

Buttons DefaultButtonBindings
{
  <Btn1Down>    icon  | frame  f.raise
  <Btn2Down>    icon    f.post_wmenu
  <Btn3Down>    root    f.menu RootMenu
  Alt<Btn1Down> window| icon   f.move
}

Keys DefaultKeyBindings
{
  Alt<Key>Escape             root|icon|window        f.next_key
  Alt Shift<Key>Escape       root|icon|window        f.prev_key
}

and ~/.Xresources as well

Mwm*useIconBox: True
Mwm*keyboardFocusPolicy: explicit
Mwm*raiseKeyFocus: true

And here is the resulting MWM session :)


Makefile that calls itself without hardcoding file name

If you have to call makefile multiple times. And you don’t want to hardcode file name you can make it following way:

makefilelocation = $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))

all:
        $(warning "I will call myself")
        $(MAKE) -f $(makefilelocation) message

message:
        $(warning "Hello message")

Remember that targets are indented with tabs :)

Then, just call it following way:

make -f makefile.test

or, if you put the file inside makefile, just call it like this

make

History repeats itself – or, applying law of series to Computer Science ;)

Some time ago I had this, quite bad, experience of upgrading OS X. It ended with horrible disaster. I have lost all my data from my HD. As I am super paranoid about data and backups, loosing all my data was not a big deal. I always have my daily backup running (external HD), I have also NAS running all the time. So, generally speaking, first experience was close to:

Nagle padł twardy dysk
Zamazał swą treść
Nie ma zdjęć

Few hours later, after getting all the data from backups, I was at place before the crash minus Gigabytes of all unnecessary data :) BTW – I am still waiting for my download link from 65daysofstatic ;) I don’t have a backup of few mp3 from these guys.

Few months later I have decided to upgrade OS X once again. And, guess what ;)

Yes, that’s right. It happened again! I have lost all the data again during system upgrade. It sounds like some bad luck. However, again, my daily backups plus NAS saved my day.

Now, there is another disaster coming into party :) My NAS is based on FreeBSD. I have decided to upgrade it as well. I remember issues while trying to upgrade it too many releases at one go. I have faced few issues while jumping from 8 or 9 to 10.2. So, I have said to myself.

– No, not this time. This time I will be supper safe and I will do upgrades as soon as new major release is ready.

I think you already suspect what’s coming :)

Yes, I have upgraded my NAS by upgrading FreeBSD and I have lost it for some time. It turned out that FreeBSD made some merges of /etc/devd.conf and I was not able to start my backup machine at all.

So, just to conclude. All systems are really fragile. And, an advice. Do not ignore messages regarding merging config files. Double check whether they are merged correctly :)

My NAS, TimeMachine and yet another backup are running now fine. They are patiently waiting for another disaster :)


IntelliJ – Scala Worksheet and missing symbols issue

In case your Worksheet can not find symbols from classes/traits/objects in your project you can use very simple solution to fix that.

If you see message – “not found: value …” or similar, just make sure to “Make project” while running Worksheet.

IntelliJ_MakeProject


Scala – the “successor” of C

class __(__ : String) {
  def ___ = __
  def ____(____ : __) = ___ + ____.___
}
new __("_") ____ new __("_")

Path Finder 7 – Norton Commander like layout

If you are using Path Finder 7 make sure to press Command + J (⌘ + J) and then set following settings (pay attention to “All windows” at the top).

pathfinder


Scratch w szkole – Zadanie 008 (rozwiązanie)

Poniżej rozwiązanie zadania 008 ze Scratcha

Zadanie 008 – rozwiązanie

A dla osób które wolą pooglądać niż poczytać, rozwiązanie na youtube, ale jeszcze nie dziś ;)


DevOps pessimist vs. optimist

Pessimist:

tmux
make >& make.log
make install >& make_install.log

Optimist:

make; make install >& /dev/null

svn: Aborting commit: ‘/directory’ remains in conflict

It’s as simple as that. You have something you want to delete. You know you don’t want it at all, but SVN keeps complaining.

svn: Aborting commit: 'directory' remains in conflict

Do not fight, do not struggle, don’t try to find the source of the issue, don’t even think about trying to understand it :) Just make it happy with this one :)

svn resolved directory

and commit changes

svn commit -m"Yes, finally removed" directory

Building tmux on OS X

You will need:

libevent-2.0.22 – link
openssl – https://github.com/openssl/openssl.git
tmux – https://tmux.github.io

# at first, compile and install openssl
git clone https://github.com/openssl/openssl.git
cd openssl
./config --prefix=$HOME/opt/usr
make; make install

# then, compile and install libevent
curl https://github.com/libevent/libevent/releases/download/\
release-2.0.22-stable/libevent-2.0.22-stable.tar.gz\
 -O libevent-2.0.22-stable.tar.gz

tar zxf libevent-2.0.22-stable.tar.gz
mv libevent-2.0.22-stable libevent
cd libevent

# Note, you may experience some issues when using OpenSSL above. 
# In that case, use one delivered
# together with OS X development env
export CFLAGS="-I/Applications/Xcode.app/Contents/Developer\
/Toolchains/XcodeDefault.xctoolchain/usr/lib/\
swift-migrator/sdk/MacOSX.sdk/usr/include\
 -I$HOME/opt/lzo/include"
./configure --prefix=/Users/michalo/opt/usr/
make; make install

# get tmux and build it
# if you prefer, you can use development version instead
# git clone https://github.com/tmux/tmux.git
curl https://github.com/tmux/tmux/releases/\
download/2.2/tmux-2.2.tar.gz -O tmux-2.2.tar.gz
tar zxf tmux-2.2.tar.gz
cd tmux-2.2

# as above, it might be that you will need system wide libs and includes
# note that we are using $HOME/opt/usr/include
# this is the place where libevent was installed
export CFLAGS="-I/Applications/Xcode.app/Contents/Developer\
/Toolchains/XcodeDefault.xctoolchain/usr/lib/\
swift-migrator/sdk/MacOSX.sdk/usr/include\
 -I$HOME/opt/lzo/include $HOME/opt/usr/include"

# this time, we have to point to libs as well (libevent again)
export LDFLAGS="-L$HOME/opt/usr/lib"
./configure --prefix=/Users/michalo/opt/usr/
make; make install

Now, you are ready to go.


iTerm 3 and Docker incompatibility

If you try to use iTerm 3 (beta) together with Docker, make sure to take a look at this link.


Scratch w szkole – Zadanie 008

To będzie jedna z ostatnich gier jakie napiszemy podczas zajęć. Tym razem, klasyczny, 8-mio bitowy Frogger. Zadanie będzie o tyle łatwe że nie będziemy używali niczego poza tym, co już poznaliśmy.

frogger

A zestaw bloczków jest tym razem naprawdę prosty. W trakcie zajęć dodamy jeszcze jeden, który będzie niespodzianką.

frogger_bloczki

Tym razem, zadanie wyglądało tak. Najpierw trzeba poruszyć żółwia i samochodzik. Dwa z nich nie działają. I tutaj niespodzianka. Dzieciaki błyskawicznie odkryły programowanie przez copy-paste ;)

Kolejnym etapem, było ożywienie żaby. I tu nie było problemów. Żaba dała radę.

Plik z zadaniem można znaleźć tutaj: Zadanie 008


Zapowiada sie ciekawie

Nowy rok szkolny i nowe wyzwania. No Starch Press pracuje nad ciekawą pozycją dla młodych programistów.

image

Link: https://www.nostarch.com/scratchplayground


Scratch w szkole – Zadanie 003 (rozwiązanie)

Poniżej rozwiązanie zadania 003 ze Scratcha

Zadanie 003 – rozwiązanie 001

Zadanie 003 – rozwiązanie 002

A dla osób które wolą pooglądać niż poczytać, rozwiązanie na youtube. House w tle :)


Converting mpeg4 to divx for Philips PD9010 (ffmpeg)

#!/bin/bash

ffmpeg -i $1 -c:v mpeg4 -q:v 5 -tag:v DIVX -s 640x220 -c:a libmp3lame -q:a 5 -ac 2 -ar 44100 $2

ffmpeg -i input -qscale 2 -vtag DX50 out.avi 

Ruby on Rails OS X El Capitan

If you get following error

sudo gem install rails --version 4.2.6
ERROR:  While executing gem ... (Gem::Exception)
    Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources

do following

gem source -r https://rubygems.org/

gem source -a http://rubygems.org/
https://rubygems.org is recommended for security over http://rubygems.org/

Do you want to add this insecure source? [yn]  y
http://rubygems.org/ added to sources

Then, install rails

sudo gem install rails --version 4.2.6

Scratch-UML N°002

scratch_uml_002


iTerm3 and Visual Bell

There is a new, cool way of presenting Visual Bell in iTerm3 (at the moment, I am using release 2.9.20160426). You can choose between OS X like icon in the middle of the screen or blinking the whole screen.

iterm3bell

To switch between settings simply press ⌘ + , (yes, this is command + comma) go to Advanced, and then set your desired behaviour for “Visual bell flashes the whole screen, not just a bell icon.”