Tag Archives: debian

Hakology Day 35 : Blog Entry

Reflecting on the weekend, have been working on a few projects. One using the max7219 LED matrix driver, which I’m considering writing my own library for as everything i’ve tried seems to fail, I have it working and can address each LED individually but haven’t been able display anything useful ie. fonts or text effects … anyway that’s a work in progress. I turned my hand to configuring a small 1.3″ OLED screen someone donated a while back now I can see it was some kind of addressing issue in the code I initially got it running (there were 2 pixels columns on the far right filled with random bits and a couple of leading pixel columns missing) anyway its working now I noticed the version I was running was from the google code repo and checked github see if the project was still live and found some more recent libraries, installed those and that seems to have remedied the problem.

Managed to sort out a good method for screen capture in gnome3 debian jessie. Was having issues capturing the screen in a format I was able to get in to my editing suite. Inadvertently I found out that debian jessie has built in screencapture/screencast ability. Pressing shift+ctrl+alt+R, a small red dot will appear in a panel near your login/logout  panel to show if you are recording, files are automatically saved to your home videos folder, to stop recording just hit the keyboard shortcut again.

These files happen to be in webm format, I havent yet tried running the webm files through handbrake to see if I can convert them to mp4 as my editing suite doesnt natively support webm and one huge problem with the built in screencast is it only records my desktop and no audio. (Maybe I’m doing something wrong, would be easier to just use the built in screencapture)

So eventually my final solution was to record using kazam to mp4, this captured the video + audio, was even hoping I wouldnt have to transcode it again, but still the default format output by kazam isnt compatible with vegas, I then ran the files through handbrake and imported them and everything seems ok … now all the audio syncs with the video perfectly.

Its a bit of a mess/bodge job but it works, maybe if I get some time in future I might have a look see if its possible to edit the default screencast settings to capture audio+video and output to a compatible format preferably mp4.

NB. The default screen recorder only allows you to record for 30 seconds use the following line in terminal to change the maximum record time.
gsettings set org.gnome.settings-daemon.plugins.media-keys max-screencast-length 45

Hakology Day 18 : Blog Entry

Feeling a lot better today but still a little under the weather. Have to do a few jobs this morning but should be online and creating later.

Picked up a PC for an upgrade 256gb SSD and PCIE wireless card. Just sorting that out and having a brew.

Waiting for images to burn, files to copy etc. Had a good play with kodi whilst I’ve been ill an I’m pretty impressed, makes it easier in some ways to watching content on your PC.

This program http://download.wsusoffline.net/ has been a real time saver, when people ask me to install windows 7 for them usually the update service is borked and needs fixing, quite frankly the MS tools are diabolical this seems to be the best / quickest way to patch and repair the windows update service.

Setting up wordpress for a new web client. Almost done with all my jobs for the day then hopefully get down to some recording even if its only a vblog.

Knackered and my head is aching, going to call it one for today. Finished all the updates on that build and also dropped debian jessie into a separate partition for them to try as they’d asked about linux. Need to be up early tomorrow and get that website online. Honestly not worth me recording a vlog b/c I’m still pretty flued up.

Connecting to a serial device over usb in debian / linux

First of all you’ll need a USB to serial cable, mine came with a driver disk but I didn’t use it. I’m running debian jessie and it detected it without any issues. If you want to check to see the device is working and detected just run lsusb and look for your device in the list.

Look for something like this
Bus 003 Device 003: ID 063b:2837 Prolific Technology, Inc. PL2303 Serial Port

Next check the device is accessible run the following:
sudo ls /dev | grep USB

Look for something like this …

Next check you have screen installed by running
sudo apt-get install screen

Connect to the device over serial using :
sudo screen /dev/ttyUSB0

You should now be connected to your device.
This is what I used to configure a HP2626 Pro-Curve switch over serial.
When I first connected I had to hit enter a few times to establish a connection / shell.
Have fun hacking

PyGame : Tutorial PT1 (Setup & Initialisation)

I would consider this my first proper post hehe … I started this blog to make life easier when doing videos about code sometimes the screen capture and editing that goes in to a short clip can be painful and consume a lot of my spare time. Here ill be able to waffle on about code and linux to my hearts content (with the ability to access the articles and update things after they have been published).

So this hopefully will turn in to some kind of archive generated by hakology plus various odds and ends I find lying about the interwebz.

I digress … keeping on point this is a python pygame introduction to simple 2D game engines (with a view to move on to opengl and 3D graphics at some later point) for this tutorial you will need the following:

Python 2.7

Python- Pygame Librarys and Modules

IDE (It doesnt really matter what you use – at the moment I’m really enjoying ninja-ide)

This tutorial is for linux users, the development rig I’m using at the moment is Debian Jessie (Test/Dev Release)

Ok so down to business if your rocking debian jessie or similar you shouldnt have too many problems getting up and running.

First install python

sudo apt-get install python2.7

Now install pygame

sudo apt-get install python-pygame

Now install ninja-ide

sudo apt-get install ninja-ide

Hopefully that all went well 🙂 (if it didn’t please consult google.com/pygame/python/debian documentation)

Now in your home folder we need to create a folder to store everything so pop a terminal and make a directory

mkdir pygame
cd pygame
touch tutorial1.py
ninja-ide tutorial1.py

Now you should have created a folder and a file in the folder and opened that file with ninja-ide

This is where the fun begins.

Add the following to the first lines of your python file ….

import pygame
from pygame.locals import *

The lines above tell the python interpreter to import and load all the librarys and variables from pygame.

Next we need to set some variable to store how big we’d like to make our game window.

wWIDTH = 640
wHEIGHT = 480

Right now were ready to add the first function that is called when the file is executed

if __name__ == “__main__”: # main function call

r = 1 # set variable for return value
pygame.init() # initialise python pygame
GCLOCK = pygame.time.Clock() # set game clock
GSURF = pygame.display.set_mode((wWIDTH, wHEIGHT)) # main game surface
while r != 0: # quit if return not equal to 0 (0 = game exit, 1 = restart main loop)

r = main() # get return value from main loop (1 == OK … 0 == exit)

Ok so lets explain the code … the first line of the above block is defacto python code you will find this in (almost) every python script you encounter, the second line defines a variable called ‘r’ and sets it equal to 1 this value is used later to determine if the game should continue or quit. GCLOCK is a variable used to store pygames clock which is used later for frame rate calculations and game speed. GSURF is the game surface ie. the area or the screen we are going to be drawing to notice we pass in the pre defined screen sizes we set at the top of the script. The while loop and main game call will not quit until the return value is equal to 0. The line within the while loop is the main game loop call when we call this function we expect a return value of either 1 or 0.

Right now to add the main game loop …

When you add this code it needs to go below the variables we created earlier but above the first function call.

def main():

r = 1
while(1): # do for a while (game loop)

for event in pygame.event.get(): # handle events

if event.type == QUIT: # ctrl+c

r = 0 # return 0 = (game is over)

elif event.type == KEYDOWN: # down arrow

if event.key == K_ESCAPE:

r = 0 # return 0 = (game is over)

if event.key == K_q: # q key pressed

r = 0

GSURF.fill((0, 0, 0))

if r != 1: #check value of r

break #exit main game loop

return r

Ok so the above code basically runs and keeps the main game window open it loops forever until the escape key is detected if the escape key is detected or quit program event then the window will close.

You can now test the script by pressing play in the ninja-ide tool bar.

or entering the following in the command line …

cd ~
cd pygame
python tutorial1.py

Enjoy your nice blank window opening and closing.

Whoot well done you and stay tuned for part two coming very very soon 🙂

Pastebin link to raw code – http://pastebin.com/vzACDi3v